> ## 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.

# Kimi 全模型接口 - Responses 快速开始

> 使用 `model` 与 `input` 调用 Kimi，支持 `kimi-k3.1-pro`、`kimi-k3.1-pro-highspeed` 与 `kimi-k3`。设置 `max_output_tokens` 时建议从 1024 起，为思考和正文预留空间。

更多示例与模型差异见[完整参数](/cn/api-manual/language-series/kimi/responses/responses-reference)页。

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

使用 `POST /v1/responses`，通过 `model` 选择 `kimi-k3.1-pro`、`kimi-k3.1-pro-highspeed` 或 `kimi-k3`。最少需要 `model` 和 `input`。

> [!WARNING]
>
> **参数名称与 Chat Completions 不同**：输入使用 `input`，输出上限使用 `max_output_tokens`，思考强度使用 `reasoning.effort`。

## 读取正文

响应的 `output` 可能同时包含推理、正文和工具调用。遍历 `type="message"` 中的 `output_text` 内容块，不要假设第一项就是正文。

假设已将响应 JSON 解析为 `response`，可以这样提取文本：

```python theme={null}
text = "".join(
    part["text"]
    for item in response.get("output", [])
    if item.get("type") == "message"
    for part in item.get("content", [])
    if part.get("type") == "output_text"
)
print(text)
```

> [!NOTE]
>
> **为思考预留输出预算**：`max_output_tokens` 包含思考与正文。若 `status="incomplete"` 且 `incomplete_details.reason="max_output_tokens"`，请调高上限；预算耗尽时可能只有推理项，没有正文。

