Skip to main content
Anthropic’s Claude Code is an agentic AI coding assistant that runs in your terminal. By setting the ANTHROPIC_BASE_URL environment variable, you can route all Claude Code requests through Flatkey and pay Flatkey’s discounted rates on Claude model usage.

Prerequisites

  • Claude Code installed: npm install -g @anthropic-ai/claude-code
  • A Flatkey account with an API key — get one here

Configuration

Set these two environment variables:
To make the setting permanent, add them to your shell profile:
~/.zshrc
Set ANTHROPIC_BASE_URL to https://router.flatkey.ai — without a trailing /v1. The Claude Code CLI appends the correct path automatically.

Configure with CC Switch

CC Switch is a third-party desktop configuration manager for coding assistants. You can also download it from the official GitHub repository.
  1. Open CC Switch and select Claude Code.
  2. Add a Custom Provider named Flatkey.
  3. Set the base URL to https://router.flatkey.ai without a trailing /v1.
  4. Enter your Flatkey API key (sk-fk-...) and activate the provider.
  5. Fully quit and reopen Claude Code so it reloads the provider settings.
  6. Send a small request, then confirm it in Usage Logs in the Flatkey Console.
If your CC Switch version does not include a Flatkey preset, use Custom Provider. CC Switch is not a Flatkey product.

Running Claude Code

Use Claude Code exactly as you normally would:
or interactively:
All requests are routed to Flatkey and billed from your prepaid balance at discounted rates.

Verifying the setup

Run a simple request and then check Usage Logs in your Flatkey Console. You should see the Claude request logged with its model ID, token counts, and cost.

Savings estimate

Using Claude Sonnet (a popular choice for Claude Code) through Flatkey: On a typical Claude Code session of 50K input tokens, using Sonnet, that is:
  • Official: ~$0.15 per session
  • Flatkey: ~$0.08 per session
Heavy Claude Code users benefit most from the $200 top-up tier — the bonus credit effectively gives you an extra month of usage on top of the model discount.

Troubleshooting