Which Claude model ids work with Claude Code and the Anthropic SDK
Use the right Claude model id, base URL and auth variable with Claude Code and the Anthropic SDK on AICredits, and fix a model error or a 404 on /v1/messages.
Use this page with an AI assistant
Opens a new chat with this docs URL and the correct AICredits base URLs.
Most Claude Code and Anthropic SDK problems come from three settings: the model id, the base URL and the auth variable. This page lists what to use and how to fix the common errors.
1. Model id: copy it from the models page
Use the id shown on the models page. For Claude models it looks like anthropic/<name>:
| Model | Id |
|---|---|
| Opus | anthropic/claude-opus-5.5 |
| Sonnet | anthropic/claude-sonnet-5.5 |
| Haiku | anthropic/claude-haiku-5.5 |
The short name without the prefix, for example claude-sonnet-5.5, is also accepted for well-known Claude names. The anthropic/ form is the safe one, because it never depends on guessing.
Only ids that exist in the catalog work. An id taken from Anthropic's own docs or from an older tutorial may not be in the catalog. If an id is not available, the gateway answers 404. To see the current list from your own key:
curl https://api.aicredits.in/v1/models \
-H "Authorization: Bearer sk-your-key-here"Model ids can also be redirected by the platform (for example a renamed model can keep working under its old id), but do not rely on that. Use the id on the models page.
2. Base URL: no /v1 for the Anthropic SDK
| Client | Base URL |
|---|---|
| Claude Code and the Anthropic SDK | https://api.aicredits.in |
OpenAI SDK, LangChain, curl to /v1/chat/completions | https://api.aicredits.in/v1 |
The Anthropic SDK adds /v1/messages itself. If you also write /v1, the request goes to /v1/v1/messages and returns 404.
3. Auth: ANTHROPIC_AUTH_TOKEN
With a custom base URL, put your AICredits key in ANTHROPIC_AUTH_TOKEN. Do not also set ANTHROPIC_API_KEY: Claude Code can then send requests twice. A working ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.aicredits.in",
"ANTHROPIC_AUTH_TOKEN": "sk-your-aicredits-key-here",
"ANTHROPIC_MODEL": "anthropic/claude-sonnet-5.5"
}
}Open a new terminal after changing environment variables. The full setup is in the Claude Code guide.
Test outside Claude Code first
If something fails, test with curl. This isolates the key, the URL and the model from Claude Code itself:
curl https://api.aicredits.in/v1/messages \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-sonnet-5.5", "max_tokens": 64,
"messages": [{"role": "user", "content": "Say hi"}]}'The same call with the Anthropic Python SDK:
import anthropic
client = anthropic.Anthropic(
base_url="https://api.aicredits.in", # no /v1
auth_token="sk-your-key-here",
)
reply = client.messages.create(
model="anthropic/claude-sonnet-5.5",
max_tokens=64,
messages=[{"role": "user", "content": "Say hi"}],
)
print(reply.content[0].text)Errors and fixes
404 on /v1/messages, "Model '...' is not available"
The model id is not in the catalog, or is not offered right now. A wrong base URL with an extra /v1 also gives a 404 (see section 2). Fix: use an id from the models page, with the anthropic/ prefix.
"There's an issue with the selected model" in Claude Code
This message is shown by Claude Code, not by AICredits. Check the model first: run the curl above with the exact id from your ANTHROPIC_MODEL (or from the /model choice in Claude Code). If curl returns 404, change the id to one from the models page. If curl works, restart Claude Code in a new terminal so it reads the current settings.
401 or 402 See 401: Invalid API key and 402: Insufficient balance.
Errors on /v1/messages use Anthropic's error format, so the SDK and Claude Code can read them. The status codes are the same as everywhere else. See Error handling.