API Reference
Chat completions
Generate a model response from a list of messages.
/v1/chat/completionsThe primary endpoint. Accepts a conversation and returns the next assistant message, optionally streamed.
Request body
modelstringRequiredModel configured on the stack. GET /v1/models lists valid values.
messagesMessage[]RequiredThe conversation so far, oldest first. Each message has a role and
content.
streambooleanOptionalDefault: falseReturn server-sent events instead of a single JSON body. See Streaming.
temperaturenumberOptionalDefault: 0.7Sampling randomness, 0–2. Overrides the stack's behavior setting for
this request only.
top_pnumberOptionalDefault: 1Nucleus sampling. Prefer adjusting this or temperature, not both.
max_tokensintegerOptionalDefault: 8000Cap on generated tokens. Clamped to a floor of 8000 and a ceiling of 16000 — a low or missing value never truncates a response mid-answer, and the floor counts against the context window (see Pricing model).
stopstring | string[]OptionalUp to four sequences that end generation. The sequence itself is not returned.
toolsTool[]OptionalFunction definitions the model may call. Same schema as OpenAI tools.
response_formatobjectOptionalSet to { "type": "json_object" } to constrain output to valid JSON.
textjson_objectchat_template_kwargsobjectOptionalAdvanced, model-family-specific. On Qwen3.x models, pass
{ "enable_thinking": false } here to skip the model's internal
reasoning step and answer directly — useful for closed, objective tasks
(classification, extraction) where you want lower latency over
reasoning depth. It must be nested under this key; a top-level
enable_thinking is silently ignored.
If you send a system message, it replaces the system prompt (and
knowledge-base context) configured on your stack for that request only.
Send no system message to keep your stack's configured behavior. See
Core concepts.
Message object
rolestringRequiredWho produced the message.
systemuserassistanttoolcontentstring | Part[]OptionalText, or an array of parts for multimodal input. May be null on an
assistant message that only calls a tool.
tool_call_idstringOptionalRequired on tool messages — links the result back to the call.
Example
curl "https://api.trystac.com/v1/chat/completions" \
-H "Authorization: Bearer $STAC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-stack-model",
"messages": [{ "role": "user", "content": "Name three primary colors." }],
"temperature": 0.2,
"max_tokens": 64
}'Response
{
"id": "chatcmpl-9f2a1c",
"object": "chat.completion",
"created": 1770000000,
"model": "your-stack-model",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Red, blue, and yellow." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 14, "completion_tokens": 7, "total_tokens": 21 }
}usage is reported for observability. It does not affect billing — see
Pricing model.
finish_reason
| Value | Meaning |
|---|---|
stop | Model finished, or hit a stop sequence |
length | Hit max_tokens |
tool_calls | Model wants a tool result before continuing |

