×

Use Gemini with Claude Code

$2/Mtok in

Claude Code's agent loop with Gemini's million-token context: point the harness at a model that can hold your whole repo in one window. The messages translation layer makes non-Anthropic models a --model flag, not a different tool.

Facts

At a glance

Model

Gemini 3.1 Pro (preview)

google/gemini-3-1-pro-preview

Price

$2 / M input · $12 / M output

Context window

1,048.576k tokens

Tool

Claude Code

Setup below, under two minutes

Quickstart

Set up Gemini in Claude Code

  1. 1

    Point Claude Code at CompanyFabric. Claude Code reads the ANTHROPIC_* variables, the value is your CompanyFabric key (sk-cf-…), no Anthropic account needed:

    export COMPANYFABRIC_API_KEY="sk-cf-…"
    export ANTHROPIC_BASE_URL="https://api.companyfabric.com"
    export ANTHROPIC_API_KEY="$COMPANYFABRIC_API_KEY"
  2. 2

    Start a session on this model:

    claude --model google/gemini-3-1-pro-preview
  3. 3

    Every turn's exact cost lands in your dashboard usage feed, set a per-key budget cap if the agent runs unattended.

Full tool guide: Use any model with Claude Code

FAQ

Frequently asked questions

Do I need a Google account to use Gemini in Claude Code?

No, one CompanyFabric key covers Gemini 3.1 Pro (preview) and every other model in the library. Billing is one prepaid balance with exact per-call metering; BYOK at 0% is available if you already have provider keys.

What does Gemini 3.1 Pro (preview) cost in Claude Code?

$2 / M input · $12 / M output, the same metered price as any other route to the model. Set a per-key budget cap to bound what the tool can spend.

Can I switch models later without touching Claude Code again?

Yes, the endpoint stays the same; the model is a string. Any catalog id works in the same configuration, including cheaper tiers for bulk work.

Why run Gemini inside Claude Code instead of Gemini CLI?

Harness maturity, if your team already lives in Claude Code (hooks, MCP servers, workflows), switching the brain is one flag; switching the harness is a migration.

Explore

Related setups

One key. Every model. Exact prices.

Run Gemini in Claude Code with free starter credits. Free starter credits included, no subscription required.