# Kimi K3.1 Pro

Use the public model ID `kimi-k3.1-pro`. The [model page](https://seedrouter.ai/models/kimi-k3-1-pro) provides the Playground and live prices. Download the [OpenAPI specification](https://seedrouter.ai/docs/kimi-k3-1-pro.openapi.json) for complete nested request and response schemas.

## Quick start

```bash
curl https://api.seedrouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model":"kimi-k3.1-pro",
    "messages":[{"role":"user","content":"How can an idempotency key prevent a duplicate payment?"}],
    "max_completion_tokens":2048,
    "reasoning_effort":"low"
  }'
```

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://api.seedrouter.ai/v1/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['SEEDROUTER_API_KEY']}",
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "model": "kimi-k3.1-pro",
        "messages": [{"role": "user", "content": "How can an idempotency key prevent a duplicate payment?"}],
        "max_completion_tokens": 2048,
        "reasoning_effort": "low",
    }).encode(),
    method="POST",
)
with urllib.request.urlopen(request, timeout=120) as response:
    result = json.load(response)
print(result["choices"][0]["message"]["content"])
```

```javascript
const response = await fetch('https://api.seedrouter.ai/v1/chat/completions', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SEEDROUTER_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'kimi-k3.1-pro',
    messages: [{ role: 'user', content: 'How can an idempotency key prevent a duplicate payment?' }],
    max_completion_tokens: 2048,
    reasoning_effort: 'low',
  }),
  signal: AbortSignal.timeout(120000),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const result = await response.json();
console.log(result.choices[0].message.content);
```

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
    "strings"
    "time"
)

func main() {
    body := strings.NewReader(`{
      "model": "kimi-k3.1-pro",
      "messages": [{"role": "user", "content": "How can an idempotency key prevent a duplicate payment?"}],
      "max_completion_tokens": 2048,
      "reasoning_effort": "low"
    }`)
    req, err := http.NewRequest("POST", "https://api.seedrouter.ai/v1/chat/completions", body)
    if err != nil { panic(err) }
    req.Header.Set("Authorization", "Bearer " + os.Getenv("SEEDROUTER_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    client := &http.Client{Timeout: 120 * time.Second}
    res, err := client.Do(req)
    if err != nil { panic(err) }
    defer res.Body.Close()
    if res.StatusCode != http.StatusOK { panic(res.Status) }
    data, err := io.ReadAll(res.Body)
    if err != nil { panic(err) }
    fmt.Println(string(data))
}
```

## Native formats

| Format           | Endpoint                    | Required fields                   |
| ---------------- | --------------------------- | --------------------------------- |
| Chat Completions | `POST /v1/chat/completions` | `model`, `messages`               |
| Responses        | `POST /v1/responses`        | `model`, `input`                  |
| Messages         | `POST /v1/messages`         | `model`, `messages`, `max_tokens` |

Use `Authorization: Bearer $SEEDROUTER_API_KEY`. Messages also uses `anthropic-version: 2023-06-01`. Each format returns native JSON or SSE events. Responses is stateless: replay complete history; `previous_response_id` is not a supported request field.

## Request parameters

Blank Playground fields are omitted. Explicit false and zero are preserved where valid. Omitted does not mean nullable. Unknown top-level extensions are discarded; invalid official fields are rejected. Nested tool schemas and returned history remain intact.

### Chat Completions

| Field                   | Type    | Required | Default / range                        |
| ----------------------- | ------- | -------- | -------------------------------------- |
| `logprobs`              | boolean | No       | default false                          |
| `top_logprobs`          | integer | No       | 0–20; requires logprobs=true           |
| `prediction`            | object  | No       | Omitted unless supplied                |
| `max_tokens`            | integer | No       | 1–1048576                              |
| `max_completion_tokens` | integer | No       | 1–1048576; default 131072              |
| `response_format`       | object  | No       | Omitted unless supplied                |
| `stop`                  | union   | No       | ≤5 strings; ≤32 UTF-8 bytes each       |
| `stream`                | boolean | No       | default false                          |
| `stream_options`        | object  | No       | Omitted unless supplied                |
| `tools`                 | array   | No       | Omitted unless supplied                |
| `prompt_cache_key`      | string  | No       | Omitted unless supplied                |
| `prompt_cache_options`  | object  | No       | Omitted unless supplied                |
| `safety_identifier`     | string  | No       | Omitted unless supplied                |
| `tool_choice`           | union   | No       | Omitted unless supplied                |
| `messages`              | array   | Yes      | Omitted unless supplied                |
| `reasoning_effort`      | string  | No       | low, high, max; default "max"          |
| `model`                 | string  | Yes      | kimi-k3.1-pro; default "kimi-k3.1-pro" |
| `temperature`           | number  | No       | 1                                      |
| `top_p`                 | number  | No       | 0.95                                   |
| `n`                     | integer | No       | 1                                      |
| `frequency_penalty`     | number  | No       | 0                                      |
| `presence_penalty`      | number  | No       | 0                                      |

