# 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.

Pick a Gemini model inside Claude Code

**Slug**: `gemini-in-claude-code`  
**URL**: https://anyrouter.dev/use-cases/gemini-in-claude-code  
**Markdown**: https://anyrouter.dev/use-cases/gemini-in-claude-code.md  
**Short link**: https://anyrouter.dev/u/gemini-in-claude-code  
**Other short links**: https://anyrouter.dev/u/gemini  

## Why use this

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.

## Set it up

1. Create a key in Google AI Studio, then add it under Dashboard → BYOK → Google AI Studio.
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. Prefer plain env vars? Point ANTHROPIC_BASE_URL at https://anyrouter.dev/api and pass the same model to claude.

## Code

### anyr CLI

```bash
curl -fsSL https://anyr.dev/cli.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-pro"
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.

## Related

- [claude-code](https://anyrouter.dev/use-cases/claude-code)
- [claude-code-multiple-keys](https://anyrouter.dev/use-cases/claude-code-multiple-keys)
- [byok](https://anyrouter.dev/use-cases/byok)
