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:~/.zshrc
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.- Open CC Switch and select Claude Code.
- Add a Custom Provider named
Flatkey. - Set the base URL to
https://router.flatkey.aiwithout a trailing/v1. - Enter your Flatkey API key (
sk-fk-...) and activate the provider. - Fully quit and reopen Claude Code so it reloads the provider settings.
- 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: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