文本与代码
处理对话、文本分析与代码辅助任务。
标准消息格式
使用 messages 传入问题,从 choices 读取回复。
按用量计量
从当前模型目录选择型号并查看输入、输出价格。
从第一个请求开始
取得 Key,复制请求,并在下方查看对应的响应 JSON。
请求
export ACEDATACLOUD_API_KEY="YOUR_API_KEY"
curl --request POST "https://api.acedata.cloud/v1/chat/completions" \
--header "Authorization: Bearer $ACEDATACLOUD_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "deepseek-flash",
"messages": [
{
"role": "user",
"content": "Explain what an API is in one sentence."
}
]
}'响应 JSON
以下为现有接口响应的关键字段节选。任务标识、用量和生成内容以本次请求返回值为准。
{
"id": "chatcmpl-050bf20a-ebcd-498a-bf6e-63ee0738013b",
"object": "chat.completion",
"created": 1764846609,
"usage": {
"prompt_tokens": 8,
"completion_tokens": 11,
"total_tokens": 19
},
"choices": [
{
"index": 0,
"message": {
"content": "Hello! 😊 How can I help you today?",
"role": "assistant"
},
"refs": null,
"logprobs": null,
"finish_reason": "stop",
"service_tier": null
}
]
}读取返回结果
从 choices[0].message.content 读取回复。需要更多上下文时,在 messages 中保留相关历史。
选择当前公开目录中的模型,按输入和输出 Token 计量。
调用与费用
请求参数、可用型号和费用以当前接口及价格页面为准。遇到认证、余额或限额错误时,检查该 Key 的应用、有效期与使用限制。排查请求时保留 trace_id。
将 DeepSeek API 接入你的应用
从完整指南继续查看参数、结果字段和错误处理。
Introduction
APIs
Pricing
