≡ All docs

Model API / Chat Completions

Chat Completions

Updated: 2026-02-18

Overview

Generate conversational text replies, compatible with the OpenAI Chat Completions spec. Supports streaming, tool calls, and structured output (JSON Mode).

POST/chat/completions

Request Parameters

ParameterTypeRequiredDescription
modelstringRequiredModel ID, e.g. doubao-seed-2-0-lite-260215, deepseek-v3
messagesarrayRequiredList of chat messages. Each has a role and a content field
temperaturenumberOptionalSampling temperature in [0.0, 2.0], default 1.0. Higher is more creative
top_pnumberOptionalNucleus sampling in [0.0, 1.0], default 1.0
max_tokensintegerOptionalMax tokens to generate, default 4096; ceiling depends on the model
streambooleanOptionalWhether to stream the response, default false
toolsarrayOptionalFunction Calling tool list, following the OpenAI tools schema
response_formatobjectOptionalOutput format; pass { type: "json_object" } to enable JSON mode

Example

curl -X POST "https://www.starunion.net/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-2-0-lite-260215",
"messages": [
{"role": "user", "content": "Explain quantum entanglement in one sentence"}
]
}'

Streaming

When stream is set to true, the server returns a Server-Sent Events (SSE) stream where each event is an incremental delta.

curl -X POST "https://www.starunion.net/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-2-0-lite-260215",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'

Function Calling

Pass function definitions via the tools parameter. The model returns tool_calls when needed; your application runs the function and feeds the result back.

JSON
{
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\": \"Hangzhou\"}"
}
}
]
}

Didn't find what you were looking for?Contact us →