> ## Documentation Index
> Fetch the complete documentation index at: https://evolink.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# DeepSeek V4 - Responses 接口

> - 使用 OpenAI Responses 协议调用 DeepSeek V4 模型
- 支持 `deepseek-v4-flash`（快速通用）和 `deepseek-v4-pro`（深度推理）两个模型
- **输入形态**：`input` 可以是一段纯文本，也可以是输入项数组（消息、函数调用、函数结果、思考、搜索记录）
- **系统指令**：通过 `instructions` 下达，等价于首条 system 消息
- **思考模式**：通过 `reasoning.effort` 控制推理强度，思考内容以 `reasoning` 输出项返回
- **流式输出**：支持语义化 SSE 事件，以 `response.completed` 结束，**不发送 `[DONE]`**
- **工具调用**：支持 Function Calling 与内置 `web_search` 联网搜索
- **结构化输出**：通过 `text.format` 启用 JSON 对象或 JSON Schema
- **上下文缓存**：相同前缀请求自动命中缓存，大幅降低输入成本

**流式事件**：`response.created`、`response.output_item.added`、`response.reasoning_text.delta`、`response.output_text.delta`，终止事件为 `response.completed` / `response.incomplete` / `response.failed`。每个事件都带 `sequence_number` 用于排序。

**不生效的字段**：以下 OpenAI 字段可以照常传入，不会报错，但不会产生实际效果。

| 字段 | 行为 |
| --- | --- |
| `store` | 恒为 `false`，不保存响应 |
| `previous_response_id` | 恒为 `null`，不支持续接会话 |
| `conversation` | 不支持 |
| `background` / `metadata` / `include` | 忽略 |
| `prompt` / `truncation` / `service_tier` | 忽略 |
| `safety_identifier` / `context_management` | 忽略 |
| `stream_options` | 忽略 |
| `parallel_tool_calls` | 忽略，并行工具调用恒为开启 |
| `max_tool_calls` | 忽略 |
| `file_search` / `code_interpreter` / `mcp` 工具 | 忽略 |

**其他限制**：
- 自定义工具（`type: custom`）仅支持 `apply_patch`
- `web_search` 工具会忽略 `search_context_size` 与 `user_location`
- 图片与文件内容块会被转换为占位符，DeepSeek V4 不是视觉模型
- 输入超过上下文窗口直接返回 400，不做自动截断

<Note>
  **BaseURL 说明**：默认 BaseURL 为 `https://direct.evolink.ai`，对文本模型支持更好，支持长连接；`https://api.evolink.ai` 是多模态主力地址，对文本模型作为备用地址使用。
</Note>


## OpenAPI

````yaml cn/api-manual/language-series/deepseek-v4/deepseek-v4-responses.json POST /v1/responses
openapi: 3.1.0
info:
  title: DeepSeek V4 完整参数文档 (Responses API)
  description: >-
    DeepSeek V4 系列 Responses 接口（`deepseek-v4-flash` / `deepseek-v4-pro`）的完整 API
    参考。


    **模型能力**：

    - 上下文长度：**1,000,000 tokens**（1M）

    - 最大输出：**384,000 tokens**（384K）

    - 思考模式：通过 `reasoning.effort` 控制推理强度，`deepseek-v4-pro` 擅长复杂推理

    - 上下文硬盘缓存：自动命中，命中与未命中分别计费

    - 内置联网搜索：`web_search` 工具由服务端执行，无需客户端参与


    **协议说明**：本接口完全兼容 OpenAI Responses API
    协议，请求体原样保留，不做字段重排或裁剪，未声明的扩展字段与缓存前缀均不受影响。


    **无状态**：DeepSeek Responses 不保存任何会话，多轮对话需要客户端每次携带完整历史。


    **计费档位（UC/1K tokens，EvoLink 内部单位）**：

    | 模型 | 输入缓存命中 | 输入缓存未命中 | 输出 |

    | --- | --- | --- | --- |

    | deepseek-v4-flash | 2 | 100 | 200 |

    | deepseek-v4-pro | 3 | 300 | 600 |
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
tags:
  - name: 对话生成
    description: AI 对话生成相关接口
