Skip to main content
Documentation

Documentation menu

Chat completions (OpenAI-compatible)

POST /v1/chat/completions - request fields, the response shape, finish reasons and what is accepted but ignored.

Last updated 2026-11-04

POST https://api.ticonai.com/v1/chat/completions follows the OpenAI Chat Completions format, so OpenAI SDKs work after you change the base URL and key.

bash
curl -sS https://api.ticonai.com/v1/chat/completions \
  -H "Authorization: Bearer $AIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      { "role": "system", "content": "You answer in one short sentence." },
      { "role": "user", "content": "What is a prepaid wallet?" }
    ],
    "max_tokens": 80,
    "temperature": 0.2
  }'

The request must have Content-Type: application/json, a valid UTF-8 JSON body, and be at most 2 MiB. Larger bodies fail with 413 request_too_large.

Request fields

FieldTypeNotes
modelstring, requiredA model id from GET /v1/models.
messagesarray, requiredAt least one message. Roles: system, developer, user, assistant, tool. system and developer messages are combined into the system prompt; there must be at least one other message.
max_tokens or max_completion_tokensintegerUpper bound on generated tokens. If both are sent, max_completion_tokens is used. If neither is sent, the model's default maximum output applies. A value above the model's maximum output is lowered to that maximum.
temperaturenumber, 0 to 2
top_pnumber, 0 to 1
stopstring or array of up to 16 strings
streambooleantrue returns server-sent events. See Streaming.
stream_options.include_usagebooleanWith stream, adds a final chunk that carries usage.
tools, tool_choiceanyAccepted and forwarded to the model.
nintegerOnly 1 is supported; any other value fails with 400 invalid_request and param: "n".

Other fields, including response_format and user, are accepted so that existing client code keeps working, but this release does not act on them.

Message content may be a string or an array of content parts. Text parts are metered as text. Image, audio, file and other non-text parts are passed through and counted with a fixed token allowance for the pre-flight hold.

Response

json
{
  "id": "chatcmpl-req_0123456789abcdef",
  "object": "chat.completion",
  "created": 1767225600,
  "model": "your-model-id",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "A prepaid wallet holds money you add before you spend it." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 14,
    "total_tokens": 45,
    "prompt_tokens_details": { "cached_tokens": 0 }
  }
}
  • model is the model id you requested.
  • finish_reason is stop, length (hit max_tokens), tool_calls or content_filter.
  • prompt_tokens includes the cached tokens reported in prompt_tokens_details.cached_tokens. Cached tokens may be billed at a lower price; see Billing and wallet.
  • The x-request-id response header identifies the request. Quote it to support.

Context window

The input plus the requested output must fit the model's context window. Otherwise the request fails with 400 invalid_request or 400 context_length_exceeded (with param: "messages"), and nothing is charged.

Errors

Errors use the OpenAI shape and carry a stable code. See Errors.

bash
curl -sS https://api.ticonai.com/v1/chat/completions \
  -H "Authorization: Bearer $AIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "no-such-model", "messages": [{ "role": "user", "content": "hi" }] }'