API Reference
Chat Completions
OpenAI-compatible inference endpoint (streaming + non-streaming).
POST /v1/chat/completions
OpenAI-compatible. Requires Authorization: Bearer <api-key>.
curl -X POST https://agent-router.gaib.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-2.5-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"max_tokens": 512
}'import OpenAI from 'openai'
const client = new OpenAI({
baseURL: 'https://agent-router.gaib.ai/v1',
apiKey: 'sk-your-key',
})
const res = await client.chat.completions.create({
model: 'gemini/gemini-2.5-flash',
messages: [{ role: 'user', content: 'Hello!' }],
max_tokens: 512,
}){
"id": "chatcmpl-abc123",
"object": "chat.completion",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 9,
"total_tokens": 29
}
}Request body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | yes | — | Model ID (e.g. gemini/gemini-2.5-flash) |
messages | array | yes | — | Array of {role, content} objects |
max_tokens | number | no | 1024 | Max completion tokens |
temperature | number | no | — | Sampling temperature |
top_p | number | no | — | Nucleus sampling |
stream | boolean | no | false | Enable SSE streaming |
tools | array | no | — | OpenAI-style tool/function definitions |
tool_choice | string / object | no | — | Tool selection control |
Other standard OpenAI fields — stop, presence_penalty, frequency_penalty, response_format, seed, n, logprobs — are also accepted and forwarded to the provider.
Not supported
Requests with thinking or reasoning_effort parameters return HTTP 400. Strip these fields before calling the gateway.
Streaming
Set "stream": true. The response is standard OpenAI SSE:
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"!"}}]}
data: [DONE]