Overview
The Google GenAI provider gives you access to Gemini models with advanced multimodal capabilities, embeddings, and image generation through Gemini native image models.Installation
createGoogleGenAI()
Create a Google GenAI provider instance.Options
string
Your Google AI API key. Pass it explicitly or set the
GOOGLE_API_KEY
environment variable.string
API version to use (e.g.,
'v1', 'v1beta').string
Custom base URL for API requests.
GoogleGenAIClient
Provide your own configured Google GenAI client instance.
Returns
GoogleGenAIProvider with methods chatModel(), embeddingModel(), and imageModel().
Supported models
Chat models
Gemini 4 (thinking level)
Gemini 4 (thinking level)
- gemini-4-argon - Flagship reasoning model for coding, agents, and hard science and math tasks
Gemini 3.x (thinking level)
Gemini 3.x (thinking level)
- gemini-3.8-flash - Fast workhorse for coding and agentic workflows
- gemini-3.7-flash - Previous Flash model for agents and coding
- gemini-3.6-flash - Token-efficient Flash model for agents and coding
- gemini-3.5-flash - Previous generation Flash model
- gemini-3.5-flash-lite - Cost-efficient model for high-volume tasks
- gemini-3.1-pro-preview - High-capability multimodal preview model
- gemini-3.1-flash-lite - Lightweight thinking-level model
- gemini-3-flash-preview - Previous Gemini 3 generation Flash model
Gemini 2.5 (thinking budget)
Gemini 2.5 (thinking budget)
- gemini-2.5-pro - High capability, budget-based thinking
- gemini-2.5-flash - Fast with optional thinking
- gemini-2.5-flash-lite - Lightweight with optional thinking
Embedding models
- text-embedding-004 - Latest text embedding model
Image models
- gemini-nano-banana-2.1 - Gemini native image generation
- gemini-3.1-flash-image - Gemini native image generation
- gemini-3-pro-image-preview - Gemini native image generation preview
- gemini-2.5-flash-image - Gemini native image generation
Examples
Basic chat
Reasoning
Multimodal input
Embeddings
Image generation
Streaming
Tool calling
Model capabilities
Google extends the sharedModelCapabilities shape with thinkingParam, which
selects budget or level control. The shared mode field reports whether
thinking is optional or always on. Inspect these values before setting
reasoning options:
temperature, topP, and topK while
reasoning is enabled. gemini-4-argon reports
reasoning.restrictsSamplingParams as true. Passing temperature, topP,
or the topK, frequencyPenalty, or presencePenalty provider options throws
ValidationError before the request, including when you omit reasoning,
because thinking stays on. All unified tool-choice modes remain supported.
modalities.input is ['text', 'image', 'file', 'audio'] for every Gemini
chat model. Image sources accept both base64 and url. A URL maps to
fileData.fileUri, which accepts publicly readable HTTP(S) URLs, pre-signed
URLs, gs:// objects, and Files API URIs. The URL is fetched by Google rather
than by this library, so the content must be reachable from Google’s side.
File and audio parts map to inlineData with the provided MIME type.
Audio parts support audio/wav, audio/mp3, audio/aiff, audio/aac,
audio/ogg, and audio/flac. The total inline request size is limited to 20
MB. Use base64 data only; core-ai does not upload audio through the Files API.
modalities.output is ['text'] for chat models. Native image generation uses
imageModel().
System messages
Gemini accepts system instructions only at the start of a conversation. Every model reportsmodel.capabilities.messages.systemPlacement as 'leading'.
Leading system messages map to systemInstruction, and a system message after
the first non-system message throws
UnsupportedSystemMessagePlacementError
before the request. Send later instructions as part of a user message instead.
Strict tool schemas
Gemini has no strict tool mode: every model reportsmodel.capabilities.tools.strictSchemas as { supported: false }, and
strict: true throws ToolSchemaStrictnessError locally. See
Strict tool schemas.
Thinking modes
Gemini models use either thinking levels or token budgets. Models whosereasoning.mode is always-on cannot disable thinking.
Thinking level (Gemini 3 and 4)
Gemini 3 and Gemini 4 models steer thinking with named levels, and each model accepts its own subset.capabilities.reasoning.supportedEfforts lists the
efforts a model has a level for:
A supported effort is sent as the level of the same name. Any other effort is
clamped to the nearest supported one first, so
max always resolves to
high and minimal resolves to low on models that have no minimal level.
gemini-4-argon defaults to medium when you omit reasoning.
Gemini 3 and Gemini 4 models cannot disable thinking completely.
Thinking budget (Gemini 2.5)
Each Gemini 2.5 model accepts its own range of thinking budgets, as listed in Google’s thinking documentation.max uses the model’s documented maximum and high 75% of it, so the two
stay distinct. The lower efforts are the same on every model.
capabilities.reasoning.thinkingBudgetRange exposes each model’s range.
Output limits
Gemini counts thought tokens againstmaxOutputTokens. When you omit
maxTokens, the adapter leaves maxOutputTokens unset and Gemini uses the
model’s output limit (65,536 for Gemini 2.5, Gemini 3, and gemini-4-argon,
reported as capabilities.output.maxTokens). generate and stream send a
synchronous request, so a maxTokens above 65,536 on gemini-4-argon is
rejected by the API.
On Gemini 2.5, a maxTokens at or below the thinking budget throws a
ValidationError instead of ending with an empty answer. The budget is never
reduced to fit. Raise maxTokens, lower the effort, or omit maxTokens.
gemini-2.5-flash and gemini-2.5-flash-lite can skip thinking by omitting
the reasoning parameter.Thought signatures
Google may attach a thought signature under thegoogle key of a part’s
providerMetadata. Reasoning parts already expose it there. Gemini 3 also
attaches a signature to function call parts; core-ai stores that on the
tool-call part so multi-step tool loops can round-trip it.
GoogleReasoningMetadata type contains:
thoughtSignature— signature for preserving thought context across multi-turn conversations
Provider-specific options
Options are namespaced undergoogle in providerOptions:
Generate options
gemini-4-argon rejects topK, frequencyPenalty, and presencePenalty,
along with temperature and topP. stopSequences and seed still apply.
Embed options
taskType, title, mimeType, autoTruncate.
Image options
Gemini image models supportseed and aspectRatio. Every model except
Gemini 2.5 Flash Image also supports imageSize; Gemini 2.5 Flash Image uses
its fixed 1K output. The n option cannot request multiple images:
aspectRatio, imageSize, seed.
Error handling
Model comparison
Related
OpenAI Provider
GPT models and image generation
Anthropic Provider
Claude models with extended thinking
Multi-Modal Guide
Learn how to work with vision and audio