≡ 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/completionsRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Model ID, e.g. doubao-seed-2-0-lite-260215, deepseek-v3 |
| messages | array | Required | List of chat messages. Each has a role and a content field |
| temperature | number | Optional | Sampling temperature in [0.0, 2.0], default 1.0. Higher is more creative |
| top_p | number | Optional | Nucleus sampling in [0.0, 1.0], default 1.0 |
| max_tokens | integer | Optional | Max tokens to generate, default 4096; ceiling depends on the model |
| stream | boolean | Optional | Whether to stream the response, default false |
| tools | array | Optional | Function Calling tool list, following the OpenAI tools schema |
| response_format | object | Optional | Output 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 →