Chat Completions
Create a chat completion request.
Endpoint
http
POST /v1/chat/completionsRequest Headers
http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/jsonRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name |
messages | array | Yes | List of conversation messages |
temperature | number | No | Controls output randomness |
max_tokens | integer | No | Maximum number of output tokens |
stream | boolean | No | Enables streaming output |
Message Fields
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | system, user, or assistant |
content | string | Yes | Message content |
Standard Request
bash
curl https://api.nexusmodels.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{
"role": "system",
"content": "You are a professional assistant."
},
{
"role": "user",
"content": "Explain artificial intelligence in three sentences."
}
]
}'Streaming Request
bash
curl https://api.nexusmodels.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Explain artificial intelligence."
}
],
"stream": true
}'Example Response
json
{
"id": "chatcmpl-example",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Artificial intelligence enables computers to perform tasks that normally require human intelligence."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 20,
"total_tokens": 32
}
}