Skip to content
Aventail™ co-founder speaks to BBC Radio Wales on AI safety and AI agents.Read the story
Aventail™
All guides

Claude Code + Gemini: the routes that work today

14 min read

Claude Code cannot call Gemini directly. The gateway routes that work in 2026, the LiteLLM setup step by step, the limits, and what Google does with prompts.

Claude Code cannot call Gemini directly. It sends requests in Anthropic's Messages format, and as of 15 November 2026 Google's Gemini API documents its own format and an OpenAI-compatible endpoint, with no Anthropic-compatible one. A gateway that translates between the two formats makes the pairing work.

Anthropic states that it does not support routing Claude Code to non-Claude models through any gateway, and Google does not document this pairing. It runs, and a Claude Code update can break it. The routes that work today:

Route

Who maintains it

What you run

Where prompts go

Read on 15 November 2026

LiteLLM proxy

Third-party project (BerriAI/litellm on GitHub). Not from Google or Anthropic

A proxy on your machine or a server

Straight to Google with your own key

Step-by-step tutorial, last updated 14 November 2026

OpenRouter

Commercial hosted gateway

Nothing local

OpenRouter, then Google AI Studio or Vertex

OpenRouter says Claude Code is only guaranteed with Anthropic's own provider

Claude Code Router

Community project (musistudio on GitHub), MIT licence

A desktop app or npm CLI with a local gateway

Straight to Google with your own key

README lists Gemini among supported protocols

Bifrost

Open-source gateway from Maxim, Apache-2.0

A local gateway started with npx

Straight to Google with your own key

Vendor guide; its examples still name Gemini 2.5 models

Aventail™ Connect

Aventail™

Aventail™ Link on each machine

Google, through your organisation's own key, under a routing rule

Hosted routing is in beta

Three things that look like routes are something else. CLAUDE_CODE_USE_VERTEX=1 connects Claude Code to Claude models on Google Cloud; it does not reach Gemini. Google's Gemini Docs MCP server and agent skills for Claude Code give Claude current Gemini documentation, and do not change the model Claude Code runs on. The gemini-for-claude-code proxy on GitHub was archived by its owner on 19 February 2026.

The steps below use LiteLLM, whose docs give every command for this pairing.

What you need

Minimum

Notes

Claude Code

Any current version

No Anthropic account is needed for this path

Gemini API key

Created at aistudio.google.com/apikey

Google's SDKs read GEMINI_API_KEY or GOOGLE_API_KEY

Google billing

A project on the paid tier for private code

On the free tier, Google uses your prompts to improve its products

LiteLLM

Installed with uv

It listens on port 4000

A Gemini model with function calling

See the table below

Claude Code edits files and runs commands through tools

Model code

Context window

Free tier

Paid price per 1M tokens, input / output

gemini-4-carbon

1M, shared by input and output

No

$2 / $10 through 30 November 2026, then $4 / $20

gemini-4-argon

1M, shared by input and output

No

$2 / $10 through 30 November 2026, then $4 / $20

gemini-4-hydrogen

1M

Yes

$1.50 / $7.50

gemini-3.8-flash

1M input, 65K output

Yes

$0.75 / $3.75 through 31 December 2026, then $1.50 / $7.50

Output prices include thinking tokens. Our guide to Gemini 4 Argon vs Carbon covers the choice between the two frontier models.

Step 1: install Claude Code

macOS, Linux and WSL:

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Step 2: get a Gemini API key

Create a key at aistudio.google.com/apikey and export it:

export GEMINI_API_KEY=[YOUR_API_KEY_HERE]

For private code, link a billing account to the project first. New accounts start on the free tier, and the data terms differ by tier.

Step 3: install LiteLLM and write the config

uv tool install 'litellm[proxy]'

Create config.yaml. This is LiteLLM's Google AI Studio example:

model_list:
# Google Gemini
- model_name: gemini-3.8-flash
litellm_params:
model: gemini/gemini-3.8-flash
api_key: os.environ/GEMINI_API_KEY

model_name is the name Claude Code will ask for. model is gemini/ plus Google's model code, so another model from the table follows the same pattern. Set a key for the proxy itself:

export LITELLM_MASTER_KEY="sk-<paste-a-long-random-key>" # Generate a secure key

To go through Vertex AI in place of an API key, LiteLLM's example uses a service account:

model_list:
# Google Gemini
- model_name: vertex-gemini-3.8-flash
litellm_params:
model: vertex_ai/gemini-3.8-flash
vertex_credentials: os.environ/VERTEX_FILE_PATH_ENV_VAR # os.environ["VERTEX_FILE_PATH_ENV_VAR"] = "/path/to/service_account.json"
vertex_project: "my-test-project"
vertex_location: "us-central1"

