API Reference

POST /v1/chat/completions

Create a model response for the provided chat conversation. Standard OpenAI payload specification.

Endpoint & Headers

httpRequest
POST https://infinityrouter.qd.je/v1/chat/completions
Authorization: Bearer inf_live_...
Content-Type: application/json

Request Body Parameters

Parameters
ParameterTypeRequiredDescription
modelstringYesCanonical ID from the model catalog (e.g. claude-sonnet-5).
messagesarrayYesArray of message objects (role: system, user, assistant, tool).
streambooleanNoWhen true, returns text/event-stream chunks. Default false.
max_tokensintegerNoUpper bound on completion tokens generated.
temperaturenumberNoSampling temperature between 0 and 2. Default 1.0.
toolsarrayNoList of function calling JSON schema definitions.

Example Response (Non-Streaming)

json200 OK
{
  "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

HTTP Status Codes
StatusCodeDescription
200OKSuccessful completion or stream initiation.
400invalid_requestMalformed JSON payload or invalid model parameter.
401authentication_failedMissing, invalid, or revoked API key.
402insufficient_creditsAccount balance cannot cover token reservation hold.
404model_not_foundRequested canonical model ID does not exist.
429rate_limitedKey throughput limit exceeded (returns Retry-After header).
502upstream_failureDownstream AI provider returned an unexpected error.
503no_capacityAll upstream routes for requested model are currently unavailable.