paths:
  /v1/responses:
    post:
      tags:
        - 对话生成
      summary: DeepSeek V4 Responses 接口（OpenAI 兼容）
      description: >-
        - 使用 OpenAI Responses 协议调用 DeepSeek V4 模型

        - 支持 `deepseek-v4-flash`（快速通用）和 `deepseek-v4-pro`（深度推理）两个模型

        - **输入形态**：`input` 可以是一段纯文本，也可以是输入项数组（消息、函数调用、函数结果、思考、搜索记录）

        - **系统指令**：通过 `instructions` 下达，等价于首条 system 消息

        - **思考模式**：通过 `reasoning.effort` 控制推理强度，思考内容以 `reasoning` 输出项返回

        - **流式输出**：支持语义化 SSE 事件，以 `response.completed` 结束，**不发送 `[DONE]`**

        - **工具调用**：支持 Function Calling 与内置 `web_search` 联网搜索

        - **结构化输出**：通过 `text.format` 启用 JSON 对象或 JSON Schema

        - **上下文缓存**：相同前缀请求自动命中缓存，大幅降低输入成本


        **流式事件**：`response.created`、`response.output_item.added`、`response.reasoning_text.delta`、`response.output_text.delta`，终止事件为
        `response.completed` / `response.incomplete` / `response.failed`。每个事件都带
        `sequence_number` 用于排序。


        **不生效的字段**：以下 OpenAI 字段可以照常传入，不会报错，但不会产生实际效果。


        | 字段 | 行为 |

        | --- | --- |

        | `store` | 恒为 `false`，不保存响应 |

        | `previous_response_id` | 恒为 `null`，不支持续接会话 |

        | `conversation` | 不支持 |

        | `background` / `metadata` / `include` | 忽略 |

        | `prompt` / `truncation` / `service_tier` | 忽略 |

        | `safety_identifier` / `context_management` | 忽略 |

        | `stream_options` | 忽略 |

        | `parallel_tool_calls` | 忽略，并行工具调用恒为开启 |

        | `max_tool_calls` | 忽略 |

        | `file_search` / `code_interpreter` / `mcp` 工具 | 忽略 |


        **其他限制**：

        - 自定义工具（`type: custom`）仅支持 `apply_patch`

        - `web_search` 工具会忽略 `search_context_size` 与 `user_location`

        - 图片与文件内容块会被转换为占位符，DeepSeek V4 不是视觉模型

        - 输入超过上下文窗口直接返回 400，不做自动截断
      operationId: createResponseDeepSeekV4
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
            examples:
              simple_text:
                summary: 单轮文本对话（Flash）
                value:
                  model: deepseek-v4-flash
                  input: 用一句话介绍杭州。
              with_instructions:
                summary: 使用系统指令
                value:
                  model: deepseek-v4-flash
                  instructions: 你是一位严谨的技术文档工程师，回答保持简洁。
                  input: 解释什么是上下文缓存。
              multi_turn:
                summary: 多轮对话（输入项数组）
                value:
                  model: deepseek-v4-flash
                  input:
                    - type: message
                      role: user
                      content: 帮我想三个产品名字。
                    - type: message
                      role: assistant
                      content: 云栖、启明、翎风。
                    - type: message
                      role: user
                      content: 第二个再给我五个近义词。
              reasoning_effort:
                summary: 使用 Pro 模型 + 高强度推理
                value:
                  model: deepseek-v4-pro
                  input: 一个水池有进水管和出水管，进水管 3 小时注满，出水管 5 小时放空。同时打开需要多久注满？请给出推导过程。
                  reasoning:
                    effort: high
              disable_thinking:
                summary: 关闭思考（仅直接回答）
                value:
                  model: deepseek-v4-flash
                  input: 北京到上海的高铁大约多久？
                  reasoning:
                    effort: none
              json_schema:
                summary: 结构化输出（JSON Schema）
                value:
                  model: deepseek-v4-flash
                  input: 提取这句话中的人物和城市：张伟下周要去成都出差。
                  text:
                    format:
                      type: json_schema
                      name: extraction
                      schema:
                        type: object
                        properties:
                          person:
                            type: string
                          city:
                            type: string
                        required:
                          - person
                          - city
              function_calling:
                summary: Function Calling 工具调用
                value:
                  model: deepseek-v4-flash
                  input: 杭州现在天气怎么样？
                  tools:
                    - type: function
                      name: get_weather
                      description: 查询指定城市的实时天气
                      parameters:
                        type: object
                        properties:
                          city:
                            type: string
                            description: 城市名称
                        required:
                          - city
                  tool_choice: auto
              web_search:
                summary: 内置联网搜索（服务端执行）
                value:
                  model: deepseek-v4-flash
                  input: 总结一下本周人工智能领域的重要新闻。
                  tools:
                    - type: web_search
              streaming:
                summary: 流式输出
                value:
                  model: deepseek-v4-flash
                  input: 写一首关于秋天的短诗。
                  stream: true
      responses:
        '200':
          description: 生成成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
              example:
                id: resp_9f2c1a4b8e7d
                object: response
                created_at: 1755000000
                status: completed
                model: deepseek-v4-flash
                output:
                  - id: rs_2b7f
                    type: reasoning
                    summary: []
                    content:
                      - type: reasoning_text
                        text: 用户想要一句话介绍，需要覆盖地理与人文两个要点。
                  - id: msg_5d1a
                    type: message
                    role: assistant
                    status: completed
                    content:
                      - type: output_text
                        text: 杭州是浙江省省会，以西湖山水与数字经济闻名。
                        annotations: []
                error: null
                incomplete_details: null
                usage:
                  input_tokens: 694
                  input_tokens_details:
                    cached_tokens: 640
                  output_tokens: 20
                  output_tokens_details:
                    reasoning_tokens: 10
                  total_tokens: 714
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 400
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: 未认证、Token 无效或过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid authentication credentials
                  type: authentication_error
        '402':
          description: 配额不足、需要充值
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 402
                  message: Insufficient quota
                  type: insufficient_quota
        '403':
          description: 无权限访问该模型
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 403
                  message: Model access denied
                  type: permission_error
        '404':
          description: 资源不存在
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 404
                  message: Model not found
                  type: not_found_error
        '413':
          description: 请求体过大
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 413
                  message: Request entity too large
                  type: invalid_request_error
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 429
                  message: Rate limit exceeded
                  type: rate_limit_error
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 500
                  message: Internal server error
                  type: server_error
        '502':
          description: 网关错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 502
                  message: Bad gateway
                  type: server_error
        '503':
          description: 服务暂时不可用
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 503
                  message: Service temporarily unavailable
                  type: server_error
