Appearance
DeepSeek 模型接口文档
兼容 OpenAI Chat Completions 接口,支持 DeepSeek 系列模型的普通消息与流式输出。
Base URL:https://api.agentpivot.net/v1/
登录平台
- Url:https://agentpivot.net/
- token:平台创建
- api-key:平台创建
接口概览
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /chat/completions | DeepSeek 对话接口(Chat Completions) |
| POST | /responses | DeepSeek 响应式接口(Responses,OpenAI 兼容) |
鉴权
使用 API Key:
| Header | 说明 |
|---|---|
x-api-key: <API_KEY> | 使用 API Key |
示例:
bash
curl -X POST "https://api.agentpivot.net/v1/chat/completions" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{
"role": "user",
"content": "Hello"
}]
}'支持模型
| 模型名称 | 说明 |
|---|---|
| deepseek-v4-flash | 高速度、低成本,适用于日常对话、代码生成、文本处理 |
| deepseek-v4-pro | 高性能推理模型,适用于复杂推理、Agent、代码生成、多步骤任务 |
POST /chat/completions
请求
- Content-Type:
application/json
Body
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称 |
messages | array | 是 | 对话消息列表 |
stream | boolean | 否 | 是否启用流式输出 |
max_tokens | number | 否 | 最大输出 Token 数 |
temperature | number | 否 | 采样温度 |
top_p | number | 否 | Top-P 采样 |
messages
| 字段 | 类型 | 说明 |
|---|---|---|
role | string | system | user | assistant |
content | string | 消息内容 |
请求示例
1. deepseek-v4-flash
bash
#!/usr/bin/env bash
API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: ${API_KEY}" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{
"role": "user",
"content": "hello"
}
],
"stream": false
}' | jq2. deepseek-v4-pro
bash
#!/usr/bin/env bash
API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: ${API_KEY}" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{
"role": "user",
"content": "分析未来五年 AI 发展趋势"
}
],
"stream": false
}' | jq流式输出
deepseek-v4-flash
bash
curl -N https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{
"role": "user",
"content": "写一个快速排序"
}
],
"stream": true
}'deepseek-v4-pro
bash
curl -N https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{
"role": "user",
"content": "详细解释 Transformer 工作原理"
}
],
"stream": true
}'响应示例
json
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1700000000,
"model": "deepseek-v4-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 10,
"total_tokens": 18
}
}POST /responses(Responses 接口)
DeepSeek 同时提供 OpenAI 兼容的 Responses 接口,面向多轮对话、工具调用与 Agent 场景。与 Chat Completions 相比,请求/响应结构与字段命名不同。
路径:POST /responses
与 /chat/completions 的关键差异
| Chat Completions | Responses |
|---|---|
messages | input(字符串或输入条目列表) |
system 消息放入 messages | instructions(作为第一条 system 消息) |
max_tokens | max_output_tokens |
响应 choices[].message.content | 响应 output[](含 message / function_call 等条目) |
请求
- Content-Type:
application/json
Body(顶层参数)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称 |
input | string | array | 是* | 输入内容(字符串或输入条目列表),input 与 instructions 至少填一个 |
instructions | string | 否 | 系统指令,作为第一条 system 消息 |
stream | boolean | 否 | 是否启用流式输出(SSE) |
temperature | number | 否 | 采样温度,范围 [0.0, 2.0] |
top_p | number | 否 | Top-P 采样 |
max_output_tokens | number | 否 | 最大输出 Token 数 |
tools | array | 否 | 工具定义,支持 function 与 web_search |
tool_choice | string | object | 否 | none / auto / required / 指定工具 |
reasoning | object | 否 | 推理配置,effort 生效 |
*
input与instructions至少提供一个。
input 条目(多轮对话)
| 字段 | 类型 | 说明 |
|---|---|---|
role | string | user | assistant | system | developer |
content | string | array | 消息内容;可含 input_text / output_text / input_image 内容片段 |
请求示例
1. 单轮(字符串 input)
bash
curl -s https://api.agentpivot.net/v1/responses \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "deepseek-v4-flash",
"input": "Hello"
}' | jq2. 带系统指令 + 多轮
bash
curl -s https://api.agentpivot.net/v1/responses \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "deepseek-v4-pro",
"instructions": "你是一个严谨的技术顾问。",
"input": [
{"role": "user", "content": "什么是响应式接口?"},
{"role": "assistant", "content": "Responses API 是 OpenAI 兼容的新一代接口。"},
{"role": "user", "content": "它和 Chat Completions 有什么区别?"}
]
}' | jq流式输出(SSE)
bash
curl -N https://api.agentpivot.net/v1/responses \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "deepseek-v4-flash",
"instructions": "You are a helpful assistant.",
"input": "写一个快速排序",
"stream": true
}'流式返回为 SSE 事件序列,事件带有 event 类型与递增的 sequence_number,以 response.completed / response.incomplete / response.failed 结束(没有 data: [DONE])。
| 事件 | 说明 |
|---|---|
response.created | 首个事件,响应已创建(status=in_progress) |
response.output_text.delta | 增量输出文本 |
response.output_text.done | 完整输出文本 |
response.completed | 正常结束,携带完整响应对象(含 usage) |
response.incomplete | 截断结束(如达到 max_output_tokens) |
response.failed | 失败,携带错误详情 |
响应示例
json
{
"id": "resp_xxx",
"object": "response",
"created_at": 1700000000,
"status": "completed",
"model": "deepseek-v4-flash",
"output": [
{
"type": "message",
"id": "msg_xxx",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Hello! How can I help you today?",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 8,
"output_tokens": 10,
"total_tokens": 18,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
}
}兼容性说明
- 不支持的参数会被静默忽略,不会报错(如
store、previous_response_id、conversation、metadata、parallel_tool_calls等)。 store固定返回false,previous_response_id固定为null。- 上下文缓存(Context Caching)自动管理。
- 超过上下文窗口的请求返回 400 错误。
测试脚本
bash
export API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"deepseek-v4-flash",
"messages":[
{
"role":"user",
"content":"介绍一下 DeepSeek"
}
]
}' | jq