class

Autobot::Providers::GeminiProvider

Inherits Autobot::Providers::Provider < Reference < Object

Google Gemini provider - https://ai.google.dev/gemini-api/docs Supports both standard Google AI Studio (API Key) and Code Assist API (OAuth) Includes Context Caching support for large context payloads

Constants

AI_STUDIO_BASE = "https://generativelanguage.googleapis.com/v1beta"

Standard API for API Keys

CACHE_MIN_CONTENT_SIZE = 8000

Minimum system+tools payload size (chars) before an explicit cache is worthwhile

CACHE_TTL = "3600s"
CODE_ASSIST_BASE = "https://cloudcode-pa.googleapis.com/v1internal"

Code Assist API for OAuth

CODE_ASSIST_USER_AGENT = "google-api-nodejs-client/9.15.1"

Client identifiers the Code Assist API expects

CONNECT_TIMEOUT = 30.seconds
DEFAULT_MODEL = "gemini/gemini-2.0-flash"
GOOG_API_CLIENT = "gl-node/22.13.1"
HTTP_SERVER_ERROR_MIN = 500
HTTP_TOO_MANY_REQUESTS = 429
HTTP_UNAUTHORIZED = 401
Log = ::Log.for(self)
MAX_RETRIES = 3
OAUTH_TOKEN_URL = "https://oauth2.googleapis.com/token"
READ_TIMEOUT = 300.seconds
RETRY_BASE_DELAY = 2.0
RETRY_JITTER_MAX = 0.5
TOKEN_EXPIRY_LEEWAY = 60
UNSUPPORTED_SCHEMA_KEYS = ["additionalProperties", "$schema", "$ref", "$defs", "definitions"]

JSON-Schema keywords Gemini's functionDeclarations rejects

USER_AGENT = "Autobot/#{VERSION}"

Constructors

new(api_key : String, model : String = DEFAULT_MODEL, client_id : String | Nil = nil, client_secret : String | Nil = nil, refresh_token : String | Nil = nil, api_base : String | Nil = nil)
Source

Instance methods

chat(messages : Array(Hash(String, JSON::Any)), tools : Array(Hash(String, JSON::Any)) | Nil = nil, model : String | Nil = nil, max_tokens : Int32 = DEFAULT_MAX_TOKENS, temperature : Float64 = DEFAULT_TEMPERATURE) : Response
Source
default_model

The default model identifier for this provider.

Source
supports_progressive_disclosure?

Whether this provider benefits from progressive tool disclosure. Providers with caching (like Gemini) should disable this so the tool schemas remain stable and don't bust the cache.

Source