创建对话补全
兼容 OpenAI 的对话补全接口,设置 stream=true 可流式输出。请求开始时按 max_tokens 预扣积分,完成后按实际用量结算,多扣部分退回。只接受 API Key。
认证
API Key:X-API-Key: <API Key> 或 Authorization: Bearer <API Key>。
示例中的凭证为占位值,请替换后在服务器端运行。
代码示例
curl -X POST 'https://shixux.com/api/v1/chat/completions' \ -H 'X-API-Key: yb_xxx_yyy' \ -H 'Content-Type: application/json' \ -d '{"model":"deepseek-v4.1-flash","messages":[{"role":"system","content":"你是一个简洁的助手。"},{"role":"user","content":"用一句话介绍时序科技。"}],"max_tokens":512,"stream":false}'{ "id": "job_xxx", "object": "chat.completion", "created": 1, "model": "example", "choices": [ { "index": 1, "message": { "role": "example", "content": "example", "reasoning_content": "example" }, "finish_reason": "example" } ]}application/json- body
OpenAI 对话补全请求。未知字段会被忽略;不支持 n 大于 1、工具调用和非文本内容。
model*string模型 ID,例如 deepseek-v4.1-flash。可用模型见文本模型总览,也可通过 GET /v1/models 获取。
messages*array<>元素
1 <= itemsstream?booleanstream_options?max_tokens?integer范围
1 <= valuemax_completion_tokens?integer范围
1 <= valuetemperature?numbertop_p?numberpresence_penalty?numberfrequency_penalty?numberseed?integer可选的确定性种子,范围 0–2147483647;模型不支持时不要传入。
stop?string|array<string>response_format?reasoning_effort?string可选值
"low""medium""high"user?string请求成功
- response
id*stringobject*stringcreated*integermodel*string模型 ID。图片和视频模型的可用状态、清晰度和费率以对应配置接口的返回为准;语音合成和音频编排可选 indextts-2(默认)或 indextts-2.5。
choices*array<>usage?