Chat Completions

Given a list of messages comprising a conversation, the model returns a response.

POST https://openapi.linkwo.ai/v1/chat/completions

Request Body

ParameterTypeRequiredDefaultDescription
modelstringYesModel ID (e.g., deepseek/deepseek-v4-pro, z-ai/glm-5.1)
messagesarrayYesList of message objects
temperaturefloatNo1.0Sampling randomness (0–2)
top_pfloatNo1.0Nucleus sampling threshold
max_tokensintegerNomodel maxMax tokens to generate
streambooleanNofalseStream partial results via SSE
stopstring/arrayNonullUp to 4 stop sequences
presence_penaltyfloatNo0Penalize new tokens based on presence (-2–2)
frequency_penaltyfloatNo0Penalize new tokens based on frequency (-2–2)
response_formatobjectNonullEnable JSON mode or structured output
toolsarrayNonullList of function/tool definitions
tool_choicestring/objectNoautoControls tool selection
seedintegerNonullFor deterministic sampling
nintegerNo1Number of completions to generate

Message Object

FieldTypeRequiredDescription
rolestringYessystem, user, assistant, or tool
contentstring/arrayYesMessage content (string or content parts)
namestringNoSender name (for user/tool roles)
tool_callsarrayNoTool calls made by the assistant
tool_call_idstringNoID 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.