Skip to main content

Use AnyAPI in Claude Code

Claude Code is Anthropic’s terminal-native AI coding agent — it edits files, runs commands, and handles multi-step refactors from your terminal. Claude Code speaks the Anthropic Messages API, and AnyAPI serves that API at https://api.anyapi.ai, so you can point it at AnyAPI with no local proxy.

Install Claude Code

macOS / Linux / WSL:
Windows PowerShell:

Get Your API Key

Go to API Keys in the AnyAPI Dashboard and create a new key.

Configure Claude Code

Run this in your terminal to write the AnyAPI settings into ~/.claude/settings.json. Replace sk-your-anyapi-key with your own key.
~/.claude/settings.json stores your key in plain text. The command above overwrites the file — if you already have settings there, add the env block by hand instead.

Start Claude Code

Check the connection inside Claude Code:
The base URL should read https://api.anyapi.ai.
AnyAPI uses provider/model format for model IDs. Bare names like claude-sonnet-4.6 without the vendor prefix won’t work.
Browse all models at anyapi.ai/ai-models, or list them from the API:

Troubleshooting

A cached Anthropic session takes priority over your settings. Run /logout inside Claude Code, quit, and relaunch claude.
Your key has no access to that model, or the model ID is wrong. Check your balance and plan at dash.anyapi.ai, and verify the ID against /v1/models.
Claude Code reads ~/.claude/settings.json, not a project .env file. Confirm the file is valid JSON — a trailing comma silently breaks it.

Next Steps

CC Switch

Switch models in Claude Code from a GUI

All Integrations

Browse all supported tools