How do I use Gemini in Claude Code?
Google's Gemini API has no Anthropic-format endpoint, so set ANTHROPIC_BASE_URL to https://api.stdcmpt.com with a Standard Compute key and ANTHROPIC_MODEL to google/gemini-3.8-flash: Claude Code then runs on Gemini 3.8 Flash, with 3.1 Pro on the opus slot, on a plan from $19 a month that returns HTTP 402 to new requests once the compute budget is used.
# Gemini 3.8 Flash for the session, 3.1 Pro on opus, Flash-Lite for background calls
# No /v1 here: Claude Code adds /v1/messages itself.
export ANTHROPIC_BASE_URL=https://api.stdcmpt.com
export ANTHROPIC_AUTH_TOKEN=YOUR_API_KEY
export ANTHROPIC_MODEL=google/gemini-3.8-flash
export ANTHROPIC_DEFAULT_OPUS_MODEL=google/gemini-3.1-pro-preview
export ANTHROPIC_DEFAULT_SONNET_MODEL=google/gemini-3.8-flash
export ANTHROPIC_DEFAULT_HAIKU_MODEL=google/gemini-3.5-flash-lite
export CLAUDE_CODE_SUBAGENT_MODEL=google/gemini-3.8-flash
claude
Replace YOUR_API_KEY with a key from the dashboard. Google has no Anthropic-format endpoint, so there is no first-party tab here.
Three Gemini IDs, three slots
| Slot | Model ID | Why |
|---|---|---|
| Main and sonnet | google/gemini-3.8-flash | Fast and low-priced for most turns |
| opus | google/gemini-3.1-pro-preview | Harder steps; switch with /model opus |
| haiku (background calls) | google/gemini-3.5-flash-lite | Titles and summaries at Flash-Lite's price |
All three read images, so pasted screenshots work in every slot.
Gemini 3.8 Flash's price doubles on January 1
Google lists Gemini 3.8 Flash at an introductory $0.75 input and $3.75 output per million tokens through December 31, 2026, then $1.50 and $7.50. A typical Claude Code day goes from about $1.54 to $3.08. Plan prices here do not change with it.
| Per day | 3.8 Flash, 2026 | 3.8 Flash, 2027 | 3.1 Pro |
|---|---|---|---|
| Typical day | $1.54 | $3.08 | $4.19 |
| Busy day | $16 | $31 | $43 |
Gemini API paid tier per million tokens: 3.8 Flash $0.75 input, $0.075 cached, $3.75 output (intro), 3.1 Pro $2, $0.20, $12 for prompts up to 200K. Source. A typical day is 8.5M tokens and a busy one 86.7M, 87.2% of input as cache reads: the median and 90th-percentile coding-agent day in our Agent Burn Index, measured on OpenCode, Cline, Kilo and similar agents, September 13 to October 12, 2026. Priced at the list rates above; your own days will differ.
What changes in Claude Code
- The thinking toggle has no effect; set each model's reasoning level on the Models page.
- The WebSearch tool is not available on this endpoint.
- Claude Code assumes a 200K window for these IDs; set
CLAUDE_CODE_MAX_CONTEXT_TOKENSif you want it to keep more before compacting.
The catch
Claude Code is tuned for Claude, and Anthropic does not support other models behind a gateway, so run a real task before switching your daily work. If you only want Gemini, Google's own Gemini CLI is the native agent; Claude Code with Gemini makes sense when you want Claude Code's workflow and the option to switch models per step.
Where Standard Compute fits
No proxy to run on your machine: the Anthropic-to-Gemini translation happens on our side. At this year's list price the Starter ($19 a month, $20 of compute) plan covers about 12 typical 3.8 Flash days.
FAQ
Can I use my Gemini API key directly in Claude Code?
Not without a translator. Gemini's API takes its own format and an OpenAI-compatible Chat Completions format, not Anthropic's Messages API, so Claude Code cannot call it directly. LiteLLM or claude-code-router can translate on your machine.
Which Gemini is best for Claude Code?
3.8 Flash for most turns, 3.1 Pro for hard ones. 3.1 Pro costs nearly three times as much per day at this year's list prices, so keep it on the opus slot.
Does my Claude Pro or Max subscription pay for this?
No. While ANTHROPIC_AUTH_TOKEN holds a gateway key, Claude Code sends that key instead of your claude.ai login, so the subscription's limits and billing do not apply. Remove the variables to go back to it.