Authentication
How to authenticate Claude API requests. Set up your API key, configure headers, and secure your integration.
Key prefix: sk-cs4-*. Anthropic header: x-api-key: sk-cs4-.... OpenAI header: Authorization: Bearer sk-cs4-.... Base URL: https://api.llmsrelay.com. Rotation: Anytime from dashboard, no downtime.
API Key Format
For the new gateway, LLMsRelay issues one API key family:
sk-cs4-…— keys forapi.llmsrelay.com. Use them with Anthropic-compatible clients (Claude Code, Anthropic SDK, Continue, OpenCode) and OpenAI-compatible clients (Cursor, Cline, Roo Code, OpenAI SDK).
Keep the key secret — never expose it in client-side code or public repositories.
Authentication Methods
The gateway supports two authentication shapes, depending on which API format you call:
Anthropic Format
Pass your API key in the x-api-key header along with the required anthropic-version header:
curl https://api.llmsrelay.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "claude-sonnet-4.6", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'OpenAI-Compatible Format
Pass your API key as a Bearer token in the Authorization header:
curl https://api.llmsrelay.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{"model": "claude-sonnet-4.6", "messages": [{"role": "user", "content": "Hello"}]}'Claude Code CLI / Extension
The Claude Code CLI and VS Code extension authenticate via the ANTHROPIC_API_KEY environment variable. Use ANTHROPIC_API_KEY only — ANTHROPIC_AUTH_TOKEN is reserved for Anthropic's OAuth login (Claude Pro/Max) and will not authenticate against this gateway.
export ANTHROPIC_BASE_URL="https://api.llmsrelay.com"
export ANTHROPIC_API_KEY="YOUR_SK_CS4_KEY"Per-Key Controls
Each API key can be configured with the following enforced controls in the dashboard:
| Setting | Description |
|---|---|
| Rate limit | Max requests per minute for this key |
| Allowed models | Restrict key to specific models (e.g. only claude-sonnet-4) |
| Monthly credit cap | Hard cap on credits this key can spend within a UTC calendar month |
| Revocation | Instantly disable a compromised key without affecting others |
SDK Configuration
Verify your setup
Validate gateway access
Before sending real requests, run two cheap checks: a health probe and a models list. They confirm the base URL, your network, and (for /v1/models) your API key — without spending any credits.
1. Liveness probe — /healthz
Public, unauthenticated. Returns 200 and a JSON status payload when the gateway is up. Use it from CI, monitoring, or any shell.
curl -sS -o /dev/null -w "HTTP %{http_code}\n" \
https://api.llmsrelay.com/healthz2. Auth + catalogue — /v1/models
Returns the list of model IDs you can use with the messages API. Requires a valid x-api-key. If this works, your key, base URL, and headers are all correct.
curl -sS https://api.llmsrelay.com/v1/models \
-H "x-api-key: $ANTHROPIC_API_KEY" | jq '.data[].id'What a healthy response looks like
- /healthz → HTTP 200 with {"status":"ok", ...}. Anything else (timeout, 5xx, HTML page) means you hit the wrong host or there is a network/proxy issue.
- /v1/models → HTTP 200 with {"object":"list","data":[...]}. The data array contains the only model IDs accepted by /v1/messages.
Common mistakes
- Wrong base URL. The only correct host is https://api.llmsrelay.com. Do not use api.anthropic.com, api.llmsrelay.com (old) or any other variant.
- Missing /v1 prefix. Endpoints live under /v1/* (e.g. /v1/messages, /v1/models). /healthz is the one exception — it is at the root.
- Wrong auth header. Use x-api-key: sk-cs4-... (Anthropic-style). Do not send Authorization: Bearer ... unless the SDK builds it for you.
- Invalid model ID. Only IDs returned by /v1/models work. The public catalogue includes claude-opus-5, claude-fable-5, claude-opus-4.8, claude-opus-4.7, claude-opus-4.6, claude-sonnet-5, claude-sonnet-4.6, and claude-haiku-4.5, subject to key filtering.
Tip: use /v1/models as the source of truth for model IDs in your scripts and CI — never hard-code a list.