About this endpoint
What it does
Generates a text chat completion from the messages you provide. You send a model name and an array of chat messages, and the endpoint returns the model's reply along with token usage.
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| model | String | Yes | Model identifier to use for the completion, e.g. qwen3.8-27b. |
| messages | Object Array | Yes | Chat message list. Must contain at least 1 item. |
| messages[].role | ENUM | Yes | Message role. Allowed values: system, user, assistant. |
| messages[].content | String | Yes | Message text content. |
| max_tokens | Integer | No | Maximum number of tokens to generate. Default: 128. Minimum: 1. |
| stream | Boolean | No | Whether to stream the response. Default: false. |
Additional model-specific parameters are accepted and passed through to the model.
Response
Returns a JSON object. The reply text is in choices[0].message.content.
| Field | Type | Description |
|---|---|---|
| id | String | Unique identifier for the completion. |
| object | String | Object type, always chat.completion. |
| created | Integer | Unix timestamp (seconds) when the completion was created. |
| model | String | Model that generated the completion. |
| choices | Object Array | List of generated completions. |
| choices[].index | Integer | Position of the choice in the list. |
| choices[].finish_reason | String | Why generation stopped: stop (natural end) or length (hit max_tokens). |
| choices[].logprobs | Object | Log probability data. null unless the model returns it. |
| choices[].message.role | String | Always assistant. |
| choices[].message.content | String | The generated text. |
| choices[].message.refusal | String | Refusal message if the model declined to answer, otherwise null. |
| usage.prompt_tokens | Integer | Tokens in the input messages. |
| usage.completion_tokens | Integer | Tokens in the generated reply. |
| usage.total_tokens | Integer | Sum of prompt and completion tokens. |
| usage.completion_tokens_details.reasoning_tokens | Integer | Tokens used for internal reasoning, 0 for non-reasoning models. |
| usage.prompt_tokens_details.cached_tokens | Integer | Prompt tokens served from cache. |
The response may include extra fields depending on the model.
Notes
max_tokensdefaults to128, so longer replies are cut off withfinish_reason: "length". Increase it for longer output.- Include earlier
userandassistantturns inmessagesto keep conversation context. The endpoint does not store history between calls. - With
stream: true, the reply is returned incrementally instead of as one JSON object.



