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

# kimi-k3

> 根据对话历史生成 Kimi K3 响应。K3 支持 100 万 Token 上下文、文本/图片输入、 始终开启的思考、流式输出、结构化输出、Partial Mode 和函数工具。使用 reasoning_effort 配置推理强度；K2.x 的 thinking 对象不会生效。不要传入固定采样参数。

Kimi K3 支持 100 万 token 上下文、文本/图片输入、可配置强度的始终开启推理、流式输出、结构化输出、Partial Mode 和函数工具。

<Note>
  使用顶层 `reasoning_effort`；K2.x 的 `thinking` 对象不会生效。采样参数为固定值，请省略 `temperature`、`top_p`、`n`、`presence_penalty` 和 `frequency_penalty`。
</Note>


## OpenAPI

````yaml zh/api-reference/model-api/moonshot/openapi/kimi-k3/openapi.yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: Kimi K3
  description: 通过 AnyFast OpenAI 兼容接口调用 Kimi K3 旗舰多模态模型。
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: 创建对话补全
      description: >-
        根据对话历史生成 Kimi K3 响应。K3 支持 100 万 Token 上下文、文本/图片输入、
        始终开启的思考、流式输出、结构化输出、Partial Mode 和函数工具。使用 reasoning_effort 配置推理强度；K2.x 的
        thinking 对象不会生效。不要传入固定采样参数。
      operationId: createChatCompletionKimiK3
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  type: string
                  enum:
                    - kimi-k3
                  default: kimi-k3
                  description: 模型 ID，固定为 kimi-k3。
                messages:
                  type: array
                  minItems: 1
                  description: >-
                    对话历史。后续轮次必须完整传回 assistant 消息，包括 reasoning、reasoning_details
                    和 tool_calls。
                  items:
                    $ref: '#/components/schemas/Message'
                reasoning_effort:
                  type: string
                  enum:
                    - low
                    - high
                    - max
                  default: max
                  description: 控制推理强度。K3 始终开启思考与 Preserved Thinking，无法关闭思考。
                max_completion_tokens:
                  type: integer
                  minimum: 1
                  maximum: 1048576
                  default: 131072
                  description: 最大输出 Token 数。输入与输出之和不能超过 100 万 Token 上下文窗口。 max_tokens 已弃用。
                response_format:
                  $ref: '#/components/schemas/ResponseFormat'
                stop:
                  oneOf:
                    - type: string
                    - type: array
                      maxItems: 5
                      items:
                        type: string
                  description: 最多 5 个停止字符串，每个字符串不超过 32 字节。停止词可能在最终内容生成前终止推理。
                stream:
                  type: boolean
                  default: false
                  description: 是否通过 Server-Sent Events 流式返回增量内容。
                stream_options:
                  type: object
                  description: 流式响应选项。
                  properties:
                    include_usage:
                      type: boolean
                      default: false
                      description: 是否在最后一个流式分块中返回完整 Token 用量。
                tools:
                  type: array
                  description: 可供模型调用的函数工具列表。
                  items:
                    $ref: '#/components/schemas/ToolDefinition'
                tool_choice:
                  type: string
                  enum:
                    - auto
                    - none
                    - required
                  default: auto
                  description: 让模型自行决定、禁用工具调用，或要求至少调用一个工具。
                prompt_cache_key:
                  type: string
                  description: 稳定的会话或任务标识，用于提高前缀缓存命中率。
                safety_identifier:
                  type: string
                  description: 最终用户的稳定标识。建议使用哈希值，不要传入可直接识别用户的信息。
            examples:
              basic:
                summary: 基础请求
                value:
                  model: kimi-k3
                  messages:
                    - role: user
                      content: Explain Kimi K3 in one sentence.
                  reasoning_effort: max
              vision:
                summary: 图片输入
                value:
                  model: kimi-k3
                  messages:
                    - role: user
                      content:
                        - type: image_url
                          image_url:
                            url: data:image/png;base64,iVBORw0KGgo...
                        - type: text
                          text: Describe this image.
              structured:
                summary: 严格 JSON Schema
                value:
                  model: kimi-k3
                  messages:
                    - role: user
                      content: Lin is 28 years old. Extract the name and age.
                  response_format:
                    type: json_schema
                    json_schema:
                      name: person
                      strict: true
                      schema:
                        type: object
                        properties:
                          name:
                            type: string
                          age:
                            type: integer
                        required:
                          - name
                          - age
                        additionalProperties: false
      responses:
        '200':
          description: >-
            成功生成响应。stream 为 true 时通过 SSE 返回 chat.completion.chunk， 并以 data:
            [DONE] 结束。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
              example:
                id: cmpl-kimi-k3-example
                object: chat.completion
                created: 1784736000
                model: moonshotai/kimi-k3
                choices:
                  - index: 0
                    message:
                      role: assistant
                      reasoning: The user requested a concise introduction.
                      reasoning_details:
                        - type: reasoning.text
                          text: The user requested a concise introduction.
                          format: unknown
                          index: 0
                      content: >-
                        Kimi K3 is Moonshot AI's flagship multimodal reasoning
                        model with a 1M-token context window.
                    finish_reason: stop
                usage:
                  prompt_tokens: 18
                  completion_tokens: 32
                  total_tokens: 50
                  prompt_tokens_details:
                    cached_tokens: 0
        '400':
          description: 请求无效或参数值不受支持。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: API Key 缺失或无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: 超出请求频率或配额限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Message:
      type: object
      required:
        - role
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
          description: 消息角色。
        content:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentPart'
            - type: 'null'
          description: 纯文本，或由文本/图片组成的内容数组。
        name:
          type: string
          description: 可选的参与者名称。
        partial:
          type: boolean
          description: 在最后一条 assistant 消息中设为 true，使模型从已有内容前缀继续生成。
        reasoning:
          type: string
          description: K3 返回的推理内容。多轮对话中需原样保留并传回。
        reasoning_details:
          type: array
          description: 响应中返回的结构化推理详情。
          items:
            $ref: '#/components/schemas/ReasoningDetail'
        tool_calls:
          type: array
          description: assistant 消息返回的工具调用。
          items:
            $ref: '#/components/schemas/ToolCall'
        tool_call_id:
          type: string
          description: 工具结果消息必填，必须与对应工具调用 ID 一致。
    ResponseFormat:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
            - json_object
            - json_schema
          default: text
        json_schema:
          type: object
          description: type 为 json_schema 时必填。
          required:
            - name
            - schema
          properties:
            name:
              type: string
            strict:
              type: boolean
              default: true
            schema:
              type: object
              additionalProperties: true
    ToolDefinition:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          enum:
            - function
        function:
          type: object
          required:
            - name
            - parameters
          properties:
            name:
              type: string
              pattern: ^[a-zA-Z_][a-zA-Z0-9-_]{2,63}$
            description:
              type: string
            parameters:
              type: object
              description: 使用 JSON Schema 描述的函数参数。
              additionalProperties: true
    ChatCompletion:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - chat.completion
        created:
          type: integer
          description: Unix 时间戳。
        model:
          type: string
          description: 响应中可能返回上游规范模型 ID。
          example: moonshotai/kimi-k3
        provider:
          type: string
          example: Moonshot AI
        system_fingerprint:
          type:
            - string
            - 'null'
        service_tier:
          type:
            - string
            - 'null'
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                  content:
                    type:
                      - string
                      - 'null'
                  refusal:
                    type:
                      - string
                      - 'null'
                  reasoning:
                    type:
                      - string
                      - 'null'
                  reasoning_details:
                    type: array
                    items:
                      $ref: '#/components/schemas/ReasoningDetail'
                  tool_calls:
                    type: array
                    items:
                      $ref: '#/components/schemas/ToolCall'
              finish_reason:
                type:
                  - string
                  - 'null'
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
                  - null
              native_finish_reason:
                type:
                  - string
                  - 'null'
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
            message:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
    ContentPart:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - image_url
        text:
          type: string
          description: type 为 text 时必填。
        image_url:
          oneOf:
            - type: string
            - type: object
              required:
                - url
              properties:
                url:
                  type: string
          description: 公开图片 URL 或 Base64 Data URI。
    ReasoningDetail:
      type: object
      properties:
        type:
          type: string
          example: reasoning.text
        text:
          type: string
        format:
          type: string
          example: unknown
        index:
          type: integer
    ToolCall:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - function
        function:
          type: object
          properties:
            name:
              type: string
            arguments:
              type: string
              description: JSON 编码的函数参数。
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              description: 自动上下文缓存命中的 Token 数。
            cache_write_tokens:
              type: integer
            audio_tokens:
              type: integer
            video_tokens:
              type: integer
        completion_tokens_details:
          type: object
          properties:
            reasoning_tokens:
              type: integer
            image_tokens:
              type: integer
            audio_tokens:
              type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````