ChatCompletions
Generate a response from a list of messages, with both streaming and non-streaming output.
Request Conventions
| Item | Value |
|---|---|
| Base URL | https://token.wdcloud.ai |
| Authentication header | Authorization: Bearer <API_KEY> |
| JSON content type | Content-Type: application/json |
Endpoint
POST /v1/chat/completions
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
messages | array | Yes | Conversation message list |
stream | boolean | No | Enable streaming output |
temperature | number | No | Sampling temperature from 0 to 2 |
top_p | number | No | Nucleus sampling value from 0 to 1 |
max_tokens | integer | No | Maximum generated tokens |
max_completion_tokens | integer | No | Maximum completion tokens |
tools | array | No | Tools available to the model |
tool_choice | string or object | No | Tool selection strategy |
response_format | object | No | Requested response format |
reasoning_effort | string | No | Reasoning level: low, medium, or high |
Example
bash
curl -X POST "https://token.wdcloud.ai/v1/chat/completions" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
"stream": false
}'