API reference
Chat completions
POST /v1/chat/completions — multi-turn chat and instruction calls.
POST
/v1/chat/completions
Creates a chat completion for the given messages. Supports streaming via stream: true.
Request (selected fields)
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | Model id from /v1/models. |
messages | array | Yes | OpenAI-style chat messages (system, user, assistant). |
stream | boolean | No | true to receive tokens as server-sent events. |
temperature | number | No | Sampling temperature (0–2). |
top_p | number | No | Nucleus sampling threshold. |
max_tokens | integer | No | Maximum tokens to generate. |
stop | string or array | No | Stop sequence(s). |
response_format | object | No | { "type": "json_object" } or { "type": "json_schema", "json_schema": {...} }. |
Response (non-streaming)
{
"id": "chatcmpl-example",
"object": "chat.completion",
"created": 1710000000,
"model": "myt/qwen3.6-35b-a3b",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": { "role": "assistant", "content": "Hello!" }
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
}
}Streaming
With stream: true, the response uses server-sent events; each chunk mirrors OpenAI streaming semantics.
Errors
{
"error": {
"message": "Invalid model: unknown-model",
"type": "invalid_request_error",
"code": null
}
}Examples
curl -sS --request "POST" \
--url "$MYT_BASE_URL/chat/completions" \
--header "Authorization: Bearer $MYT_API_KEY" \
--header "Content-Type: application/json" \
--data '{"model":"myt/qwen3.6-35b-a3b","messages":[{"role":"user","content":"Hello"}]}'