LiteLLM's own example shows us-east-1 as the location. Use a Google Cloud location for your project, such as us-central1.

Step 4: start the proxy and test it

litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000

curl -X POST http://0.0.0.0:4000/v1/messages \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"max_tokens": 1000,
"messages": [{"role": "user", "content": "What is the capital of France?"}]
}'

A normal answer means the proxy accepts Messages requests and Google replied.

Step 5: point Claude Code at the proxy

export ANTHROPIC_BASE_URL="http://0.0.0.0:4000"
export ANTHROPIC_AUTH_TOKEN="$LITELLM_MASTER_KEY"

# Use Google Gemini
claude --model gemini-3.8-flash

Four settings from Anthropic's docs matter on a non-Claude model:

  • Aliases. opus, sonnet and haiku still exist inside Claude Code. Point them at names your proxy serves with ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL, and set CLAUDE_CODE_SUBAGENT_MODEL for subagents.

  • Context window. Claude Code assumes a 1M-token window for a model ID it does not recognise. That matches the Gemini models above. For a smaller model, set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the real window.

  • Request fields. For an unrecognised ID, Claude Code sends everything current Claude models accept, including adaptive reasoning, effort and context management. If the gateway or Google rejects a field, CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 stops the pre-release ones.

  • Model picker. CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 adds the proxy's models to /model. LiteLLM notes that the picker only keeps gateway models whose ID contains claude or anthropic, so a Gemini model appears only under a Claude-flavoured name (LiteLLM's example is kimi-k3-claude-compatible). Starting with claude --model avoids the problem.

If you were signed in to Claude Code before, run /logout once so the cached login does not conflict with the gateway token.

Step 6: the other routes in brief

OpenRouter. Follow our guide to Claude Code with OpenRouter, then set a role variable to a Gemini slug such as google/gemini-4-argon. No local process is needed. OpenRouter does not document this pairing and warns that Claude Code may not work correctly with other providers.

Claude Code Router. Install the desktop app from its GitHub releases, or the CLI:

npm install -g @musistudio/claude-code-router
ccr ui

Open http://127.0.0.1:3458, add a provider with the Gemini protocol and your key, start the server (the gateway listens on http://127.0.0.1:3456), and apply the Claude Code profile under Agent Config. The CLI needs Node.js 22 or newer.

Bifrost. npx -y @maximhq/bifrost starts a gateway on port 8080 with a web UI for provider keys. Its Anthropic-compatible endpoint is http://localhost:8080/anthropic, which is the value for ANTHROPIC_BASE_URL.

Step 7: check which model answered

Inside Claude Code, /status shows the Anthropic base URL line, which should read http://0.0.0.0:4000. That proves the route to the proxy only. Claude Code treats any gateway as the Claude API and cannot see which model sits behind it, and a proxy can serve Gemini under a Claude-style name.

Check the far end:

  • The proxy. The curl test in step 4 uses the same model name Claude Code sends. With a database configured, LiteLLM's UI at http://0.0.0.0:4000/ui shows usage by model.

  • Google. The Logs dashboard in AI Studio (aistudio.google.com/logs) lists GenerateContent calls for paid-tier projects that have logging on. On the OpenRouter route, use its Activity page.

What works and what does not on Gemini

Works: chat, reading and editing files, running commands and the agent loop, with tool calls translated by the gateway. The Gemini models in the table support function calling. LiteLLM can serve Claude and Gemini models from one proxy.

Does not work, or works differently:

  • No vendor supports it. Anthropic's gateway docs exclude non-Claude models, and a Claude Code release that adds a request field can break the translation.

  • Features tied to Anthropic are off. Remote Control, voice dictation, server-managed settings and claude.ai connectors need a claude.ai login and Anthropic's endpoint. Fast mode is served only by Anthropic's own API.

  • The window is shared on Gemini 4. Google counts input and output against the same 1M tokens.

  • Caching follows Google's rules. Gemini models cache prompts in memory by default, with a 24-hour limit.

  • Thinking is billed as output. Google's output price includes thinking tokens, and the Gemini 4 Argon and Carbon prices double on 1 December 2026.

  • Some traffic still goes to Anthropic. Version checks and telemetry go outside the gateway unless you set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1. The WebFetch domain safety check calls api.anthropic.com either way.

What Google does with your prompts

The answer depends on how you pay and which Google service the gateway calls. The Gemini app and Workspace are in our guide Is Gemini safe for work?

Gemini API, free tier

Gemini API, paid tier

Vertex AI (Gemini Enterprise Agent Platform)

Used to improve Google's products

