AIgateway speaks the OpenAI API verbatim — chat, embeddings, images, audio, moderations. Point the official OpenAI SDK at our base URL and every endpoint, every parameter, every streaming SSE shape works exactly the same.
aigateway-py/js for our aggregator primitives (sub-accounts, evals, replays, jobs, webhook verify). openai for chat — drop-in compat per our own SDK's guidance.
pip install aigateway-py openai # or pnpm add aigateway-js openai
Use the AIgateway endpoint and your AIgateway key. Nothing else changes for chat.
# pip install aigateway-py openai
from openai import OpenAI
client = OpenAI(
base_url="https://api.aigateway.sh/v1",
api_key="sk-aig-...",
)
resp = client.chat.completions.create(
model="anthropic/claude-opus-4.7", # or any of 100+ models
messages=[{"role": "user", "content": "hello"}],
stream=True,
)Same swap on the JS side.
// pnpm add aigateway-js openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.aigateway.sh/v1",
apiKey: process.env.AIGATEWAY_API_KEY,
});
const stream = await client.chat.completions.create({
model: "moonshot/kimi-k2.6",
messages: [{ role: "user", content: "hello" }],
stream: true,
});Sub-accounts, evals, replays, async video/music jobs, webhook signature verification.
from aigateway import AIgateway client = AIgateway(api_key="sk-aig-...") # Scoped key per customer sub = client.sub_accounts.create(name="acme", spend_cap_cents=50_000) # Async video job job = client.jobs.create_video(model="runwayml/gen-4", prompt="...", duration=5) done = client.jobs.wait(job.id)