components:
  schemas:
    ResponsesRequest:
      type: object
      required:
        - model
      properties:
        model:
          type: string
          description: |-
            模型 ID

            - `deepseek-v4-flash`：快速通用，适合日常对话、摘要、抽取
            - `deepseek-v4-pro`：深度推理，适合复杂数学、代码与多步规划
          enum:
            - deepseek-v4-flash
            - deepseek-v4-pro
          default: deepseek-v4-flash
          example: deepseek-v4-flash
        input:
          type:
            - string
            - array
          description: >-
            模型输入。`input` 与 `instructions` 至少提供一个。


            - **字符串形态**：整段文本按一条 `user` 消息处理

            - **数组形态**：输入项列表，支持
            `message`、`function_call`、`function_call_output`、`reasoning`、`web_search_call`
            五种类型


            **多轮对话**：接口无状态，续接对话必须把完整历史放进数组。
          items:
            $ref: '#/components/schemas/InputItem'
          example: 用一句话介绍杭州。
        instructions:
          type: string
          description: 系统级指令，等价于插入在最前面的一条 system 消息，用于设定角色、语气与输出约束。
          example: 你是一位严谨的技术文档工程师，回答保持简洁。
        stream:
          type: boolean
          description: >-
            是否流式返回


            - `false`（默认）：一次性返回完整响应对象

            - `true`：以语义化 SSE 事件推送，末尾事件为 `response.completed` /
            `response.incomplete` / `response.failed`，**不会发送 `[DONE]`**
          default: false
          example: false
        max_output_tokens:
          type: integer
          description: 本次生成的最大输出 token 数（含思考 token）。取值范围 1 ~ 393216（384K）。留空则由模型自行决定。
          minimum: 1
          maximum: 393216
          example: 4096
        temperature:
          type: number
          description: 采样温度，越高输出越随机。**思考模式下不生效。**
          minimum: 0
          maximum: 2
          default: 1
          example: 1
        top_p:
          type: number
          description: 核采样阈值，与 `temperature` 建议只调其一。**思考模式下不生效。**
          maximum: 1
          default: 1
          example: 1
        top_logprobs:
          type: integer
          description: 返回每个位置概率最高的若干候选 token 及其对数概率。
          minimum: 0
          maximum: 20
          example: 0
        reasoning:
          type: object
          description: >-
            思考模式配置。DeepSeek V4 默认开启思考，思考内容以 `reasoning` 输出项返回，其 token
            计入输出并按输出价计费。
          properties:
            effort:
              type: string
              description: |-
                推理强度

                - `none`：关闭思考，直接作答
                - `minimal` / `low` / `medium`：较低强度
                - `high`（默认）：常规深度推理
                - `xhigh` / `max`：最高强度，耗时与输出 token 显著增加
              enum:
                - none
                - minimal
                - low
                - medium
                - high
                - xhigh
                - max
              default: high
              example: high
            max_output_tokens:
              type:
                - integer
                - 'null'
              description: 思考阶段的输出 token 上限，留空表示不额外限制。
            summary:
              type: string
              description: 可以传入，但不会生成思考摘要，字段无实际效果。
        text:
          type: object
          description: 文本输出格式配置。
          properties:
            format:
              type: object
              description: |-
                输出格式

                - `text`（默认）：自由文本
                - `json_object`：输出合法 JSON 对象，**提示词中必须出现 JSON 字样**
                - `json_schema`：按给定 JSON Schema 输出，需同时提供 `name` 与 `schema`
              properties:
                type:
                  type: string
                  enum:
                    - text
                    - json_object
                    - json_schema
                  default: text
                  description: 输出格式类型
                name:
                  type: string
                  description: Schema 名称，`json_schema` 模式必填
                schema:
                  type: object
                  description: JSON Schema 定义，`json_schema` 模式必填
                strict:
                  type: boolean
                  description: 是否严格遵循 Schema
        tools:
          type: array
          description: >-
            可供模型调用的工具列表。函数工具由客户端执行并把结果以 `function_call_output` 回传；`web_search`
            由服务端直接执行，无需客户端参与。
          items:
            $ref: '#/components/schemas/Tool'
        tool_choice:
          type:
            - string
            - object
          description: |-
            工具调用策略

            - `none`：禁止调用工具
            - `auto`（默认）：由模型决定
            - `required`：必须至少调用一个工具
            - `{"type": "function", "name": "get_weather"}`：强制调用指定函数
            - `{"type": "web_search"}`：强制执行联网搜索
          example: auto
    ResponsesResponse:
      type: object
      description: Responses 接口的响应对象。
      properties:
        id:
          type: string
          description: 本次响应的唯一标识
          example: resp_9f2c1a4b8e7d
        object:
          type: string
          description: 对象类型，固定为 `response`
          example: response
        created_at:
          type: integer
          description: 创建时间，Unix 时间戳（秒）
          example: 1755000000
        status:
          type: string
          description: |-
            响应状态

            - `completed`：正常完成
            - `in_progress`：生成中
            - `incomplete`：因长度等原因被截断，详见 `incomplete_details`
            - `failed`：生成失败，详见 `error`
          enum:
            - in_progress
            - completed
            - incomplete
            - failed
          example: completed
        model:
          type: string
          description: 实际生成本次响应的模型 ID
          example: deepseek-v4-flash
        output:
          type: array
          description: >-
            输出项列表，按生成顺序排列。各类型的字段：


            - `reasoning`：思考过程，含 `id`、`status`、`content`（`reasoning_text`
            块列表）、`summary`

            - `message`：最终回答，含 `id`、`status`、`role`、`content`（`output_text` 块列表）

            - `function_call`：模型发起的函数调用，含
            `id`、`status`、`call_id`、`name`、`arguments`，需客户端执行后以
            `function_call_output` 回传

            - `web_search_call`：服务端执行的联网搜索记录，含 `id`、`status`、`action`（描述本次搜索动作）
          items:
            type: object
        error:
          type:
            - object
            - 'null'
          description: 失败原因，成功时为 `null`
        incomplete_details:
          type:
            - object
            - 'null'
          description: 截断原因，未截断时为 `null`
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      description: 错误响应
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP 状态码
              example: 400
            message:
              type: string
              description: 错误描述
              example: Invalid request parameters
            type:
              type: string
              description: 错误类型
              example: invalid_request_error
    InputItem:
      type: object
      title: 输入项
      description: '`input` 数组中的单个输入项。`type` 决定该项的语义。'
      required:
        - type
      properties:
        type:
          type: string
          description: |-
            输入项类型

            - `message`：一条对话消息
            - `function_call`：历史中模型发起的函数调用
            - `function_call_output`：函数执行结果
            - `reasoning`：历史思考内容
            - `web_search_call`：历史联网搜索记录
          enum:
            - message
            - function_call
            - function_call_output
            - reasoning
            - web_search_call
          example: message
        role:
          type: string
          description: '消息角色，仅 `type: message` 使用。`developer` 按 `system` 处理。'
          enum:
            - user
            - assistant
            - system
            - developer
          example: user
        content:
          type:
            - string
            - array
          description: >-
            消息内容，仅 `type: message` 使用。可以是纯文本，也可以是内容块数组，输入侧内容块类型为
            `input_text`。**`input_image` 等图片、文件内容块不会报错，但会被替换为占位文本**，DeepSeek V4
            不具备视觉能力。
          example: 用一句话介绍杭州。
        call_id:
          type: string
          description: 函数调用标识，`function_call` 与 `function_call_output` 通过它配对。
        name:
          type: string
          description: '被调用的函数名，仅 `type: function_call` 使用。'
        arguments:
          type: string
          description: '函数调用参数，JSON 字符串，仅 `type: function_call` 使用。'
        output:
          type: string
          description: '函数执行结果，仅 `type: function_call_output` 使用。'
    Tool:
      type: object
      title: 工具定义
      required:
        - type
      properties:
        type:
          type: string
          description: >-
            工具类型


            - `function`：客户端执行的自定义函数

            - `web_search` / `web_search_2025_08_26`：服务端执行的联网搜索，会忽略
            `search_context_size` 与 `user_location`

            - `custom`：仅支持 `apply_patch`


            `file_search`、`code_interpreter`、`mcp` 会被忽略。
          enum:
            - function
            - web_search
            - web_search_2025_08_26
            - custom
          example: function
        name:
          type: string
          description: 工具名称，最长 128 字符，仅允许字母、数字、`-` 与 `_`，同一请求内不可重复。
          maxLength: 128
          example: get_weather
        description:
          type: string
          description: 工具用途说明，写清楚有助于模型判断何时调用。
          example: 查询指定城市的实时天气
        parameters:
          type: object
          description: 参数定义，JSON Schema 格式。
          example:
            type: object
            properties:
              city:
                type: string
                description: 城市名称
            required:
              - city
    Usage:
      type: object
      description: Token 使用统计信息（含缓存与推理分项）
      properties:
        input_tokens:
          type: integer
          description: 输入 token 总数（含缓存命中与未命中）
          example: 694
        input_tokens_details:
          type: object
          description: 输入 token 详细分项
          properties:
            cached_tokens:
              type: integer
              description: >-
                命中上下文缓存的 token 数量


                **说明**：命中部分按**缓存命中价**计费（Flash 2 UC/1K，Pro 3 UC/1K），未命中部分 =
                `input_tokens - cached_tokens`，按**标准输入价**计费（Flash 100 UC/1K，Pro
                300 UC/1K）
              example: 640
        output_tokens:
          type: integer
          description: 输出 token 数量（含思考部分）
          example: 20
        output_tokens_details:
          type: object
          description: 输出 token 详细分项
          properties:
            reasoning_tokens:
              type: integer
              description: 思考模式产生的推理 token 数量（计入输出，按输出价计费）
              example: 10
        total_tokens:
          type: integer
          description: 总 token 数量 = input_tokens + output_tokens
          example: 714
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |-
        ##所有接口均需要使用 Bearer Token 进行认证##

        **获取 API Key**：

        访问 [API Key 管理页面](https://evolink.ai/dashboard/keys) 获取您的 API Key

        **使用时在请求头中添加**：
        ```
        Authorization: Bearer YOUR_API_KEY
        ```

````