Skip to content

@agentier/google

Google Gemini provider for the agentier framework. Communicates via the Gemini REST API.

Functions

google(config)

Creates a Google Gemini ModelProvider. Supports both blocking chat (via generateContent) and streaming stream (via streamGenerateContent) endpoints. The API key is passed as a query parameter.

ts
function google(config: GoogleProviderConfig): ModelProvider

Parameters:

  • config — Provider configuration including API key and optional overrides.

Returns: A ModelProvider wired to the Google Gemini API.

Example:

ts
import { google } from '@agentier/google'

const provider = google({ apiKey: process.env.GOOGLE_API_KEY! })
const response = await provider.chat({
    model: 'gemini-2.0-flash',
    messages: [{ role: 'user', content: 'Hello!' }],
})

Interfaces

GoogleProviderConfig

ts
interface GoogleProviderConfig {
    apiKey: string
    baseUrl?: string
    apiVersion?: string
    defaultHeaders?: Record<string, string>
    fetch?: typeof globalThis.fetch
}
PropertyTypeDescription
apiKeystringGoogle AI API key appended as a query parameter to each request.
baseUrlstring?Base URL for API requests. Defaults to https://generativelanguage.googleapis.com/{apiVersion}.
apiVersionstring?Gemini API version used in the default base URL. Defaults to 'v1beta'.
defaultHeadersRecord<string, string>?Additional headers merged into every request.
fetchtypeof globalThis.fetch?Custom fetch implementation, useful for proxies or test doubles.

Released under the MIT License.