MaaS_DeepSeek
请求协议
https
Header
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
Content-Type |
string | 是 | 固定为 application/json |
Authorization |
string | 是 | Bearer ${YOUR_AK} |
对话补全
请求 URL
POST https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/chat/completions
请求 Body 参数
| 参数名 | 二级参数 | 三级参数 | 四级参数 | 类型 | 必填 | 描述 |
|---|---|---|---|---|---|---|
| model | - | - | - | string | 是 | 使用的模型 ID。 |
| messages | - | - | - | array[json] | 是 | 对话消息列表,按从老到新的顺序填入。 |
| role | - | - | string | 是 | 消息作者的角色,可选值为 user、assistant 或 system。 |
|
| content | - | - | object | 是 | 消息内容,可为 string 或 array[json] 类型。 | |
| content 为 string 时 | - | string | 否 | 消息内容为普通文本。 | ||
| content 为 array[json] 时 | - | array[json] | 否 | 消息内容为文本结构。 | ||
| type | string | 否 | 内容类型,必须为 text 或 file 两者中的一个。 |
|||
| text | string | 否 | 当 type 为 text 时,填写的消息文本。 |
|||
| file | object | 否 | 当 type 为 file 时,填写的文件内容。 |
|||
| file_id | string | 否 | ||||
| thinking | - | - | - | object | 否 | 用于控制模型的推理行为。 |
| reasoning_effort | - | - | string | 否 | 控制模型的推理强度,可选值为 high 或 max。 |
|
| max_tokens | - | - | - | integer | 否 | 限制模型生成的最大 token 数。 |
| response_format | - | - | - | object | 否 | 用于指定模型输出的格式。 |
| stop | - | - | - | object | 否 | 用于定义停止序列。 |
| stream | - | - | - | boolean | 否 | 是否使用流式接口,默认值为 false。若设为 true,模型将以 SSE 形式发送消息增量。 |
| stream_options | - | - | - | object | 否 | 流式传输时的附加选项。 |
| temperature | - | - | - | number | 否 | 采样温度,介于 0 到 2 之间,默认值为 1。通常建议仅调整该参数或 top_p 中的一个。 |
| top_p | - | - | - | number | 否 | 核采样参数,取值范围为 (0, 1],默认值为 1。通常建议仅调整该参数或 temperature 中的一个。 |
| tools | - | - | - | array[json] | 否 | 模型可以调用的函数列表。 |
| tool_choice | - | - | - | object | 否 | 控制模型如何调用工具。 |
| logprobs | - | - | - | boolean | 否 | 是否返回输出 token 的对数概率,默认值为 false。 |
| top_logprobs | - | - | - | integer | 否 | 返回 top N 个最可能 token 的对数概率,取值范围为 0 到 20。使用时需将 logprobs 设为 true。 |
| user_id | - | - | - | string | 否 | 业务侧的用户标识,字符集为 [a-zA-Z0-9\-_],最长 512 字符。 |
| frequency_penalty | - | - | - | number (deprecated) | 否 | 已弃用,该参数不再支持,传入不会产生任何效果。 |
| presence_penalty | - | - | - | number (deprecated) | 否 | 已弃用,该参数不再支持,传入不会产生任何效果。 |
请求示例
curl -L -X POST 'https://genaiapi.cloudsway.net/v1/ai/{endpointPath}/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"messages": [
{
"content": "You are a helpful assistant",
"role": "system"
},
{
"content": "Hi",
"role": "user"
}
],
"model": "MaaS_Deepseek_V4_pro_20260424",
"thinking": {
"type": "enabled"
},
"reasoning_effort": "high",
"max_tokens": 4096,
"response_format": {
"type": "text"
},
"stop": null,
"stream": false,
"stream_options": null,
"temperature": 1,
"top_p": 1,
"tools": null,
"tool_choice": "none",
"logprobs": false,
"top_logprobs": null
}'
响应示例
{
"id": "chatcmpl-lHhTva9flc1dlUBqu4pPADmq",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?",
"reasoning_content": "We are starting a conversation with the user. The user said \"Hi\". I should respond in a friendly and helpful manner, keeping in mind that the system prompt says \"You are a helpful assistant\". I need to introduce myself and ask how I can help. Keep it concise and warm."
},
"finish_reason": "stop",
"native_finish_reason": "stop"
}
],
"created": 1780299859,
"model": "MaaS_Deepseek_V4_pro_20260424",
"object": "chat.completion",
"system_fingerprint": "fp_9954b31ca7_prod0820_fp8_kvcache_20260402",
"usage": {
"prompt_tokens": 10,
"completion_tokens": 68,
"total_tokens": 78,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0,
"reasoning_tokens": 58,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0,
"image_tokens": 0
},
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 10
}
}