Chat Completions

The workhorse route. One request shape, JSON or streamed, with token accounting written to your ledger.

FieldTypeNotes
modelstring, requiredModel id from GET /v1/models.
messagesarray, requiredOrdered list of { role, content }. Roles: system, user, assistant, tool.
streambooleantrue returns text/event-stream chunks ending in data: [DONE].
temperaturenumberSampling randomness. Lower for extraction, higher for ideation.
max_tokensnumberCaps completion length. The gateway validates the value before dispatch.
toolsarrayFunction definitions: { type: "function", function: { name, description?, parameters? } }. Rejected if the model cannot call tools.
tool_choicestring | objectLets the model pick, forces a specific function, or disables tools entirely.

Response

json
{
  "id": "chatcmpl-8f2…",
  "object": "chat.completion",
  "created": 1757000123,
  "model": "YOUR_MODEL_ID",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Because short wavelengths scatter more." },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 42, "completion_tokens": 18, "total_tokens": 60 }
}

Tool calls

json
{
  "model": "YOUR_MODEL_ID",
  "messages": [{ "role": "user", "content": "What is the weather in Berlin?" }],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Current weather for a city",
      "parameters": {
        "type": "object",
        "properties": { "city": { "type": "string" } },
        "required": ["city"]
      }
    }
  }]
}

The assistant reply then contains tool_calls. Execute them, append a role: "tool" message with the result, and call the endpoint again — the standard loop every OpenAI-compatible client already implements.

ExosAI

ExosAI — OpenAI-compatible AI API