Claude Code
Connect Claude Code to APIPool's Anthropic-compatible Messages API on macOS and Linux.
This guide connects Claude Code on macOS or Linux to APIPool through the
Anthropic-compatible Messages API. The base URL is https://app.apipool.dev;
Claude Code appends POST /v1/messages itself.
1. Install Claude Code
Skip this if claude --version already works:
npm install -g @anthropic-ai/claude-code
claude --version2. Prepare an API key
Create a key on the API key page whose group contains the target models, then set it in the shell that will start Claude Code:
export APIPOOL_API_KEY="YOUR_APIPOOL_API_KEY"This affects only the current terminal session. For persistent use, rely on an operating-system secret manager or another protected environment mechanism. Do not put a real key in project files, Claude configuration, command arguments, screenshots, or support messages.
3. Available model IDs
Use the complete model ID exactly as listed:
claude-fable-5-1claude-opus-5-5claude-fable-5claude-opus-5claude-sonnet-5claude-opus-4-8claude-opus-4-7claude-opus-4-6claude-sonnet-4-6claude-haiku-4-5-20251001
Access is controlled by the group you chose when creating the key; a model ID alone does not grant access to another group. Check the model list for availability in your group, then follow the connection steps below.
4. Run Claude Code
export ANTHROPIC_BASE_URL="https://app.apipool.dev"
export ANTHROPIC_AUTH_TOKEN="$APIPOOL_API_KEY"
claude --model "claude-sonnet-5"To switch models, change the --model value.
Do not add /v1 or /v1/messages to ANTHROPIC_BASE_URL. Claude Code builds
the request URL as https://app.apipool.dev/v1/messages.
If you previously set an ANTHROPIC_BASE_URL or authentication variable
pointing at another provider, remove or update it first — otherwise Claude Code
may keep using the old endpoint.
5. Confirm the connection
The signal is a usable model reply, not merely an HTTP success — a protocol success can still be a refusal. Send a short, deterministic request:
claude --model "claude-sonnet-5" -p "Reply with exactly: APIPOOL-OK"APIPOOL-OK means you are connected. The charge for this request then shows up
on the usage page.
Troubleshooting
| Symptom | What to check |
|---|---|
claude command not found | Run which -a claude; if needed, inspect npm prefix -g, fix PATH, and retry claude --version. |
401 | Confirm ANTHROPIC_AUTH_TOKEN is set in the current shell and that the key is active. |
403 or model not found | Confirm the complete model ID appears in the model list and is available to the key's group. |
| Route or HTML response | Use exactly https://app.apipool.dev as ANTHROPIC_BASE_URL; do not append /v1/messages. |
| Claude uses another provider | Check for a saved ANTHROPIC_BASE_URL or authentication variable pointing somewhere else. |
| HTTP success but no useful answer | Inspect the stop reason and response content; a protocol success can still be a refusal. |
| Usage or charge differs | Stop sending paid requests, then keep the request IDs and usage records and contact us. |
Ruling out local configuration
When you suspect saved MCP servers, project rules, skills, hooks, or permission configuration are affecting the result, reproduce it with an isolated minimal request:
ANTHROPIC_BASE_URL="https://app.apipool.dev" \
ANTHROPIC_AUTH_TOKEN="$APIPOOL_API_KEY" \
claude --setting-sources '' --strict-mcp-config --tools "" \
--safe-mode --no-session-persistence --permission-mode plan \
--model "claude-sonnet-5" -p "Reply with exactly: APIPOOL-OK"These diagnostic flags temporarily ignore saved MCP servers and customizations. If this command succeeds while your everyday command fails, check your local settings one at a time. Restore your usual settings for everyday use.
Telling Claude Code apart from APIPool
The curl example below only applies to groups that support generic API clients. For Claude Code-only groups, use the real Claude Code command above. A plain curl request can be rejected even when it uses /v1/messages.
claude_code_client_required means the group requires Claude Code; it does not mean your API key is invalid. Use Claude Code or switch to a group that supports your client.
For groups supporting generic clients, a minimal Messages request with the same key can help distinguish API issues from client configuration issues:
curl -sS https://app.apipool.dev/v1/messages \
-H "x-api-key: $APIPOOL_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-5","max_tokens":16,"messages":[{"role":"user","content":"Reply exactly: APIPOOL-OK"}]}'