Providers
Gemini API
Uses the Ahena CLI (beta). Install it with npm install -g @ahena/cli, or prefix commands with npx @ahena/cli. See Installation. The dashboard covers projects, connections, Doctor, the Stack Graph, plans and approvals without it.
Overview
Ahena checks your Gemini API key (the Gemini Developer API, with keys from Google AI
Studio) and that your configured model exists and supports generateContent, reports the
model's token limits, and generates an adapter behind the common ahena.ai interface using
the official @google/genai SDK. Your app calls the Gemini API directly. Ahena is never in
the inference path, and its checks never call generateContent on your key.
Vertex AI is a different product. It serves Gemini models through Google Cloud projects,
service accounts and IAM, on other hosts. Ahena doesn't integrate Vertex AI yet; this
provider only talks to generativelanguage.googleapis.com with an API key.
Package: @ahena/provider-gemini · Category: ai · Default model: gemini-3.8-flash
Capabilities: text-generation, model-availability
Maturity: verified against a fake of the API; not yet verified against the real service.
Connection
GEMINI_API_KEY (secret), created in Google AI Studio.
GEMINI_API_KEY=… ahena connect gemini -e production
Ahena sends the key only in the x-goog-api-key header, never as a ?key= query
parameter, so it can't end up in URL logs.
Permissions
Gemini API keys carry no scopes Ahena can read, so Ahena only checks that the key works
(permissionCheck: "authentication-only"). It calls models.list and models.get, nothing
else. Every Gemini API key belongs to a Google Cloud project, which holds its billing and
quota. Restrict the key to the Gemini API (Generative Language API): if its API
restrictions exclude it, the API answers 403 and Ahena says so.
Capabilities
| Capability | Access | What Ahena does |
|---|---|---|
text-generation |
read-only | Generates src/ahena/ai/providers/gemini.ts behind ahena.ai.generate(); ahena.ai.raw is the GoogleGenAI client. Ahena never calls generateContent itself. |
model-availability |
read-only | Checks ai.model with models.get: it must exist and list generateContent; reports input and output token limits. |
Network: only generativelanguage.googleapis.com (enforced). models.list is read with
pageSize=1000, following nextPageToken until there is none.
Configure
There's nothing to plan or apply: Ahena changes nothing in your Google account. You choose
the provider and model in ahena.config.ts (models/… prefixes are accepted and dropped):
ai: {
provider: { development: "ollama", production: "gemini" },
model: { development: "llama3.2", production: "gemini-3.8-flash" },
},
Generate
ahena generate gemini writes:
src/ahena/ai/types.ts: the sharedAiAdapterinterface.src/ahena/ai/providers/gemini.ts:adapter()createsnew GoogleGenAI({ apiKey, vertexai: false })(soGOOGLE_GENAI_USE_VERTEXAIcan't silently switch it to Vertex AI) and callsmodels.generateContentwith the system prompt assystemInstructionandmaxTokensasmaxOutputTokens. A blocked prompt (promptFeedback.blockReason) becomes a clear error..env.example.gemini:GEMINI_API_KEY=.
Limitations
- Quota, rate limits and billing tier aren't visible. The Gemini API doesn't report a
key's limits, quota use, or whether its Cloud project has billing. Doctor says so
(
gemini.quota, INFO) instead of guessing. Check them in Google AI Studio. - Data-use terms depend on billing, which Ahena can't see. Under Google's Gemini API Additional Terms, unpaid services may use your prompts and responses to improve Google's products (with human review), while paid services (a project with an active Cloud Billing account) don't. In the EEA, Switzerland and the UK the paid-service data terms apply to unpaid use too. Read the terms; Ahena only points to them.
- Vertex AI (service accounts, GCP projects, regional endpoints) isn't supported.
- The common interface covers text generation. Multimodal input, tools, structured output,
streaming and thinking settings use
ahena.ai.raw. ahena driftdoesn't track AI providers.
Manual steps
- Create a key in Google AI Studio (https://aistudio.google.com/apikey) in a project you use for this app, and restrict it to the Gemini API.
- Decide whether the project needs billing (rate limits and data-use terms differ) and set it up in Google AI Studio.
- Set
GEMINI_API_KEY(andAI_PROVIDER=geminiif several adapters exist) where your app runs.
Doctor checks
| Id | Severity | Meaning |
|---|---|---|
gemini.key |
PASS / FAIL | Key accepted. FAIL for an invalid key (400 API_KEY_INVALID or 401), a key reported as leaked, or a key whose restrictions exclude the Gemini API (403). If it fails, no other check runs. |
gemini.model |
PASS / FAIL | Configured model exists and supports generateContent. |
gemini.model_limits |
INFO | Input and output token limits, and whether the model thinks. |
gemini.quota |
INFO | Quota, rate limits and billing tier aren't exposed by the API; in production, the steps include checking billing and the data-use terms. |
Set up step by step
Create the key. Open Google AI Studio (https://aistudio.google.com/apikey), go to API Keys, choose Create API key and pick (or create) the Google Cloud project it belongs to. Copy the key.
Minimum permissions. Keys have no scopes. Restrict the key to the Gemini API (Generative Language API); nothing else is needed. Ahena only lists and reads models.
Connect.
GEMINI_API_KEY=… ahena connect gemini -e productionVerify the connection.
ahena inspect gemini -e productionlists the models the key can see, with their token limits.Run Doctor.
ahena doctor -e productionchecks the key and yourai.model.Plan.
ahena plan -e productionlists no Gemini changes: there's nothing to apply.Make a change. Set
ai.providerandai.modelinahena.config.ts, then runahena generate -e productionto write the adapter. Billing and key restrictions are changed in Google AI Studio or Google Cloud.Verify. Run
ahena doctor -e productionagain:gemini.modelshould be PASS.Troubleshooting.
Symptom Cause What to do gemini.keyFAIL, connection expiredInvalid, deleted or mistyped key Create a new key in Google AI Studio and reconnect. "reported as leaked" Google blocked the key Create a new key; remove the old one from wherever it was exposed. Connection needs action (403) The key's API restrictions exclude the Gemini API Allow the Generative Language API on the key, or create a new key. gemini.modelFAILModel id wrong, retired, or not a text model Use a current model from https://ai.google.dev/gemini-api/docs/models. HTTP 429 from your app Rate limit or quota reached Check the project's limits in Google AI Studio; enable billing for higher limits. 400 FAILED_PRECONDITIONfrom your appA prerequisite such as billing or regional availability isn't met Check the project's billing and region in Google AI Studio. Disconnect and revoke.
ahena disconnect gemini -e productionremoves the stored key. Then delete the key in Google AI Studio (API Keys).
Disconnect behavior
Removes the connection and the key Ahena stored. Delete the key in Google AI Studio (https://aistudio.google.com/apikey). Nothing in your Google account is changed.