> ## 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 全模型接口 - Chat Completions 完整参数

> 使用 OpenAI Chat Completions 格式调用 Kimi 系列模型，支持普通 JSON 和 SSE 流式响应。多轮对话请完整保留 assistant 消息中的 reasoning_content 和 tool_calls。

联网搜索返回 tool_calls 时，将每个调用的 function.arguments 作为相同 tool_call_id 的 tool 消息内容回传，继续请求以生成最终回答。

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


## OpenAPI

````yaml cn/api-manual/language-series/kimi/chat-completions/chat-completions-reference.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: Kimi 全模型接口 - Chat Completions 完整参数
  description: >-
    通过 OpenAI Chat Completions 协议调用 Kimi 系列文本模型，用 `model` 参数选择
    `kimi-k3.1-pro`、`kimi-k3.1-pro-highspeed` 或 `kimi-k3`。上下文窗口均为 1,048,576
    tokens，支持多轮对话、流式输出、工具调用、联网搜索、结构化输出和图片、视频输入。


    三个模型始终开启思考，推理内容通过 `reasoning_content` 返回。思考强度和缓存写入时长因模型而异，见 `model`
    字段说明。多轮对话时请保留完整的思考与工具调用历史。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
tags:
  - name: Chat Completions
    description: OpenAI Chat Completions 兼容接口
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions
      summary: Kimi 对话接口（全模型，OpenAI 兼容）
      description: >-
        使用 OpenAI Chat Completions 格式调用 Kimi 系列模型，支持普通 JSON 和 SSE 流式响应。多轮对话请完整保留
        assistant 消息中的 reasoning_content 和 tool_calls。


        联网搜索返回 tool_calls 时，将每个调用的 function.arguments 作为相同 tool_call_id 的 tool
        消息内容回传，继续请求以生成最终回答。
      operationId: createChatCompletionKimi
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              simple:
                summary: Pro 最小请求
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: Reply with OK.
                  reasoning_effort: low
                  max_completion_tokens: 1024
              highspeed:
                summary: Highspeed 最小请求
                value:
                  model: kimi-k3.1-pro-highspeed
                  messages:
                    - role: user
                      content: Reply with OK.
                  reasoning_effort: low
                  max_completion_tokens: 1024
              k3:
                summary: Kimi K3 最小请求
                value:
                  model: kimi-k3
                  messages:
                    - role: user
                      content: Reply with OK.
                  max_completion_tokens: 1024
              streaming:
                summary: SSE 流式输出
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: Reply with OK.
                  reasoning_effort: low
                  max_completion_tokens: 1024
                  stream: true
              multimodal:
                summary: 图片输入
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content:
                        - type: image_url
                          image_url:
                            url: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...
                        - type: text
                          text: 请描述这张图片。
                  reasoning_effort: low
                  max_completion_tokens: 1024
              function_calling:
                summary: Function Calling
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: 查询北京今天的天气。
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: 查询指定城市的天气
                        parameters:
                          type: object
                          properties:
                            city:
                              type: string
                              description: 城市名称
                          required:
                            - city
                  tool_choice: auto
              web_search:
                summary: 联网搜索（统一写法）
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: Use web search to find the official Kimi homepage URL.
                  reasoning_effort: low
                  max_completion_tokens: 1024
                  tools:
                    - type: web_search
              structured_output:
                summary: 严格 JSON Schema
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: Return a JSON object with result equal to OK.
                  reasoning_effort: low
                  max_completion_tokens: 1024
                  response_format:
                    type: json_schema
                    json_schema:
                      name: result
                      strict: true
                      schema:
                        type: object
                        properties:
                          result:
                            type: string
                        required:
                          - result
                        additionalProperties: false
              cache_1h:
                summary: 1h 自动缓存写入（仅 K3.1 系列）
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: Reply with OK.
                  reasoning_effort: low
                  max_completion_tokens: 1024
                  prompt_cache_options:
                    mode: implicit
                    ttl: 1h
      responses:
        '200':
          description: 对话补全响应；流式请求返回 SSE 事件流
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
            text/event-stream:
              schema:
                type: string
                description: 'OpenAI Chat Completions 格式的 SSE 数据，以 `data: [DONE]` 结束。'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      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` | 最新一代模型（推荐） | `low` / `high` / `max`，默认 `max` |

            | `kimi-k3.1-pro-highspeed` | 与 Pro 参数相同，生成速度更快 | 同 `kimi-k3.1-pro`
            |

            | `kimi-k3` | 上一代模型 | 仅支持 `max` |


            三个模型的上下文窗口均为 1,048,576 tokens，均始终开启思考。


            缓存写入时长（`prompt_cache_options`）仅 K3.1 系列支持，`kimi-k3` 不支持此参数。
        messages:
          type: array
          minItems: 1
          description: 对话消息。多轮对话需完整回传历史 assistant message。
          items:
            $ref: '#/components/schemas/ChatMessage'
        max_completion_tokens:
          type: integer
          minimum: 1
          maximum: 1048576
          default: 131072
          description: 最大生成 Token 数，包含思考与最终回答；默认 131072，最大 1048576，同时受剩余上下文限制。
        reasoning_effort:
          type: string
          enum:
            - low
            - high
            - max
            - medium
            - xhigh
            - minimal
            - none
          default: max
          description: >-
            思考强度，模型始终思考。


            - `kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed`：推荐 `low` / `high` /
            `max`，默认 `max`。兼容通用客户端：`medium` 按 `high`，`xhigh` 按 `max`，`minimal` /
            `none` 按 `low` 处理；`none` 不会关闭思考。

            - `kimi-k3`：仅支持 `max`（默认）。


            提高强度通常增加推理 Token 和延迟，思考 Token 计入输出。
        stream:
          type: boolean
          default: false
          description: 是否使用 SSE 流式返回。
        tools:
          type: array
          maxItems: 128
          description: 函数工具或联网搜索工具。联网搜索使用 {"type":"web_search"}。
          items:
            oneOf:
              - $ref: '#/components/schemas/FunctionTool'
              - $ref: '#/components/schemas/WebSearchTool'
        tool_choice:
          oneOf:
            - type: string
              enum:
                - auto
                - none
                - required
            - $ref: '#/components/schemas/NamedToolChoice'
          description: 控制模型是否调用工具，或强制调用指定函数。
        prompt_cache_options:
          type: object
          description: >-
            上下文缓存写入选项，仅 `kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed` 支持，`kimi-k3`
            不支持此参数。省略时默认自动写入 5m 缓存；写入、读取分别计费。
          properties:
            mode:
              type: string
              enum:
                - implicit
              default: implicit
            ttl:
              type: string
              enum:
                - 5m
                - 1h
              default: 5m
              description: 缓存有效期，可选 5m 或 1h，默认 5m。
        response_format:
          type: object
          description: >-
            输出格式：text 为普通文本，json_object 返回 JSON 对象，json_schema 按指定的 JSON Schema
            生成结构化结果。
          properties:
            type:
              type: string
              enum:
                - text
                - json_object
                - json_schema
              description: >-
                输出格式类型。text：默认，纯文本输出；json_object：保证输出为合法 JSON 对象；json_schema：按指定
                JSON Schema 约束输出（推荐，需配合 json_schema 字段使用）
            json_schema:
              type: object
              description: 当 type 为 json_schema 时使用，定义输出应遵循的 JSON Schema
              properties:
                name:
                  type: string
                  description: Schema 名称，用于标识
                strict:
                  type: boolean
                  default: true
                  description: 是否严格遵循指定的 JSON Schema，默认 true。
                schema:
                  type: object
                  description: 定义输出结构的 JSON Schema。
                  additionalProperties: true
              required:
                - name
                - schema
        max_tokens:
          type: integer
          minimum: 1
          maximum: 1048576
          deprecated: true
          description: 兼容旧客户端的输出上限别名；新请求使用 max_completion_tokens，避免同时设置。
        temperature:
          type: number
          default: 1
          description: >-
            采样温度，由模型固定为 `1`，无需传入。`kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed`
            会自动忽略此字段；`kimi-k3` 传入不支持的取值将返回错误。
        top_p:
          type: number
          default: 0.95
          description: >-
            核采样阈值，由模型固定为 `0.95`，无需传入。`kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed`
            会自动忽略此字段；`kimi-k3` 传入不支持的取值将返回错误。
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: chat.completion
        created:
          type: integer
        model:
          type: string
          example: kimi-k3.1-pro
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                $ref: '#/components/schemas/ChatMessage'
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - tool_calls
        usage:
          $ref: '#/components/schemas/ChatUsage'
    ChatMessage:
      type: object
      required:
        - role
      properties:
        role:
          type: string
          description: 消息角色：system、user、assistant 或 tool。
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          description: >-
            消息内容。纯文本时传字符串；多模态输入时传内容块数组（文本 + 图片 + 视频）。工具调用场景下 assistant content
            可以为 null。
          oneOf:
            - type: string
              description: 纯文本消息内容。
            - type: array
              description: 多模态内容块数组。
              items:
                $ref: '#/components/schemas/ContentPart'
            - type: 'null'
        reasoning_content:
          type: string
          description: assistant 的推理内容。多轮对话时应与完整 assistant message 一起原样回传。
        tool_calls:
          type: array
          description: assistant 返回的工具调用列表；多轮工具调用时需原样回传。
          items:
            $ref: '#/components/schemas/ToolCall'
        tool_call_id:
          type: string
          description: '`role=tool` 时对应的工具调用 ID。'
    FunctionTool:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          description: 工具类型，当前固定为 function。
          enum:
            - function
        function:
          type: object
          description: 可供模型调用的函数定义。
          required:
            - name
            - parameters
          properties:
            name:
              type: string
              description: 函数名称。
            description:
              type: string
              description: 函数用途说明，帮助模型判断何时调用。
            parameters:
              type: object
              additionalProperties: true
              description: JSON Schema 格式的函数参数定义。
            strict:
              type: boolean
              description: 是否要求工具参数严格遵循 parameters 中的 JSON Schema。
    WebSearchTool:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - web_search
          description: 联网搜索工具。
    NamedToolChoice:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          description: 指定工具选择类型，固定为 function。
          enum:
            - function
        function:
          type: object
          description: 要强制调用的函数。
          required:
            - name
          properties:
            name:
              type: string
              description: 要强制调用的函数名称。
    ChatUsage:
      type: object
      properties:
        prompt_tokens:
          type: integer
          description: >-
            总输入 Token，包含普通输入、缓存读取和缓存写入。K3.1
            系列普通输入=prompt_tokens-cached_tokens-cache_write_tokens；`kimi-k3`
            普通输入=prompt_tokens-cached_tokens。
        completion_tokens:
          type: integer
          description: 包含推理 Token。
        total_tokens:
          type: integer
          description: 输入与输出 Token 总数。
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              description: 缓存命中的输入 Token。
            cache_write_tokens:
              type: integer
              minimum: 0
              description: >-
                本次缓存写入 Token 总数，包含 5m / 1h 写入。K3.1 系列单独计费，不再重复计入普通输入费；`kimi-k3`
                不单独区分，按普通输入计费。
        completion_tokens_details:
          type: object
          properties:
            reasoning_tokens:
              type: integer
              description: 推理 Token，已包含在 completion_tokens 中。
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type:
                - string
                - 'null'
    ContentPart:
      description: 多模态内容块。`type` 决定使用哪个字段。
      oneOf:
        - type: object
          required:
            - type
            - text
          properties:
            type:
              type: string
              enum:
                - text
            text:
              type: string
              description: '`type=text` 时的文本内容。'
        - type: object
          required:
            - type
            - image_url
          properties:
            type:
              type: string
              enum:
                - image_url
            image_url:
              description: '`type=image_url` 时的图片；也可直接传 URL 字符串。'
              oneOf:
                - type: string
                - type: object
                  required:
                    - url
                  properties:
                    url:
                      type: string
                      description: 图片内容，支持 Base64 Data URL（data:image/png;base64,...）。
        - type: object
          required:
            - type
            - video_url
          properties:
            type:
              type: string
              enum:
                - video_url
            video_url:
              description: '`type=video_url` 时的视频；也可直接传 URL 字符串。'
              oneOf:
                - type: string
                - type: object
                  required:
                    - url
                  properties:
                    url:
                      type: string
                      description: 视频内容，支持 Base64 Data URL（data:video/mp4;base64,...）。
    ToolCall:
      type: object
      required:
        - id
        - type
        - function
      properties:
        id:
          type: string
          description: 工具调用 ID，提交 tool 消息时通过 tool_call_id 关联。
        type:
          type: string
          description: 工具调用类型：客户端函数为 `function`；内置 `$web_search` 为 `builtin_function`。
          enum:
            - function
            - builtin_function
        function:
          type: object
          description: 模型请求调用的函数及参数。
          properties:
            name:
              type: string
              description: 函数名称。
            arguments:
              type: string
              description: JSON 字符串形式的函数参数。
      description: 多轮对话时完整保留工具调用，包括 ID、类型、函数名、参数和思考内容。
  responses:
    BadRequest:
      description: 请求参数错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: API Key 无效或缺失
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: 请求过于频繁或额度不足
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: 服务内部错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  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.