@aetheros/provider-google
v0.2.0
Published
Google Gemini adapter for AetherOS and Aevron (Gemini API or Vertex AI): streaming, structured output, tools, thinking, documents and prompt caching.
Readme
@aetheros/provider-google
Google Gemini adapter for AetherOS and Aevron (Generative Language API or Vertex AI): streaming, structured output, tools, thinking controls, documents and prompt caching.
import {fromEnvironment} from '@aetheros/provider-google';
const gemini = fromEnvironment(process.env, {model: '<gemini model id>'}); // GEMINI_API_KEY or GOOGLE_API_KEY
engine.registerProvider(gemini);- Streaming (
onEvent) and structured output (responseFormat); system prompt fromcontext.system. - Images and documents: a message's
contentmay be a list of{type: 'text', text},{type: 'image', mediaType, data}and{type: 'document', mediaType, data, name?}blocks (base64); they go to Gemini as inline data. Documents may be PDF, plain text, Markdown, CSV, HTML, XML, RTF or JSON; other types are refused withunsupported, and images plus documents over 20 MB withrequest_too_large(larger files need Gemini's file upload, not built). - The key goes in a request header, never in the URL, and is never logged.
- Safety blocks come back as
refusal, not as an error. - Errors carry
code,statusandretryable, so@aetheros/modelsfallbacks know when another model may help. - Tools: every call goes through the toolset Aevron hands over, so the host's approval, actor and tenant checks apply. Tool ids with dots become function names with
_. Gemini's own turn is sent back unchanged between rounds, which keeps its thought signatures. At most 8 tool rounds by default (maxToolRounds). - Thinking:
effort: 'low' | 'medium' | 'high'(constructor, request orcontext) becomesthinkingConfig.thinkingLevel(Gemini 3 and later) or athinkingBudgetof 1024, 8192 or 24576 tokens (Gemini 2.5). Models without thinking (Gemini 2.0 and older, Gemma) refuse it withunsupported. - Prompt caching (on by default): when the system prompt and tool declarations together are large (
cacheMinTokens, default 4096, estimated at four characters a token), they are stored once as cached content (cacheTtlSeconds, default 300) and later requests refer to it. If the model or size does not allow it, the request goes out normally and that prefix is not tried again for ten minutes. Gemini's implicit caching works either way.usage.cachedInputTokensreports cached tokens (they are part ofusage.inputTokens). Turn it off withpromptCache: false. Cached content is also billed for storage while it lives.
Vertex AI
new GoogleProvider({platform: 'vertex', project: 'my-project', region: 'us-central1', model: 'gemini-3.6-flash'});Address:
https://{region}-aiplatform.googleapis.com(https://aiplatform.googleapis.comfor the default regionglobal);endpointoverrides it (https only).Access token from
GOOGLE_CLOUD_ACCESS_TOKENoraccessToken: async () => token(a credential helper you write). It is read before each request and never stored on public fields. A token fromgcloudlasts one hour:export GOOGLE_CLOUD_ACCESS_TOKEN="$(gcloud auth print-access-token)"PowerShell:
$env:GOOGLE_CLOUD_ACCESS_TOKEN = gcloud auth print-access-tokenfromEnvironment()uses Vertex AI whenGEMINI_PLATFORM=vertexorGOOGLE_GENAI_USE_VERTEXAI=true, withGOOGLE_CLOUD_PROJECTandGOOGLE_CLOUD_LOCATION.
