Creates a new GeminiAdapter instance.
Gemini adapter configuration
ReadonlyproviderProvider identifier (e.g., 'anthropic', 'openai')
ReadonlymodelModel identifier (e.g., 'claude-sonnet-4', 'gpt-4o')
ReadonlycapabilitiesCapabilities this model supports
Protected ReadonlyloggerLogger for request/response logging
Protected ReadonlyconfigConfiguration for the adapter
Check if this adapter supports a specific capability.
The capability to check for
True if the capability is supported
ProtectedlogLog details about an outgoing request. Sanitizes sensitive information before logging.
The completion request to log
ProtectedlogLog details about a received response.
The completion response to log
ProtectedtransformTransform a provider-specific error into a standardized ModelError.
Maps common error patterns to appropriate error codes:
The original error from the provider
A standardized ModelError
Validates adapter configuration. Extends base validation with Gemini-specific checks.
Send a completion request to Gemini.
The completion request
Result with response or ModelError
Stream a completion request from Gemini.
The completion request
Count tokens in text using Gemini-specific estimation.
Text to count tokens for
Approximate token count
(#2540) List Gemini models exposed by the configured API key.
Wraps client.models.list() (returns a Pager). 5-min cache,
concurrent-caller promise sharing.
Gemini/Google AI model adapter.
Provides a unified interface for interacting with Google's Gemini models. Supports completion, streaming, tool use, and vision capabilities.
Example