Use a custom endpoint with the OpenAI and Anthropic SDKs

Both official SDKs accept a base URL argument. That means switching billing routes is a one-line change — your request and response code stays exactly as it is.

Don't have an account yet? You need an API key from the gateway before the steps below will work. Create one free → (no prepay, $1 minimum top-up)
Check current rates → Free to sign up · $1 minimum top-up · No prepayment
Quick self-check. Before wiring anything into your app, confirm the key works. This lists every model your account can call — it costs nothing and works from any machine:
curl https://aicomp.ai/v1/models \
  -H "Authorization: Bearer sk-your-gateway-key"

You should get back a JSON list of model IDs. If you see Invalid token, the key is wrong or was not copied in full.

Python — OpenAI SDK

from openai import OpenAI

client = OpenAI(
    base_url="https://aicomp.ai/v1",
    api_key="sk-your-gateway-key",   # not your OpenAI key
)

resp = client.chat.completions.create(
    model="gpt-5.6-luna",
    messages=[{"role": "user", "content": "say OK"}],
)
print(resp.choices[0].message.content)

Node — OpenAI SDK

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://aicomp.ai/v1",
  apiKey: "sk-your-gateway-key",
});

const r = await client.chat.completions.create({
  model: "gpt-5.6-luna",
  messages: [{ role: "user", content: "say OK" }],
});
console.log(r.choices[0].message.content);

Python — Anthropic SDK

import anthropic

client = anthropic.Anthropic(
    base_url="https://aicomp.ai/v1",
    api_key="sk-your-gateway-key",
)

msg = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=64,
    messages=[{"role": "user", "content": "say OK"}],
)
print(msg.content[0].text)

Plain curl

curl https://aicomp.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-gateway-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.6-luna",
       "messages":[{"role":"user","content":"say OK"}]}'

Gotchas that cost people an hour

Migrating an existing codebase

Because only the client constructor changes, the safest rollout is to read the base URL from config:

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1"),
    api_key=os.getenv("OPENAI_API_KEY"),
)

Then switching route is an environment change, not a deploy.

Next

Compare rates before you switch: all model prices, or run your volume through the cost calculator.

Get API access