Claude Code
Use Foza models with Claude Code CLI
Recommended: Console setup#
Connect Claude Code to the Foza gateway using the setup generator from your API key page.
Claude Code is best paired with Anthropic-compatible model slugs. In Foza, copy the exact model slug from Console -> Marketplace after subscribing your API key.
Open your API key
Go to Console -> API Keys, open the key you want Claude Code to use, and confirm it is Active.
Open the Claude Code tab
In the key detail page, select Claude Code.
Choose operating system
Select macOS / Linux or Windows. The generated command uses the right Claude Code settings path for your OS.
Assign models by workload
Choose Foza model slugs for Claude Code's workload buckets:
- Haiku for light tasks
- Sonnet for daily use
- Opus for hard tasks
This step is required for Foza because model names include the provider prefix, such as anthropic/claude-sonnet-4.6.
Create setup command
Click Create setup command, copy it, and run it in your terminal. The command writes the Foza base URL, API key reference, and exact model names into Claude Code settings.
The generated remove command removes only the Foza Claude Code configuration. It does not uninstall Claude Code.
Manual setup with settings.json#
Create or edit Claude Code settings
Because Foza model slugs include the upstream provider prefix, you should explicitly pin the model instead of relying on Claude Code's default model names.
For a team-shared project config, create .claude/settings.json:
{ "model": "anthropic/claude-sonnet-4.6", "env": { "ANTHROPIC_BASE_URL": "https://api.foza.ai/v1", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-4-5", "ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-4.6", "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-4-8", "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1" } }
Claude Code uses these workload model variables when it chooses a fast, daily-use, or hard-task model internally. Replace each value with the exact Foza model slug connected to your API key.
Then keep your API key outside the repository. For example, put it in ~/.claude/settings.json:
{ "env": { "ANTHROPIC_API_KEY": "sk-foza-xxxxx" } }
For a machine-specific project override, use .claude/settings.local.json instead. Claude Code treats that file as local-only.
Or set environment variables
export ANTHROPIC_BASE_URL=https://api.foza.ai/v1 export ANTHROPIC_API_KEY=sk-foza-xxxxx export ANTHROPIC_MODEL=anthropic/claude-sonnet-4.6 export ANTHROPIC_DEFAULT_HAIKU_MODEL=anthropic/claude-haiku-4-5 export ANTHROPIC_DEFAULT_SONNET_MODEL=anthropic/claude-sonnet-4.6 export ANTHROPIC_DEFAULT_OPUS_MODEL=anthropic/claude-opus-4-8 export CLAUDE_CODE_DISABLE_1M_CONTEXT=1
Add these to your ~/.bashrc or ~/.zshrc to persist them.
Confirm the current shell sees Foza
echo $ANTHROPIC_BASE_URL echo ${ANTHROPIC_API_KEY:0:12} claude --print "reply with the model you are using"
Run this in the same terminal where you will start claude.
Run Claude Code
cd /path/to/your/project claude
Claude Code will now route all requests through the Foza gateway.
First prompt#
Start with a read-only request:
Inspect this repository and summarize the architecture. Do not edit files yet.Then move to a small patch:
Find the smallest file related to API key display and suggest one improvement. Ask before editing.Troubleshooting#
| Symptom | What to check |
|---|---|
| Auth error | ANTHROPIC_API_KEY is your Foza key and is active |
| Endpoint error | ANTHROPIC_BASE_URL is exactly https://api.foza.ai/v1 |
| Model unavailable | model or ANTHROPIC_MODEL is the full Foza slug, e.g. anthropic/claude-sonnet-4.6 |
| Wrong workload model | Check ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_DEFAULT_OPUS_MODEL |
| Edits are too broad | Ask Claude Code to plan first and edit one file at a time |
You can also set these variables per-session by prefixing the command: ANTHROPIC_BASE_URL=https://api.foza.ai/v1 ANTHROPIC_API_KEY=sk-foza-xxxxx claude
Do not commit API keys in .claude/settings.json. Commit the shared model/base URL if useful, and keep the key in your user settings, local settings, shell profile, or secret manager.