> ## 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 API (All Models) - Messages Full Reference

> Public endpoint: POST /v1/messages. Set reasoning effort with output_config.effort. Top-level cache_control controls 5m/1h cache writes (K3.1 series only). Preserve all thinking, signature, tool_use, and server-side search result blocks.

> [!NOTE]
>
> **BaseURL**: The default BaseURL is `https://direct.evolink.ai`, which has better support for text models and long-lived connections. `https://api.evolink.ai` is the primary endpoint for multimodal services and serves as a fallback address for text models.


## OpenAPI

````yaml en/api-manual/language-series/kimi/messages/messages-reference.json POST /v1/messages
openapi: 3.1.0
info:
  title: Kimi API (All Models) - Messages Full Reference
  description: >-
    Call Kimi text models through the Anthropic Messages protocol. Use `model`
    to select `kimi-k3.1-pro`, `kimi-k3.1-pro-highspeed`, or `kimi-k3`. All have
    a context window of 1,048,576 tokens and support multi-turn conversations,
    streaming, tool calling, web search, and image input.


    Reasoning is always enabled for all three models; adjust its intensity with
    `output_config.effort`. Structured output, stop sequences, and cache write
    TTL are supported only by the K3.1 series; see the `model` field. In
    multi-turn conversations, return complete assistant content blocks
    unchanged, including thinking, signature, and tool_use.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: Production (Recommended)
  - url: https://api.evolink.ai
    description: Alternative URL
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Anthropic Messages-compatible API
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: Kimi Messages API (all models, Anthropic-compatible)
      description: >-
        Public endpoint: POST /v1/messages. Set reasoning effort with
        output_config.effort. Top-level cache_control controls 5m/1h cache
        writes (K3.1 series only). Preserve all thinking, signature, tool_use,
        and server-side search result blocks.
      operationId: createMessageKimi
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMessageRequest'
            examples:
              simple:
                summary: Minimal Pro request
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 1024
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: Reply with OK.
              highspeed:
                summary: Minimal Highspeed request
                value:
                  model: kimi-k3.1-pro-highspeed
                  max_tokens: 1024
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: Reply with OK.
              k3:
                summary: Minimal Kimi K3 request
                value:
                  model: kimi-k3
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: Reply with OK.
              system_prompt:
                summary: System prompt
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 2048
                  output_config:
                    effort: low
                  system: You are a precise technical editor.
                  messages:
                    - role: user
                      content: Explain context caching.
              streaming:
                summary: Anthropic SSE streaming
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 1024
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: Reply with OK.
                  stream: true
              multimodal:
                summary: Image input
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 1024
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content:
                        - type: image
                          source:
                            type: base64
                            media_type: image/jpeg
                            data: /9j/4AAQSkZJRgABAQAA...
                        - type: text
                          text: Describe this image.
              tool_use:
                summary: Tool use
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 2048
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: Check today's weather in Beijing.
                  tools:
                    - name: get_weather
                      description: Get the weather for a specified city
                      input_schema:
                        type: object
                        properties:
                          city:
                            type: string
                            description: City name
                        required:
                          - city
                  tool_choice:
                    type: auto
              web_search:
                summary: Server-side web search
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 1024
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: Use web search to find the official Kimi homepage URL.
                  tools:
                    - type: web_search_20250305
                      name: web_search
                      max_uses: 1
              structured_output:
                summary: Strict structured output (K3.1 series only)
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 1024
                  output_config:
                    effort: low
                    format:
                      type: json_schema
                      schema:
                        type: object
                        properties:
                          result:
                            type: string
                        required:
                          - result
                        additionalProperties: false
                  messages:
                    - role: user
                      content: Return a JSON object with result equal to OK.
              cache_1h:
                summary: Top-level 1h cache (K3.1 series only)
                value:
                  model: kimi-k3.1-pro
                  max_tokens: 1024
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: Reply with OK.
                  cache_control:
                    type: ephemeral
                    ttl: 1h
      responses:
        '200':
          description: >-
            Message response; streaming requests return an Anthropic SSE event
            stream
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
            text/event-stream:
              schema:
                type: string
                description: >-
                  The event sequence typically includes message_start,
                  content_block_*, message_delta, and message_stop.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    CreateMessageRequest:
      type: object
      required:
        - model
        - max_tokens
        - messages
      properties:
        model:
          type: string
          enum:
            - kimi-k3.1-pro
            - kimi-k3.1-pro-highspeed
            - kimi-k3
          default: kimi-k3.1-pro
          description: >-
            Model to call:


            | Model ID | Positioning | Reasoning effort |

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

            | `kimi-k3.1-pro` | Latest-generation model (recommended) | `low` /
            `high` / `max`, default `max` |

            | `kimi-k3.1-pro-highspeed` | Same parameters as Pro, faster
            generation | Same as `kimi-k3.1-pro` |

            | `kimi-k3` | Previous-generation model | Only `max` |


            All three models have a context window of 1,048,576 tokens and
            always have reasoning enabled.


            Structured output (`output_config.format`), stop sequences
            (`stop_sequences`), and cache write TTL (`cache_control`) are
            supported only by the K3.1 series, not by `kimi-k3`. Responses from
            `kimi-k3` may contain only `text` blocks without `thinking` blocks.
        max_tokens:
          type: integer
          minimum: 1
          description: >-
            Maximum number of tokens allowed for this generation, including
            thinking and final text.
          maximum: 1048576
        messages:
          type: array
          minItems: 1
          description: >-
            Anthropic Messages message list. For multi-turn conversations,
            return complete assistant content blocks unchanged.
          items:
            $ref: '#/components/schemas/Message'
        system:
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/MessagesTextBlockParam'
          description: System prompt as a string or array of text blocks.
        stream:
          type: boolean
          default: false
          description: Whether to return an Anthropic SSE event stream.
        tools:
          type: array
          description: >-
            Custom functions or server-side web search. Built-in search uses
            type=web_search_20250305 and name=web_search; billed per actual
            call.
          items:
            oneOf:
              - $ref: '#/components/schemas/Tool'
              - $ref: '#/components/schemas/WebSearchTool'
        tool_choice:
          $ref: '#/components/schemas/ToolChoice'
        stop_sequences:
          type: array
          items:
            type: string
          maxItems: 5
          description: >-
            Stop sequences. Output stops on an exact match, and the matched
            sequence itself is omitted. Up to 5 sequences, each no more than 32
            bytes. On a match, `stop_reason` is `end_turn` and `stop_sequence`
            is `null`.


            Supported only by `kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed`;
            `kimi-k3` does not support this parameter.
        cache_control:
          type: object
          description: >-
            Top-level cache write options, supported only by `kimi-k3.1-pro` /
            `kimi-k3.1-pro-highspeed`; `kimi-k3` does not support this
            parameter. Only top-level cache_control controls the write TTL;
            cache markers inside message blocks cannot replace this field.
            Defaults to 5m when omitted.
          properties:
            type:
              type: string
              enum:
                - ephemeral
              description: Cache type; always ephemeral.
            ttl:
              type: string
              enum:
                - 5m
                - 1h
              default: 5m
              description: 'Cache TTL: 5m or 1h; default: 5m.'
          required:
            - type
        output_config:
          type: object
          description: 'Output configuration: reasoning effort and structured output.'
          properties:
            effort:
              type: string
              enum:
                - low
                - high
                - max
                - medium
                - xhigh
                - minimal
                - none
              default: max
              description: >-
                Reasoning effort. Reasoning is always enabled, even if
                `thinking.type: "disabled"` is passed.


                - `kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed`: `low` / `high` /
                `max` are recommended; default `max`. For generic client
                compatibility, `medium` maps to `high`, `xhigh` to `max`, and
                `minimal` / `none` to `low`; `none` does not disable reasoning.

                - `kimi-k3`: only `max` is supported (default).


                Higher effort typically increases reasoning tokens and latency.
                Reasoning tokens count toward output.
            format:
              type: object
              description: >-
                Structured output: the model returns JSON that strictly follows
                the specified JSON Schema. Supported only by `kimi-k3.1-pro` /
                `kimi-k3.1-pro-highspeed`; `kimi-k3` does not support it. For
                structured output with `kimi-k3`, use `response_format` in the
                Chat Completions API.
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                schema:
                  type: object
                  description: JSON Schema that the output must follow.
                  additionalProperties: true
              required:
                - type
                - schema
        temperature:
          type: number
          default: 1
          description: >-
            Sampling temperature, fixed by the model at `1`; omit this field.
            `kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed` automatically ignore it;
            `kimi-k3` returns an error for unsupported values.
        top_p:
          type: number
          default: 0.95
          description: >-
            Nucleus sampling threshold, fixed by the model at `0.95`; omit this
            field. `kimi-k3.1-pro` / `kimi-k3.1-pro-highspeed` automatically
            ignore it; `kimi-k3` returns an error for unsupported values.
    MessageResponse:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - message
        role:
          type: string
          enum:
            - assistant
        model:
          type: string
          example: kimi-k3.1-pro
        content:
          type: array
          items:
            $ref: '#/components/schemas/ContentBlock'
        stop_reason:
          type:
            - string
            - 'null'
          enum:
            - end_turn
            - max_tokens
            - tool_use
            - refusal
            - null
        stop_sequence:
          type:
            - string
            - 'null'
        usage:
          $ref: '#/components/schemas/MessageUsage'
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: Message role. Only user and assistant are supported.
          enum:
            - user
            - assistant
        content:
          description: >-
            Message content as either a plain text string or an array of
            Anthropic content blocks.
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentBlock'
    MessagesTextBlockParam:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
        text:
          type: string
      required:
        - type
        - text
    Tool:
      type: object
      required:
        - name
        - input_schema
      properties:
        name:
          type: string
          description: Tool name.
        description:
          type: string
          description: Description that helps the model decide when to use the tool.
        input_schema:
          type: object
          additionalProperties: true
          description: Tool parameter definition in JSON Schema format.
    WebSearchTool:
      type: object
      required:
        - type
        - name
      properties:
        type:
          type: string
          enum:
            - web_search_20250305
        name:
          type: string
          enum:
            - web_search
        max_uses:
          type: integer
          minimum: 1
          description: Maximum searches allowed for this response.
    ToolChoice:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          description: >-
            Tool choice: auto lets the model decide, any requires a tool call,
            and none disables tool calls.
          enum:
            - auto
            - any
            - none
          default: auto
    ContentBlock:
      description: >-
        Anthropic content block for text, image, reasoning, tool use, or a tool
        result.
      oneOf:
        - $ref: '#/components/schemas/TextBlock'
        - $ref: '#/components/schemas/ImageBlock'
        - $ref: '#/components/schemas/ThinkingBlock'
        - $ref: '#/components/schemas/ToolUseBlock'
        - $ref: '#/components/schemas/ToolResultBlock'
        - $ref: '#/components/schemas/ServerToolUseBlock'
        - $ref: '#/components/schemas/WebSearchResultBlock'
    MessageUsage:
      type: object
      properties:
        input_tokens:
          type: integer
          description: >-
            Ordinary input tokens, excluding cache reads and cache writes. The
            three input categories are mutually exclusive; do not subtract
            cached tokens again.
        cache_creation_input_tokens:
          type: integer
          description: Input tokens written to cache.
        cache_read_input_tokens:
          type: integer
          description: Input tokens served from cache.
        output_tokens:
          type: integer
          description: Output tokens, including thinking tokens.
        output_tokens_details:
          type: object
          properties:
            thinking_tokens:
              type: integer
        cache_creation:
          type: object
          properties:
            ephemeral_5m_input_tokens:
              type: integer
              minimum: 0
            ephemeral_1h_input_tokens:
              type: integer
              minimum: 0
          description: >-
            The two cache-write tiers within cache_creation_input_tokens. The
            K3.1 series bills each tier according to its actual TTL.
        server_tool_use:
          type: object
          properties:
            web_search_requests:
              type: integer
              minimum: 0
          description: Search usage for this response.
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - error
        error:
          type: object
          properties:
            type:
              type: string
            message:
              type: string
        request_id:
          type: string
    TextBlock:
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          description: Content block type. Fixed to text.
          enum:
            - text
        text:
          type: string
          description: Text content.
    ImageBlock:
      type: object
      required:
        - type
        - source
      description: Image content block (multimodal input).
      properties:
        type:
          type: string
          enum:
            - image
          description: Content block type. Fixed to image.
        source:
          type: object
          required:
            - type
          description: Image source.
          properties:
            type:
              type: string
              enum:
                - base64
                - url
              description: 'Image source: base64 for inline data, url for a file reference.'
            media_type:
              type: string
              enum:
                - image/jpeg
                - image/png
                - image/gif
                - image/webp
              description: Image MIME type when `type=base64`.
            data:
              type: string
              description: >-
                Base64 image data when `type=base64` (without the `data:`
                prefix).
            url:
              type: string
              description: Image file reference, used only when type=url.
    ThinkingBlock:
      type: object
      required:
        - type
        - thinking
      properties:
        type:
          type: string
          description: Content block type. Fixed to thinking.
          enum:
            - thinking
        thinking:
          type: string
          description: >-
            Model reasoning content. Return it unchanged together with the
            signature in multi-turn conversations.
        signature:
          type: string
          description: >-
            In multi-turn conversations, return this unchanged together with the
            thinking block.
    ToolUseBlock:
      type: object
      required:
        - type
        - id
        - name
        - input
      properties:
        type:
          type: string
          description: Content block type. Fixed to tool_use.
          enum:
            - tool_use
        id:
          type: string
          description: Tool use ID referenced by tool_use_id when returning the result.
        name:
          type: string
          description: Name of the tool requested by the model.
        input:
          type: object
          additionalProperties: true
          description: Tool input object generated by the model.
    ToolResultBlock:
      type: object
      required:
        - type
        - tool_use_id
        - content
      properties:
        type:
          type: string
          description: Content block type. Fixed to tool_result.
          enum:
            - tool_result
        tool_use_id:
          type: string
          description: ID of the corresponding tool_use content block.
        content:
          description: Tool result as a string or an array of text and image blocks.
          oneOf:
            - type: string
            - type: array
              items:
                oneOf:
                  - $ref: '#/components/schemas/TextBlock'
                  - $ref: '#/components/schemas/ImageBlock'
        is_error:
          type: boolean
          default: false
          description: Whether the tool execution failed.
    ServerToolUseBlock:
      type: object
      required:
        - type
        - id
        - name
        - input
      properties:
        type:
          type: string
          enum:
            - server_tool_use
        id:
          type: string
        name:
          type: string
        input:
          type: object
          additionalProperties: true
    WebSearchResultBlock:
      type: object
      required:
        - type
        - tool_use_id
        - content
      properties:
        type:
          type: string
          enum:
            - web_search_tool_result
        tool_use_id:
          type: string
        content:
          oneOf:
            - type: array
              items:
                type: object
                additionalProperties: true
            - type: object
              additionalProperties: true
              description: Search error object with type=web_search_tool_result_error.
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: API key is missing or invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Rate limit exceeded or insufficient quota
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Internal service error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##All APIs require Bearer Token authentication##


        **Get API Key:**


        Visit [API Key Management Page](https://evolink.ai/dashboard/keys) to
        get your API Key


        **Add to request header:**

        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````

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