Claude Code API Key Setup: Match Your Billing Key, Base URL and Model
For Claude Code with LLMAPI, use the Anthropic base URL https://llmapi.pro without /v1, set ANTHROPIC_AUTH_TOKEN to the matching LLMAPI key, and select an exact model ID supported by your billing mode and protocol. The most important billing distinction: adding API credit does not increase subscription quota. Pay-as-you-go API billing uses a separate key and balance.
This guide covers configuring an existing Claude Code installation for LLMAPI, not obtaining a direct Anthropic account or installing the CLI. LLMAPI is an independent API relay; its catalog and account access should not be treated as official Anthropic specifications. Keep the Claude Code setup guide and model-selection guide available while checking your configuration.
1. Match the key to the service and billing mode
Before changing terminal settings, check which service issued the key and which billing mode it belongs to. For this LLMAPI configuration, select the matching key type in the Console. Do not treat a subscription key and an API billing key as interchangeable.
| Billing mode | Key and usage source | What to check |
|---|---|---|
| Monthly subscription | Subscription key; supported models share the plan quota | The exact model is in the subscription model list |
| Pay-as-you-go API | Separate API billing key and balance | The selected channel's model, pricing and supported protocols |
If you topped up API credit but Claude Code is still configured with a subscription key, the top-up has not increased that subscription's quota. To use pay-as-you-go billing, configure the API billing key and choose a model and channel supported for that mode.
Use the current subscription page for plan details and the model-selection guide for billing-mode selection. A model appearing somewhere in LLMAPI's catalog is not, by itself, confirmation that your subscription includes it.
2. Set the Anthropic base URL, not a request endpoint
Claude Code uses the Anthropic protocol. For LLMAPI, its base URL is:
https://llmapi.pro
These addresses have different purposes:
| Purpose | LLMAPI URL |
|---|---|
| Claude Code base URL | https://llmapi.pro |
| OpenAI-compatible client base URL | https://llmapi.pro/v1 |
| Direct Anthropic HTTP request endpoint | https://llmapi.pro/v1/messages |
Do not copy the OpenAI-compatible address or the complete HTTP endpoint into Claude Code's base URL setting. A client builds its request path from its protocol configuration; a direct HTTP request uses the complete endpoint. The integration directory lists the addresses for other clients if you are configuring more than one application.
3. Configure the terminal with the matching key
The documented LLMAPI configuration uses ANTHROPIC_AUTH_TOKEN. Replace YOUR_API_KEY locally with the key selected for your billing mode, then launch Claude Code from that terminal. These are configuration examples, not proof that a particular account has access.
macOS or Linux
export ANTHROPIC_BASE_URL="https://llmapi.pro"
export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
claude
Windows PowerShell
$env:ANTHROPIC_BASE_URL="https://llmapi.pro"
$env:ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
claude
Windows CMD
set ANTHROPIC_BASE_URL=https://llmapi.pro
set ANTHROPIC_AUTH_TOKEN=YOUR_API_KEY
claude
For persistent settings, the Claude Code guide documents adding the variables to ~/.zshrc or ~/.bashrc on macOS/Linux, or using setx on Windows. Confirm the service, billing key and URL before making a configuration persistent.
4. Choose an exact model ID for your account
Model identity, protocol compatibility and billing mode are separate checks. Copy the request ID rather than a display name from the subscription model list or pay-as-you-go channel catalog, and confirm Anthropic-protocol support for your selection.
For example, the LLMAPI Claude Code guide documents this command:
claude --model claude-opus-5
This is a documented selection example, not a guarantee of availability for every account or billing channel. Use the exact ID appropriate to your own access. The model-selection guide explains which list to consult; subscription availability is synchronized with GET /v1/models.
The client menu is not the same as LLMAPI's catalog. The Claude Code guide documents that a custom model such as claude-fable-5 may not appear in the built-in /model menu and can instead be selected with claude --model claude-fable-5. Do not interpret menu visibility alone as an account-access check.
5. Use the setup tool for URL formatting only
The API base URL checker and settings generator lets you select Claude Code, check the LLMAPI URL format and copy terminal settings without signing up or entering a key. Substitute your key only in your own client.
The check runs locally in your browser and makes no API request. Its scope is URL formatting: it cannot validate a key, confirm account permissions or establish that a model is available. A successful format check therefore does not prove that Claude Code can authenticate or that your billing mode has capacity.
Use the tool to review the address, then separately check the key's issuing service, billing mode and selected model.
6. Diagnose the configuration before retrying
Use the failure category to decide which setting to inspect rather than repeatedly changing everything:
- Authentication failure or 401: review whether the configured token is an active key from the service at your base URL. Passing the URL-format check does not answer that question.
- Path error or 404: compare the Claude Code base URL with the table above, especially whether you pasted an address containing
/v1. - Access or capacity error, including 403/429: review account access, quota and concurrency. If you recently added API credit, recheck whether the terminal still uses a subscription key. Avoid rapid repeated retries.
- Server error or 5xx: keep a timestamp and request ID for a later retry or a redacted support report.
For the full error reference, follow the troubleshooting links in the setup tool. Before another attempt, review four items together: issuing service, billing-key type, Anthropic base URL and exact model ID. Correcting only the address cannot resolve a mismatch in the other three.