POST /v1/chat/completions
Create a model response for the provided chat conversation. Standard OpenAI payload specification.
Endpoint & Headers
POST https://infinityrouter.qd.je/v1/chat/completions Authorization: Bearer inf_live_... Content-Type: application/json
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Canonical ID from the model catalog (e.g. claude-sonnet-5). |
| messages | array | Yes | Array of message objects (role: system, user, assistant, tool). |
| stream | boolean | No | When true, returns text/event-stream chunks. Default false. |
| max_tokens | integer | No | Upper bound on completion tokens generated. |
| temperature | number | No | Sampling temperature between 0 and 2. Default 1.0. |
| tools | array | No | List of function calling JSON schema definitions. |
Example Response (Non-Streaming)
{
"id": "req_9f1a2b3c4d5e",
"object": "chat.completion",
"created": 1770000000,
"model": "claude-sonnet-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist your engineering team today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 11,
"total_tokens": 23
}
}Response Status Codes
| Status | Code | Description |
|---|---|---|
| 200 | OK | Successful completion or stream initiation. |
| 400 | invalid_request | Malformed JSON payload or invalid model parameter. |
| 401 | authentication_failed | Missing, invalid, or revoked API key. |
| 402 | insufficient_credits | Account balance cannot cover token reservation hold. |
| 404 | model_not_found | Requested canonical model ID does not exist. |
| 429 | rate_limited | Key throughput limit exceeded (returns Retry-After header). |
| 502 | upstream_failure | Downstream AI provider returned an unexpected error. |
| 503 | no_capacity | All upstream routes for requested model are currently unavailable. |