Core features
Text generation
Chat-style text generation through the chat completions endpoint.
POST
/v1/chat/completions
Generates a model response for the given chat conversation. Supports multi-turn history, system prompts, tool calls, and streaming.
Request body
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | Model id from /v1/models. |
messages | array | Yes | Ordered list of system, user, and assistant turns. |
stream | boolean | No | true to receive tokens as server-sent events. |
temperature | number | No | Sampling temperature (0–2). Lower = more deterministic. |
top_p | number | No | Nucleus sampling threshold. |
max_tokens | integer | No | Maximum tokens to generate. |
stop | string or array | No | Stop sequence(s) that terminate generation. |
n | integer | No | Number of completion choices to return. |
Example request
{
"model": "myt/qwen3.6-35b-a3b",
"messages": [
{ "role": "system", "content": "You are a concise assistant." },
{ "role": "user", "content": "Explain what a REST API is in two sentences." }
],
"temperature": 0.7,
"max_tokens": 128
}Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1749366600,
"model": "myt/qwen3.6-35b-a3b",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "A REST API is a web service that uses standard HTTP methods (GET, POST, PUT, DELETE) to allow clients to read and modify resources on a server. It is stateless, meaning each request carries all the information needed to process it."
}
}
],
"usage": {
"prompt_tokens": 29,
"completion_tokens": 44,
"total_tokens": 73
}
}Streaming
Set "stream": true to receive tokens incrementally via server-sent events. Each chunk contains a delta object; the stream ends with data: [DONE].
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"A"}}]}
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" REST"}}]}
data: [DONE]Errors
| Status | When |
|---|---|
400 | Missing model or messages, invalid parameter values |
401 | API key missing or invalid |
403 | Model not allowed for your project |
429 | Rate limit or monthly budget exceeded |
Code 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"}]}'Streaming example
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","stream":true,"messages":[{"role":"user","content":"Count from 1 to 5 slowly."}]}'Full parameter reference: Chat completions.