Chat Completions
POST /v1/chat/completions is used to create chat completions and is the default interface for most clients and SDKs.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Platform model name |
messages | array | Yes | List of conversation messages |
stream | boolean | No | Whether to use streaming responses |
temperature | number | No | Sampling temperature; whether it takes effect depends on the model |
top_p | number | No | Nucleus sampling parameter |
max_tokens | number | No | Maximum output tokens; some models use other fields |
max_completion_tokens | number | No | Maximum completion tokens used by some reasoning models |
tools | array | No | Tool or function definitions |
tool_choice | string/object | No | Tool selection strategy |
response_format | object | No | JSON or structured output requirements |
Message Object
| Field | Description |
|---|---|
role | system, user, assistant, tool, etc. |
content | Text or an array of multimodal content parts |
name | Optional name |
tool_calls | Tool calls initiated by the model |
tool_call_id | ID of the call associated with the tool response message |
Response
Non-streaming responses typically contain id, object, created, model, choices, and usage. Streaming responses return incremental delta values by event.
Request Example
curl https://api.cloudaikit.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "你好"}],
"temperature": 0.2
}'Text in non-streaming responses is typically located at choices[0].message.content. When using tool calls, execute the functions in choices[0].message.tool_calls, then send the results back as messages with role: tool.
Compatibility Differences
Tool calls, structured output, image input, audio input, reasoning parameters, and cache billing fields depend on the model and channel. If a field is ignored or causes an error, check the actual channel in the logs and consult the capabilities of the corresponding model.