工具调用、联网搜索、图片输入与结构化输出，请查看[完整参数文档](https://evolink.ai/docs/cn/api-manual/language-series/kimi/responses/responses-reference.md)。


## OpenAPI

````yaml cn/api-manual/language-series/kimi/responses/responses-quickstart.json POST /v1/responses
openapi: 3.1.0
info:
  title: Kimi 全模型接口 - Responses 快速开始
  description: >-
    通过 OpenAI Responses 协议调用 Kimi 系列文本模型的快速开始示例。最少只需 `model` 与 `input`
    两个参数即可发起对话；工具调用、联网搜索、结构化输出、图片输入等请查看「完整参数」页。
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
paths:
  /v1/responses:
    post:
      tags:
        - Responses
      summary: Kimi Responses 快速调用
      description: >-
        使用 `model` 与 `input` 调用 Kimi，支持
        `kimi-k3.1-pro`、`kimi-k3.1-pro-highspeed` 与 `kimi-k3`。设置
        `max_output_tokens` 时建议从 1024 起，为思考和正文预留空间。


        更多示例与模型差异见[完整参数](/cn/api-manual/language-series/kimi/responses/responses-reference)页。
      operationId: kimiResponsesQuick
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesQuickRequest'
            examples:
              simple:
                summary: Pro 最小请求
                value:
                  model: kimi-k3.1-pro
                  input: 用一句话解释什么是上下文缓存。
              highspeed:
                summary: Highspeed 低思考强度
                value:
                  model: kimi-k3.1-pro-highspeed
                  input: 用一句话解释什么是上下文缓存。
                  reasoning:
                    effort: low
                  max_output_tokens: 1024
              k3:
                summary: Kimi K3 最小请求
                value:
                  model: kimi-k3
                  input: 用一句话解释什么是上下文缓存。
              multi_turn:
                summary: 系统指令与多轮对话
                value:
                  model: kimi-k3.1-pro
                  input:
                    - role: developer
                      content: 你是一名严谨的中文技术编辑，回答简洁。
                    - role: user
                      content: 什么是上下文缓存？
                    - role: assistant
                      content: 上下文缓存会保存请求中重复出现的前缀内容，后续请求命中时可以更快、更省地处理。
                    - role: user
                      content: 它适合哪些场景？
                  reasoning:
                    effort: low
                  max_output_tokens: 2048
              streaming:
                summary: SSE 流式输出
                value:
                  model: kimi-k3.1-pro
                  input: 写一首关于夏夜的四行短诗。
                  reasoning:
                    effort: low
                  max_output_tokens: 2048
                  stream: true
      responses:
        '200':
          description: 响应创建成功；流式请求返回 SSE 事件流
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
            text/event-stream:
              schema:
                type: string
                description: >-
                  Responses 格式的 SSE 事件流，以
                  `response.completed`、`response.incomplete` 或 `response.failed`
                  事件结束。
        '400':
          description: 请求错误 - 参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权 - API 密钥无效或缺失
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: 请求过于频繁或额度不足
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 服务器错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ResponsesQuickRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - kimi-k3.1-pro
            - kimi-k3.1-pro-highspeed
            - kimi-k3
          default: kimi-k3.1-pro
          description: |-
            要调用的模型：

            | 模型 ID | 定位 |
            |---|---|
            | `kimi-k3.1-pro` | 最新一代模型（推荐） |
            | `kimi-k3.1-pro-highspeed` | 与 Pro 参数相同，生成速度更快 |
            | `kimi-k3` | 上一代模型 |

            三个模型的上下文窗口均为 1,048,576 tokens，均始终开启思考。
        input:
          description: 本次请求的输入。传字符串等价于一条 user 消息；传数组时按顺序给出历史消息。
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/InputMessage'
        max_output_tokens:
          type: integer
          minimum: 1
          maximum: 1048576
          default: 131072
          description: 最大生成 Token 数，包含思考与最终回答；默认 131072，最大 1048576。
        reasoning:
          type: object
          description: 推理相关配置。
          properties:
            effort:
              type: string
              enum:
                - low
                - high
                - max
              default: max
              description: 思考强度，默认 `max`。`kimi-k3` 仅支持 `max`；其他兼容取值见完整参数页。
        stream:
          type: boolean
          default: false
          description: 为 true 时以 SSE 事件流返回响应。
    ResponsesResponse:
      type: object
      properties:
        id:
          type: string
          description: 响应 ID。
          example: resp_6adc72aab1f2eaaebe6b869e
        object:
          type: string
          enum:
            - response
          example: response
        created_at:
          type: integer
          description: 创建时间，Unix 时间戳（秒）。
          example: 1792832171
        status:
          type: string
          enum:
            - completed
            - incomplete
            - failed
          description: 响应状态。`incomplete` 通常表示达到 `max_output_tokens` 上限。
          example: completed
        incomplete_details:
          type:
            - object
            - 'null'
          description: '`status` 为 `incomplete` 时给出原因。'
          properties:
            reason:
              type: string
              enum:
                - max_output_tokens
                - content_filter
        model:
          type: string
          description: 本次调用的模型。
          example: kimi-k3.1-pro
        output:
          type: array
          description: 输出项数组，通常先是 reasoning，再是 message。
          items:
            $ref: '#/components/schemas/OutputItem'
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: 描述错误原因的错误消息
            type:
              type: string
              description: 错误类型
            code:
              type: string
              description: 错误码
          required:
            - message
      required:
        - error
    InputMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - developer
          description: 消息角色。`developer` 按系统指令处理。
        content:
          type: string
          description: 消息内容（纯文本）。
          example: 用一句话解释什么是上下文缓存。
    OutputItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - reasoning
            - message
          description: '`reasoning` 为推理内容，`message` 为最终回答。'
          example: message
        id:
          type: string
          example: msg_6adc72aab1f2eaaebe6b869f
        summary:
          type: array
          description: '`type=reasoning` 时的推理内容。'
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - summary_text
              text:
                type: string
        role:
          type: string
          enum:
            - assistant
          description: '`type=message` 时返回。'
        content:
          type: array
          description: '`type=message` 时的回答内容。'
          items:
            $ref: '#/components/schemas/OutputText'
        status:
          type: string
          enum:
            - completed
          example: completed
    Usage:
      type: object
      properties:
        input_tokens:
          type: integer
          description: 输入 Token，包含缓存命中部分。
          example: 24
        input_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              description: 缓存命中的输入 Token。
              example: 0
        output_tokens:
          type: integer
          description: 输出 Token，包含推理 Token。
          example: 96
        output_tokens_details:
          type: object
          properties:
            reasoning_tokens:
              type: integer
              description: 推理 Token，已包含在 output_tokens 中。
              example: 62
        total_tokens:
          type: integer
          description: 输入与输出 Token 总数。
          example: 120
    OutputText:
      type: object
      properties:
        type:
          type: string
          enum:
            - output_text
          example: output_text
        text:
          type: string
          example: 上下文缓存会保存请求中重复出现的前缀内容，后续请求命中时可以更快、更省地处理。
  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
        ```

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.