Your first request
Everything is OpenAI-compatible. The only change from your existing code is the base_url. Pick a language and run one of the snippets below — if you already have the OpenAI SDK installed, you don't need to install anything else.
Quickstart
# pip install aigateway-py openai # aigateway-py for primitives (sub-accounts, evals, jobs). # openai for chat — drop-in, that's the path our own SDK recommends. from openai import OpenAI client = OpenAI( base_url="https://api.aigateway.sh/v1", api_key=os.environ["AIG_KEY"], ) stream = client.chat.completions.create( model="moonshot/kimi-k2.6", messages=[{"role": "user", "content": "hi"}], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content, end="")
What you get back
Non-streaming calls return the familiar OpenAI response envelope. Streaming calls return a series of chat.completion.chunk events; the final chunk carries a usage object with exact token counts so you can meter per-request cost without waiting for the provider to settle.
// chat.completion streaming chunks { "id": "cmpl-9xT...", "object": "chat.completion.chunk", "model": "moonshot/kimi-k2.6", "choices": [{ "delta": { "content": "I'll " } }] } { ... "choices": [{ "delta": { "content": "help you " } }] } { ... "choices": [{ "delta": { "content": "..." } }] } { ... "usage": { "prompt_tokens": 42, "completion_tokens": 184 } }
Request shape
The request body is the standard OpenAI chat/completions schema. Any parameter the target model supports (temperature, top_p, response_format, tool_choice, max_tokens, seed) is passed through untouched. Unsupported parameters are dropped with a warning header (x-aig-warning) rather than a hard error.
POST /v1/chat/completions Content-Type: application/json Authorization: Bearer sk-aig-... { "model": "moonshot/kimi-k2.6", "messages": [ { "role": "system", "content": "You are concise." }, { "role": "user", "content": "hi" } ], "temperature": 0.2, "stream": true }
What to try next
- Swap
modelfor any ID from Swap models. - Add
stream: true— see Streaming. - Call a reasoning model (
deepseek/deepseek-r1,openai/o4-mini) and read the Reasoning page.