Chat Completions
Given a list of messages comprising a conversation, the model returns a response.
POST https://openapi.linkwo.ai/v1/chat/completionsRequest Body
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Model ID (e.g., deepseek/deepseek-v4-pro, z-ai/glm-5.1) |
messages | array | Yes | — | List of message objects |
temperature | float | No | 1.0 | Sampling randomness (0–2) |
top_p | float | No | 1.0 | Nucleus sampling threshold |
max_tokens | integer | No | model max | Max tokens to generate |
stream | boolean | No | false | Stream partial results via SSE |
stop | string/array | No | null | Up to 4 stop sequences |
presence_penalty | float | No | 0 | Penalize new tokens based on presence (-2–2) |
frequency_penalty | float | No | 0 | Penalize new tokens based on frequency (-2–2) |
response_format | object | No | null | Enable JSON mode or structured output |
tools | array | No | null | List of function/tool definitions |
tool_choice | string/object | No | auto | Controls tool selection |
seed | integer | No | null | For deterministic sampling |
n | integer | No | 1 | Number of completions to generate |
Message Object
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | system, user, assistant, or tool |
content | string/array | Yes | Message content (string or content parts) |
name | string | No | Sender name (for user/tool roles) |
tool_calls | array | No | Tool calls made by the assistant |
tool_call_id | string | No | ID of the tool call (for tool role) |
Example Request
curl https://openapi.linkwo.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4-pro",
"messages": [
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function to reverse a linked list."}
],
"temperature": 0.3,
"max_tokens": 1024
}'Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1719000000,
"model": "deepseek/deepseek-v4-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here's a Python function to reverse a linked list..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 30,
"completion_tokens": 150,
"total_tokens": 180
}
}
```bash
### Finish Reasons
| Reason | Description |
|--------|-------------|
| `stop` | Model finished naturally or hit a stop sequence |
| `length` | Max tokens reached before completion |
| `content_filter` | Content was filtered by safety policies |
| `tool_calls` | Model wants to call a tool |
## Streaming
Set `stream: true` to receive SSE chunks. See [Streaming Response](/docs/getting-started/streaming-response) for details.
## Using with OpenAI SDK
```python
from openai import OpenAI
client = OpenAI(
base_url="https://openapi.linkwo.ai/v1",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="deepseek/deepseek-v4-pro",
messages=[
{"role": "user", "content": "Hello!"}
]
)Supported Models
See Model Overview for the complete list of available model IDs.
Related
- Function Calling — Add tool capabilities
- Structured Output — Force JSON schema output
- Streaming Response — Streaming guide