Create chat completion

POST
/v1/chat/completions

Creates a model response for the given chat conversation. Supports streaming via SSE when stream: true.

Response headers

  • Inference-Id — Unique ID for this request. Include this when contacting support.

Error codes

StatusMeaning
402Insufficient credits
429Rate limited
504No backend available
529No healthy backends are available for the requested model

Authorization

BearerAuth
AuthorizationBearer <token>

API key passed as Bearer token

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "messages": [      {}    ]  }'
{
  "id": "string",
  "object": "string",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "string",
        "content": "string",
        "tool_calls": [
          {}
        ],
        "tool_call_id": "string"
      },
      "finish_reason": "string"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}