Skip to main content

Use AnyAPI in Claude Code

Claude Code is Anthropic’s official terminal-native AI coding agent. It lets you delegate complex coding tasks — file edits, multi-step refactors, test generation, and more — directly from your terminal.
AnyAPI works with Claude Code via the Anthropic Messages API (/v1/messages). No local proxy required.

Quick Start

1. Get your API key

Sign up at anyapi.ai and create an API key in the dashboard.

2. Install Claude Code

macOS / Linux / WSL:
Windows PowerShell:

3. Configure environment variables

Add these lines to your shell profile (~/.zshrc or ~/.bashrc):
Then reload your shell:
Important: ANTHROPIC_API_KEY must be set to an empty string "", not just unset. If it has any value, Claude Code will try to authenticate with Anthropic directly instead of using AnyAPI.
Note: Do not put these in a project-level .env file — Claude Code does not read standard .env files.

4. Clear any cached Anthropic login

If you previously logged in to Claude Code with an Anthropic account, run this inside Claude Code:
Then quit and relaunch claude.

5. Start Claude Code

6. Verify

Run /status inside Claude Code:

Model Format

AnyAPI uses the vendor/model format. Always include the vendor prefix:
Browse available models at anyapi.ai/ai-models or query the API:

Configuration Examples

DeepSeek:
Kimi K2:
Claude Sonnet (via Anthropic on AnyAPI):

Troubleshooting

403 RBAC: access denied

Your key doesn’t have access to the requested model, or the model name is wrong.
  1. Check your balance and plan at dash.anyapi.ai
  2. Verify the model name using the /v1/models endpoint above
  3. Make sure you’re using vendor/model format

Please run /login on startup

Claude Code is ignoring your environment variables.
  1. Make sure ANTHROPIC_API_KEY="" is explicitly set to empty string
  2. Run /logout inside Claude Code, then restart
  3. Confirm variables are in your shell profile, not a .env file

Auth conflict warnings / unexpected model-not-found errors

Usually caused by a cached Anthropic OAuth session conflicting with ANTHROPIC_AUTH_TOKEN.
  1. Run /logout inside Claude Code
  2. Quit and relaunch claude
  3. Verify with /status that the base URL shows https://api.anyapi.ai

Browser opens for login unexpectedly

ANTHROPIC_API_KEY is either unset or has a real value. Set it to an empty string:

Support

Next Steps

All Integrations

Browse all supported tools

Model Catalog

Browse 300+ available models