Skip to content

DeepSeek 模型接口文档 ​

兼容 OpenAI Chat Completions 接口,支持 DeepSeek 系列模型的普通消息与流式输出。

Base URL:https://api.agentpivot.net/v1/


登录平台 ​


接口概览 ​

方法路径说明
POST/chat/completionsDeepSeek 对话接口(Chat Completions)
POST/responsesDeepSeek 响应式接口(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 ​

字段类型必填说明
modelstring是模型名称
messagesarray是对话消息列表
streamboolean否是否启用流式输出
max_tokensnumber否最大输出 Token 数
temperaturenumber否采样温度
top_pnumber否Top-P 采样

messages ​

字段类型说明
rolestringsystem | user | assistant
contentstring消息内容

请求示例 ​

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
  }' | jq

2. 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 CompletionsResponses
messagesinput(字符串或输入条目列表)
system 消息放入 messagesinstructions(作为第一条 system 消息)
max_tokensmax_output_tokens
响应 choices[].message.content响应 output[](含 message / function_call 等条目)

请求 ​

  • Content-Type:application/json

Body(顶层参数) ​

字段类型必填说明
modelstring是模型名称
inputstring | array是*输入内容(字符串或输入条目列表),input 与 instructions 至少填一个
instructionsstring否系统指令,作为第一条 system 消息
streamboolean否是否启用流式输出(SSE)
temperaturenumber否采样温度,范围 [0.0, 2.0]
top_pnumber否Top-P 采样
max_output_tokensnumber否最大输出 Token 数
toolsarray否工具定义,支持 function 与 web_search
tool_choicestring | object否none / auto / required / 指定工具
reasoningobject否推理配置,effort 生效

*input 与 instructions 至少提供一个。

input 条目(多轮对话) ​

字段类型说明
rolestringuser | assistant | system | developer
contentstring | 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"
  }' | jq

2. 带系统指令 + 多轮 ​

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