Chat Completions API
POST
/v1/chat/completions 文本模型使用 Chat Completions 端点。非流式请求一次返回完整 JSON;设置 stream: true 后返回 Server-Sent Events,并以 [DONE] 结束。
Authorization: Bearer YOUR_API_KEYContent-Type: application/json同一个 HiAPI API Key 可以调用账户已开放的所有模型。文本模型使用 /v1/chat/completions;图片、视频和音频模型使用 /v1/tasks、input 参数对象及异步任务生命周期。
curl https://api.hiapi.ai/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-v4-flash", "messages": [{"role": "user", "content": "请解释稀疏注意力。"}], "stream": false }'model 和 messages 为必填字段。常用可选字段包括 stream、max_tokens、thinking、reasoning_effort、response_format 和 tools;具体能力以模型页为准。
从 choices[0].message.content 读取最终回答。思考模型还可能返回 choices[0].message.reasoning_content。usage 包含输入、输出、缓存读取及总 Token 数,也是计费明细的依据。
将 stream 设为 true,逐条解析 data: 事件,在收到 data: [DONE] 后结束。正文增量位于 choices[0].delta.content,推理增量位于 choices[0].delta.reasoning_content。
401:API Key 缺失或无效。402:余额不足。400:模型不存在或参数不合法。429:触发速率限制。503:模型暂时不可用,可使用有上限的指数退避重试。
查看 DeepSeek V4 Flash 的模型专属参数,实时 Token 价格以定价页为准。