Skip to content

Chat Completions

Generates a response from a list of messages, with or without streaming.

Updated on Aug 09, 2026

The core endpoint of the API. Send the history as a list of messages and receive the model's next response — the call is stateless, so the context is exactly what you sent. The guided usage is in Text generation.

POSThttps://api.hinow.ai/v1/chat/completionsBearer

Generates a response from a list of messages. Supports streaming over SSE.

Parâmetros

  • modelstring· bodyobrigatório

    Namespaced model id, such as `hinow/himax`.

  • messagesarray· bodyobrigatório

    The conversation messages. Content may include text and, on supported models, parts such as `image_url`.

  • streamboolean· body

    Returns tokens as they are produced, over SSE. `usage` arrives in the last event.

  • temperaturenumber· body

    Controls sampling variation. Lower values tend to produce more stable responses.

  • max_tokensinteger· body

    Upper limit of tokens in the response. When it truncates, `finish_reason` comes back as `"length"`.

  • response_formatobject· body

    `{"type": "json_object"}` requests content in JSON. Validate the fields in your application.

  • toolsarray· body

    Tools in JSON Schema for function calling.

  • tool_choicestring· body

    `"auto"` lets the model decide whether to call a tool.

Respostas

200Generated response
{
  "id": "chatcmpl-R2dSu3p8...",
  "object": "chat.completion",
  "model": "hinow/hinova",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 132, "completion_tokens": 60, "total_tokens": 192 }
}
400Malformed body (`invalid_request_error`)
404Model does not exist or is not enabled (`model_not_found`)
429Per-minute limit exceeded (`rate_limit_exceeded`)

finish_reason

ValueWhat it meansWhat to do
stopThe model finished the responseNothing — this is the normal case
lengthThe generation hit max_tokensThe response is truncated; raise the limit or ask for something shorter in the prompt
tool_callsThe model requested a toolRead message.tool_calls and return the result

Streaming and token counting

With stream: true, the usage field only appears in the last event, together with finish_reason, and the stream ends with data: [DONE]. Consume the final event when you need to record the count returned by the API.

Was this page helpful?