Yes. Human reviewers may read prompts and responses, disconnected from your account and key

No

No, not without your permission or instruction

Kept for abuse monitoring

55 days

55 days. Flagged content may be reviewed by authorised Google staff

Flagged prompts up to 90 days, only for customers on the online Terms of Service. Gemini 4 Carbon: prompts and responses up to 30 days, stored in your environment

Your own request logs

Not available

On by default for projects created on or after 26 October 2026. Kept up to 55 days; you can choose 7, 14 or 28, or turn logging off

Request-response logging is off by default

Caching

In memory, 24-hour limit

In memory, 24-hour limit

In memory, plus durable caching at rest for up to 24 hours on supported models. Both can be turned off per project

Zero data retention

No

Not guaranteed. Google says to use Vertex AI if you need it

Possible, under the conditions on Google's zero data retention page

Where it is processed

Not stated in the unpaid terms

Logs may be stored or cached in any country where Google or its agents have facilities

The region you select; the global endpoint can serve from any region

For users in the UK, the EEA and Switzerland, Google applies the paid-tier data terms to the free tier as well. Google's Additional Terms were last changed on 23 March 2026; the Vertex page was updated on 12 November 2026.

Settings to change before you open a private repository:

  1. Use a project with billing enabled, so the paid terms apply.

  2. In AI Studio, open the Logs dashboard settings and turn generateContent logging off, or shorten retention, if you do not want stored copies.

  3. Do not share log datasets with Google. Shared datasets fall under the free-tier terms and may be used for training.

  4. If you need zero retention, call Gemini through Vertex AI and turn off durable caching for the project.

The gateway adds its own hop. LiteLLM, Claude Code Router and Bifrost run on your machine and call Google with your key. OpenRouter is a second company in the path, with its own settings: enforcing ZDR for Google models removes AI Studio endpoints, and Vertex endpoints stay only if you allow Safety Retention.

The same setup for a team: Gemini as an approved provider

A proxy on each laptop leaves a security lead with little to audit. The provider key sits in a shell profile, any developer can point the proxy at a personal free-tier key, and no rule keeps a sensitive repository away from Google.

Aventail™ Connect configures Claude Code to send model requests through Aventail™ Link, the inference engine and gateway on each machine. Routing rules are set once in Aventail™ Control and evaluated on the device. Google Gemini is a provider option in Control's API key vault, and Aventail™ states that it supports Gemini 4 Argon and Carbon. The key belongs to your organisation's own Google project, so one set of Google terms applies to every developer.

  1. Install Link on each developer machine and choose Connect next to Claude in Connected apps. Claude Code uses that connection, with no endpoint or key to enter.

  2. Add the Gemini key to the API key vault (Fleet Admin or Super Admin) and select a model the key can use.

  3. Tag the machines. Rules match devices, so machines that work on sensitive repositories get their own tag and policy.

  4. Write two policies. Sensitive machines permit only On device and serve a local model with at least 64K context. Other machines route to the Gemini connection, or use On device first with Gemini as a fallback hop.

  5. Check Requests in Control after a harmless prompt. A model label does not show the destination. If no destination is permitted, the request fails with an error.

Routing to hosted providers is in beta. The hosted Control service receives device and routing events, and does not receive prompts or responses. The Gemini connection uses an API key from your own Google account.

Which path to take

Claude Code + Gemini through your own gateway

Claude Code with Aventail™ Connect

Who it suits

One developer testing Gemini in Claude Code

A team with an approved Google account and some repositories that must stay local

Setup

A proxy, a config file and two environment variables

Connect button in Link, rules in Control

Where the Gemini key lives

A shell profile or the proxy's config

Control's API key vault

Where prompts go

Wherever the proxy config says

Where the routing rule says, evaluated on the device

Local models for sensitive work

Only if you add them to the proxy yourself

A local-only policy for tagged machines

Record of requests

The proxy's logs, if you set them up

Requests in Control

Cost

Google's token prices

Free for three devices; Starter is £50 a month excluding VAT with ten devices; Google's charges on your own account

Frequently asked questions

Can Claude Code use Gemini models?
Yes, through a gateway that translates Anthropic's Messages format to Gemini's. LiteLLM, OpenRouter, Claude Code Router and Bifrost all do this. Claude Code has no built-in Gemini setting.

Does Google offer an Anthropic-compatible endpoint for Gemini?
Not in the Gemini API docs read on 15 November 2026. Google documents its own API and an OpenAI-compatible endpoint at https://generativelanguage.googleapis.com/v1beta/openai/. Claude Code cannot use either without translation.

