SPEC: agent-provider-gemini
Purpose
Google Gemini provider implementation (@google/genai), also implementing IImageGenerationProvider.
A deprecated GoogleProvider compatibility alias is re-exported via the ./google entry for callers
migrating off the old name.
Users who need a provider not included here can implement IAIProvider from @robota-sdk/agent-core
and register it directly.
Contract
- Streaming.
GeminiProviderpreserves every assistant function call andusageMetadatavalue returned by Gemini's streaming API.chatStream()emits text deltas as they arrive plus a universal assistant message for a function-call chunk or a usage-only terminal chunk. Whenchat()uses its streaming assembly path (onTextDeltaset), it returns one complete assistant message assembled from all stream chunks. - Requests containing
nativeWebToolsare validated by bothchat()andchatStream(). Gemini does not advertise native web tools, so such a request fails explicitly instead of being silently ignored. - Model effort. A verified model selection sends Gemini's
thinkingConfig.thinkingLevelcontrol, preserves unrelatedthinkingConfigfields, and rejects a conflicting staticthinkingLevelorthinkingBudget.autoreports the documented default while omitting a control; unknown models and unverified routes reportnot-appliedrather than inventing a numericthinkingBudgetmapping. - Tool schema projection.
GeminiProvider.projectionProfile()strips foreign JSON-Schema keywords andadditionalPropertiesbefore tool schemas reach Gemini's request builder, because Gemini'sSchematype is a fixed OpenAPI-3.0 subset, not standard JSON Schema — a member the builder doesn't understand must not fail silently downstream. A tool that projection rejects is omitted from that request alone and reported once per cache identity via agent-core'sToolSchemaProjectionlogger.
Non-goals
- Does not depend on
agent-framework,agent-session, or any higher-layer package — only@robota-sdk/agent-coreand its own vendor SDK.
Design decisions
- The provider definition's diagnostic
endpoint(generativelanguage.googleapis.com:443) is stated separately fromdefaults.baseURLon purpose:endpointexists only for the pre-session doctor's TCP reachability check, whilebaseURLis the runtime-effective value persisted into profiles and passed tocreateProvider. A profile with its ownbaseURLis probed at that host instead.