### Responses

| Field                  | Type    | Required | Default / range                        |
| ---------------------- | ------- | -------- | -------------------------------------- |
| `model`                | string  | Yes      | kimi-k3.1-pro; default "kimi-k3.1-pro" |
| `input`                | union   | Yes      | Omitted unless supplied                |
| `instructions`         | string  | No       | Omitted unless supplied                |
| `stream`               | boolean | No       | default false                          |
| `max_output_tokens`    | integer | No       | 1–1048576; default 131072              |
| `reasoning`            | object  | No       | Omitted unless supplied                |
| `text`                 | object  | No       | Omitted unless supplied                |
| `tools`                | array   | No       | Omitted unless supplied                |
| `tool_choice`          | object  | No       | Omitted unless supplied                |
| `include`              | array   | No       | Omitted unless supplied                |
| `prompt_cache_key`     | string  | No       | Omitted unless supplied                |
| `prompt_cache_options` | object  | No       | Omitted unless supplied                |
| `safety_identifier`    | string  | No       | Omitted unless supplied                |

### Messages

| Field            | Type    | Required | Default / range                        |
| ---------------- | ------- | -------- | -------------------------------------- |
| `model`          | string  | Yes      | kimi-k3.1-pro; default "kimi-k3.1-pro" |
| `messages`       | array   | Yes      | Omitted unless supplied                |
| `max_tokens`     | integer | Yes      | 1–1048576                              |
| `system`         | union   | No       | Omitted unless supplied                |
| `stream`         | boolean | No       | default false                          |
| `stop_sequences` | array   | No       | ≤5 strings; ≤32 UTF-8 bytes each       |
| `tools`          | array   | No       | Omitted unless supplied                |
| `tool_choice`    | object  | No       | Omitted unless supplied                |
| `metadata`       | object  | No       | Omitted unless supplied                |
| `cache_control`  | object  | No       | Omitted unless supplied                |
| `output_config`  | object  | No       | Omitted unless supplied                |

Chat has 22 top-level fields: model, five fixed sampling fields and 16 variable inputs. Responses has model plus 12 inputs; Messages has model plus 10 inputs. The Playground hides fixed model and fixed sampling controls.

### Reasoning and output limits

Thinking is always enabled. Chat `reasoning_effort`, Responses `reasoning.effort` and Messages `output_config.effort` accept `low`, `high` or `max`; default `max`. All output limits include reasoning. Chat and Responses default to 131,072 output tokens, with a maximum of 1,048,576. Messages requires a positive `max_tokens`. Chat accepts deprecated `max_tokens`; prefer `max_completion_tokens` for new integrations.

The context window is 1,048,576 tokens. Input itself must fit inside it. When input plus the generation budget exceeds the window, the service can reduce the budget to the remaining space. A small output cap may stop before any visible answer appears.

Chat sampling is fixed: `temperature:1`, `top_p:0.95`, `n:1`, `frequency_penalty:0`, `presence_penalty:0`. Other values are invalid. Stop sequences match exact text and are excluded from the answer. Their 32-byte limit counts UTF-8 bytes, not characters.

### Structured output and predictions

Chat accepts `response_format.type` of `text`, `json_object` or `json_schema`. JSON mode also needs a prompt asking for JSON. JSON Schema requires `json_schema.name` and `json_schema.schema`; `strict` defaults to true.

Responses uses `text.format` with `type:json_schema`, `schema`, optional `name` and `strict`. Messages uses `output_config.format` with `type:json_schema` and `schema`. Follow Moonshot Flavored JSON Schema; do not assume every general JSON Schema extension is enforced. Validate completed output in your application.

Chat predicted output uses `prediction:{type:"content",content:...}`. Content is a string or text-only parts. Use it for mostly known output, such as a file receiving a small edit.

### Tools and preserved conversation history

Chat tools use `type:function` with `function.name` and `function.parameters`. Optional fields include `description` and `strict` (default true). Names match `^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$`. Tool choice supports `auto`, `none` and `required`; required needs at least one available tool. Forcing a named function conflicts with always-on thinking.

