Claude API Proxy
Use Claude models with Claude Code, the Anthropic SDK, or any OpenAI-compatible tool.
BASE URL
https://api.apivai.comAPIVAI exposes Claude models in two formats. Pick the one your tool expects — mixing them up is the most common cause of 404 errors.
| Format | Base URL | Endpoint | Auth header | Used by |
|---|---|---|---|---|
| Anthropic-native | https://api.apivai.com | /v1/messages | x-api-key | Claude Code, Anthropic SDK |
| OpenAI-compatible | https://api.apivai.com/v1 | /chat/completions | Authorization: Bearer | Cursor, Cline, Aider, OpenAI SDK |
The Anthropic SDK and Claude Code append /v1/messages themselves, so their base URL must not end with /v1. OpenAI-style tools need /v1 exactly once.
Claude Code
macOS / Linux
export ANTHROPIC_BASE_URL="https://api.apivai.com"
export ANTHROPIC_AUTH_TOKEN="YOUR_APIVAI_API_KEY"
claude
Windows PowerShell
$env:ANTHROPIC_BASE_URL="https://api.apivai.com"
$env:ANTHROPIC_AUTH_TOKEN="YOUR_APIVAI_API_KEY"
claude
Start with a short prompt to confirm routing before running a long agent session.
Anthropic SDK
Python
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_APIVAI_API_KEY",
base_url="https://api.apivai.com",
)
message = client.messages.create(
model="YOUR_MODEL_NAME",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)
Node.js
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.APIVAI_API_KEY,
baseURL: "https://api.apivai.com",
});
const message = await client.messages.create({
model: "YOUR_MODEL_NAME",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello!" }],
});
// message.content is an array of content blocks
console.log(message.content.map((b) => (b.type === "text" ? b.text : "")).join(""));
cURL (Messages API)
curl https://api.apivai.com/v1/messages \
-H "x-api-key: YOUR_APIVAI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_NAME",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'
Add "stream": true to the body to receive the response as server-sent events.
Claude through the OpenAI format
Tools that only accept an OpenAI-style provider can still use Claude models — point them at the /v1 base URL and pass a Claude model ID.
curl https://api.apivai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_APIVAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_NAME",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Common errors
| Error | Usual cause |
|---|---|
| 401 | The key is missing, malformed, or not visible to the process that launched the tool. |
| 404 | The base URL has /v1 where it should not, is missing it, or has it twice. |
| model_not_found | The configured model is not in your current GET /v1/models response. |