Claude Code
Connect Claude Code to CodaAPI. Import with CC Switch in one click, or set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN yourself.
Claude Code is Anthropic's command-line coding assistant. It calls models through the Anthropic Messages endpoint (/v1/messages), which CodaAPI provides, so all you need to do is point Claude Code's address and key at CodaAPI.
Method 2 (manual setup) on this page has been tested on the CodaAPI gateway (Claude Code 2.1.299, November 2026). Importing with CC Switch, the VS Code extension and one troubleshooting tip haven't been tested yet and are marked where they appear. Settings may change when Claude Code updates, so the official documentation is authoritative.
Before you start:
- Install Claude Code. The officially recommended way: on macOS / Linux run
curl -fsSL https://claude.ai/install.sh | bash, and on Windows PowerShell runirm https://claude.ai/install.ps1 | iex. You can also usenpm install -g @anthropic-ai/claude-code(needs Node.js 22 or later). - A CodaAPI API key with Group set to
Claude Code(orClaude-AWS). To create one, see the Quickstart; for how the groups differ, see Groups. - Pick the Claude models to use. Anthropic doesn't support pointing Claude Code at non-Claude models through a gateway, so use Claude models such as
claude-sonnet-5-5,claude-opus-5-5andclaude-haiku-5-5. These three are in theClaude CodeandClaude-AWSgroups, not inClaude-官转; if your key is in another group, use Claude models from that group instead.
Setup
Pick either method.
Method 1: import with CC Switch
Not tested: the CC Switch steps follow its official repository and haven't been tested on CodaAPI yet.
CC Switch is an open-source desktop tool for managing the model providers of Claude Code, Codex and similar tools. The CodaAPI console can import a key into it directly:
- Install CC Switch (version 4.0.10 or later).
- In the console, open General → API Keys (open it directly) and click CC Switch in the menu of the key you want to use.
- In the Import to CC Switch dialog, set Application to Claude and choose a Claude model for Primary Model. You can set the Haiku Model, Sonnet Model and Opus Model separately; leave them empty to keep Claude Code's defaults.
- Click Open CC Switch. Your browser launches CC Switch. After you confirm the import, enable this provider in CC Switch.
The imported address is https://codaapi.com (Claude Code uses the root address without /v1). For installation, adding a provider by hand, switching and common problems, see the CC Switch page.
Method 2: set it manually
Claude Code reads the gateway address and key from environment variables. We recommend putting them in the env section of the user-level settings file ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json), so you don't have to set them every time you open a terminal:
{
"env": {
"ANTHROPIC_BASE_URL": "https://codaapi.com",
"ANTHROPIC_AUTH_TOKEN": "sk-your-key",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
}
}
What each setting means:
| Variable | What it does |
|---|---|
ANTHROPIC_BASE_URL |
The gateway address. Set it to https://codaapi.com without /v1 |
ANTHROPIC_AUTH_TOKEN |
The key, sent by Claude Code as Authorization: Bearer. You can use ANTHROPIC_API_KEY instead (sent as x-api-key). CodaAPI accepts both, so pick one |
ANTHROPIC_DEFAULT_SONNET_MODEL and the other two |
Optional. Set which model each of the sonnet, opus and haiku aliases maps to. The haiku one is also used for small background tasks |
ANTHROPIC_MODEL |
Optional. Sets the model for this session directly |
A few things to note:
- The settings file is strict JSON, so no comments and no trailing commas.
- Don't put the key in
.claude/settings.jsoninside a project directory. That file is usually committed to the repository. - To try it out temporarily, you can also run
export ANTHROPIC_BASE_URL=…andexport ANTHROPIC_AUTH_TOKEN=…in the terminal and then runclaude. If a terminal variable and the settings file are both present, the settings file wins.
Use it in an IDE
- Running
claudein the built-in terminal of VS Code or Cursor: it reads the same~/.claude/settings.json, so no extra setup is needed. - The Claude Code VS Code extension (which can also be installed in Cursor): the extension bundles Claude Code, so it works without the command-line tool, and it shares
~/.claude/settings.jsonwith the command line. Alternatively, enter the sameANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENas above in the VS Code settingclaudeCode.environmentVariables; use only one of the two methods. See VS Code extension for details. (Not tested) - The Claude desktop app doesn't read
ANTHROPIC_BASE_URLorsettings.json, so the configuration above has no effect on it.
Download IDEs and extensions only from official sources: Cursor's website is cursor.com, and for VS Code extensions, check the publisher in the extension marketplace.
Check that it works
- Run
claudeand type/status. The status page should have anAnthropic base URLline showinghttps://codaapi.com, and show that the key comes fromANTHROPIC_AUTH_TOKEN(orANTHROPIC_API_KEY). If it shows a claude.ai account login instead, the gateway settings weren't picked up. - Ask anything. If it answers normally, you're set. The matching request and charge appear in the console usage logs.
You can also bypass Claude Code and test the gateway and key directly with curl:
curl https://codaapi.com/v1/messages \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "claude-haiku-5-5", "max_tokens": 16, "messages": [{"role": "user", "content": "ping"}]}'
Common problems:
- Returns 401: the key is in the wrong variable, or the key itself is invalid. See Troubleshooting.
- Returns 400 with an error message that mentions
context_managementorExtra inputs are not permitted: the official Claude Code documentation's fix is to set the environment variableCLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, which turns off experimental beta features. (Not tested: it can only be verified when an upstream actually rejects beta parameters) - The token counts in
/contextare estimates: the gateway doesn't support thecount_tokensendpoint yet (see the native Claude API). The usage logs are authoritative for charges.
MCP and plugins
MCP (Model Context Protocol) servers run on your own computer. Claude Code starts and calls them to read local files, query databases and call other systems. Which gateway the model goes through is a separate matter: after you switch to CodaAPI, MCP setup and usage stay the same, so add servers as the official Claude Code documentation describes (for example with claude mcp add).
CodaAPI itself doesn't provide MCP servers and doesn't read or proxy your MCP traffic. What an MCP tool returns is sent to the model as part of the conversation and billed by tokens.