Does Anthropic support Claude Code with Gemini?
No. Anthropic's gateway docs say it does not support routing Claude Code to non-Claude models through any gateway, and that it does not endorse, maintain or audit third-party gateway products.

Which Gemini model should I use with Claude Code?
One with function calling. Google describes Gemini 4 Carbon as its strongest reasoning model for software engineering, Argon as the faster and cheaper-per-turn Gemini 4 model, and Hydrogen as the model for everyday coding and agentic work. Test tool calls on a real edit before you settle.

Is Claude Code with Gemini free?
Claude Code and LiteLLM cost nothing to install. Gemini 4 Hydrogen and Gemini 3.8 Flash have a free tier with rate limits, and on that tier Google uses your content to improve its products. Gemini 4 Argon and Carbon are paid only.

Can I use my Google Cloud account for this?
Yes, through the gateway. LiteLLM's Vertex AI config takes a service account, a project and a location. Claude Code's own CLAUDE_CODE_USE_VERTEX setting is for Claude models.

Is my code used to train Gemini?
On the paid tier of the Gemini API and on Vertex AI, Google states it does not use prompts or responses to improve its products. On the free tier it does, except for users in the UK, the EEA and Switzerland.

Sources

  1. Anthropic, Other LLM gateways: https://code.claude.com/docs/en/llm-gateway

  2. Anthropic, Connect Claude Code to an LLM gateway: https://code.claude.com/docs/en/llm-gateway-connect

  3. Anthropic, Gateway compatibility guide: https://code.claude.com/docs/en/llm-gateway-protocol

  4. Anthropic, Model configuration: https://code.claude.com/docs/en/model-config

  5. Anthropic, Environment variables: https://code.claude.com/docs/en/env-vars

  6. Anthropic, Feature availability: https://code.claude.com/docs/en/feature-availability

  7. Anthropic, Claude Code on Google Cloud's Agent Platform: https://code.claude.com/docs/en/google-vertex-ai

  8. Google, Gemini API documentation index: https://aistudio.google.com/llms.txt (ai.google.dev/gemini-api/docs redirects here)

  9. Google, OpenAI compatibility: https://aistudio.google.com/docs/openai

  10. Google, API keys: https://aistudio.google.com/docs/api-key, Billing: https://aistudio.google.com/docs/billing and Coding agent setup: https://aistudio.google.com/docs/coding-agents

  11. Google, Models: https://aistudio.google.com/docs/models and model pages for gemini-4-argon and gemini-3.8-flash

  12. Google, Gemini Developer API pricing: https://aistudio.google.com/docs/pricing

  13. Google, Gemini API Additional Terms of Service (effective 23 March 2026): https://aistudio.google.com/docs/terms

  14. Google, Zero data retention in the Gemini Developer API: https://aistudio.google.com/docs/zdr

  15. Google, Abuse monitoring: https://aistudio.google.com/docs/usage-policies

  16. Google, Logs and datasets: https://aistudio.google.com/docs/logs-datasets and Data logging and sharing: https://aistudio.google.com/docs/logs-policy

  17. Google Cloud, Gemini Enterprise Agent Platform and zero data retention (updated 12 November 2026): https://docs.cloud.google.com/gemini-enterprise-agent-platform/resources/zero-data-retention

  18. Google Cloud, Abuse monitoring: https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/abuse-monitoring

  19. LiteLLM, Use Claude Code with non-Anthropic models (updated 14 November 2026): https://docs.litellm.ai/docs/tutorials/claude_non_anthropic_models

  20. OpenRouter, Claude Code integration: https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration

  21. OpenRouter, Zero data retention: https://openrouter.ai/docs/guides/features/zdr

  22. OpenRouter, model list API: https://openrouter.ai/api/v1/models

  23. Claude Code Router, README: https://github.com/musistudio/claude-code-router

  24. Bifrost, Use Claude Code with Gemini models: https://getbifrost.ai/guides/claude-code/use-claude-code-with-gemini-models

  25. gemini-for-claude-code (archived): https://github.com/coffeegrind123/gemini-for-claude-code

  26. Aventail™, Connect overview: https://docs.aventail.co.uk/docs/connect/overview

  27. Aventail™, Routing: https://docs.aventail.co.uk/docs/fleet/routing

  28. Aventail™, Gemini 4 Argon vs Carbon: https://aventail.co.uk/guides/gemini-4-argon-vs-carbon

  29. Aventail™, Pricing: https://aventail.co.uk/#pricing

All sources were read on 15 November 2026.

We use optional cookies and tracking to identify visiting companies, load our contact form, measure Google Ads download clicks and understand page use with PostHog on our homepage, Connect and How it works pages, Ollama and LM Studio comparison guides and campaign pages. Cookie policy