A dynamic Chat tool message is `{role:"system",tools:[...]}` without content. Keep these messages in the conversation. Append the complete assistant reply, including `reasoning_content` and `tool_calls`, then return each tool result as a `role:tool` message with the matching `tool_call_id`. Assistant tool replies can carry null content. Other message roles still require content.

Responses supports native function, namespace, `apply_patch` custom and `web_search` tool definitions with `tool_choice:"auto"`. Return `function_call_output` or `custom_tool_call_output` items with matching call IDs. The include values `web_search_call.results` and `web_search_call.action.sources` affect web-search output only.

Messages supports native tool definitions and tool choice objects with type `auto`, `any` or `none`. Preserve assistant thinking blocks and their signatures. Return tool-result blocks inside user messages. Your application validates arguments, executes custom functions and controls external actions.

Chat Partial Mode sets `partial:true` only on the final assistant message. Messages continues a final assistant message directly. Do not rebuild history from visible answer text alone.

### Media constraints

Chat accepts text, `image_url` and `video_url` content blocks. Use base64 data URLs or accepted `ms://` references; arbitrary public media URLs are unsupported. Image formats: JPEG, PNG, GIF, WebP, BMP, HEIC and HEIF. Video formats: MP4, MPEG, MOV, AVI, FLV, MPG, WebM, WMV and 3GPP. The official guide specifies a total request-body limit of 100M, with no separate image-count cap. 4K images and Full HD video are recommendations, not required limits.

Responses uses `input_image.image_url` with a data URL. Messages uses an image source such as `{type:"base64",media_type:"image/png",data:"..."}`, or type `url` with an accepted `ms://` reference. Messages inline image types are JPEG, PNG, GIF and WebP. These formats do not inherit Chat's video block by implication; use their dedicated schemas.

The Playground attaches inline images. Use native conversation fields or the JSON editor for video blocks and file references. File upload/management is outside these generation endpoints. A file ID created with another account is not necessarily usable.

### Caching and usage

Chat and Responses use `prompt_cache_key` and `prompt_cache_options:{mode:"implicit",ttl:"5m"}`. TTL accepts `5m` or `1h`, default 5 minutes. Messages uses top-level `cache_control:{type:"ephemeral",ttl:"5m"}` and optional `metadata.user_id`. Nested Messages cache-control markers are ignored. Content-level `prompt_cache_breakpoint` is invalid.

An existing cached prefix retains its original TTL when refreshed. Requesting a different lifetime does not prove that it applied. Chat's official cache-write headers report actual 5-minute and 1-hour counts. Responses can return applied `prompt_cache_options`; Messages reports both TTL counters in `usage.cache_creation`.

| Format    | Total input                                                            | Cache read                            | Cache write                                |
| --------- | ---------------------------------------------------------------------- | ------------------------------------- | ------------------------------------------ |
| Chat      | `usage.prompt_tokens`                                                  | `prompt_tokens_details.cached_tokens` | `prompt_tokens_details.cache_write_tokens` |
| Responses | `usage.input_tokens`                                                   | `input_tokens_details.cached_tokens`  | `input_tokens_details.cache_write_tokens`  |
| Messages  | `input_tokens + cache_read_input_tokens + cache_creation_input_tokens` | `cache_read_input_tokens`             | `cache_creation_input_tokens`              |

Chat and Responses input totals already include cache reads and writes. These categories and the uncached remainder are disjoint; do not add cache tokens twice. Output includes reasoning. Messages separates writes into `ephemeral_5m_input_tokens` and `ephemeral_1h_input_tokens`. See [live rates](https://seedrouter.ai/models/kimi-k3-1-pro#pricing); public generation responses do not contain monetary charges.

### Streaming and completion

Set `stream:true`. Chat emits data chunks and `[DONE]`; `stream_options.include_usage:true` requests the final usage chunk. Responses uses named events such as `response.output_text.delta`, `response.completed` and `response.incomplete`. Messages uses `message_start`, content-block events, `message_delta` and `message_stop`.

A closed connection alone does not prove completion. Check native finish reasons and terminal status. An interrupted stream may lack final usage. Stopping a reader does not guarantee generation cancellation.

## Official references

Checked on October 25, 2026: [Kimi K3.1 Pro guide](https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart), [Chat](https://platform.kimi.ai/docs/api/chat), [Responses](https://platform.kimi.ai/docs/api/responses), [Messages](https://platform.kimi.ai/docs/api/messages), [vision](https://platform.kimi.ai/docs/guide/use-kimi-vision-model) and [caching](https://platform.kimi.ai/docs/guide/context-caching).
