Disclosure: I run APIVAI, the gateway used in the examples below. The setup steps work the same way with any endpoint that speaks the Anthropic and OpenAI formats.
Most AI coding tools let you change the API base URL. That means you can point Claude Code, Cursor, Codex CLI, Cline and the official SDKs at a single gateway and manage one key and one balance instead of several.
Claude Code
Claude Code speaks the Anthropic Messages format. Set two environment variables:
export ANTHROPIC_BASE_URL="https://api.apivai.com"
export ANTHROPIC_AUTH_TOKEN="your-key"
claude
On Windows PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.apivai.com"
$env:ANTHROPIC_AUTH_TOKEN = "your-key"
claude
Cursor
Settings → Models → API Keys: turn on Override OpenAI Base URL, enter https://api.apivai.com/v1, paste your key, then add the model IDs you want (for example claude-sonnet-4-6).
OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(api_key="your-key", base_url="https://api.apivai.com/v1")
r = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)
Common errors
-
401: the key is wrong, or it was sent in the wrong header. Use
x-api-keyorAuthorization: Bearer. -
404: usually a
/v1mismatch. Anthropic-format tools use the root URL, OpenAI-format tools need/v1. - 429: the default limit is 60 requests per minute per key.
What it costs
At the time of writing, Claude models on APIVAI are 56–62% below Anthropic's list prices and GPT models up to 86% below OpenAI's. For example, Claude Sonnet 4.6 is $1.15 / $5.74 per million input / output tokens against the official $3 / $15. It's prepaid and pay-per-token, with no subscription. The full table is at https://apivai.com/pricing.
Setup guides for Cline, Roo Code, Aider, Continue, Open WebUI and others are on the blog: https://apivai.com/blog
Questions are welcome in the comments.
Top comments (0)