Skip to content
All use cases

Claude Code + Gemini

Gemini models in Claude Code

Claude Code talks to the Messages API, and AnyRouter translates it for any catalog model. Save a Google key, then choose a Gemini model with --model.

What this is for

You like Claude Code's loop but want to try Gemini on the same repo, without switching to another tool or editing its config by hand.

How the request flows

Claude CodeMessages API
AnyRoutertranslates
Geminiyour Google key

Steps, then copy

  1. 1.Create a key in Google AI Studio, then add it under Dashboard → BYOK → Google AI Studio.
  2. 2.Install the anyr CLI and run anyr claude with a Gemini model. A concrete --model also sets Claude Code's haiku, sonnet, opus and subagent models, so background tasks use Gemini too.
  3. 3.Prefer plain env vars? Point ANTHROPIC_BASE_URL at https://anyrouter.dev/api and pass the same model to claude.
anyr CLI
bash
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr claude --model google/gemini-2.5-pro
Env wrapper
bash
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="$ANYROUTER_API_KEY"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="google/gemini-2.5-flash"
claude --model google/gemini-2.5-pro

Limits

  • Gemini routes run on keys you add, so Google's limits and billing apply to your account.
  • Claude Code is built around Claude. Gemini models vary in how well they handle tool calls and long edits.
  • With plain env vars, set ANTHROPIC_DEFAULT_HAIKU_MODEL too, or Claude Code's small background tasks still call a Claude model.
  • Features that exist only on Anthropic's API, such as its prompt cache, do not apply on a Gemini route.

Ready to try it

The guide has the full walkthrough. Sign up if you still need a key.