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

> Kimi-K2.6 multimodal chat model by MoonShot via Anyfast OpenAI-compatible API. Latest, most intelligent, with thinking mode and text/image/video input.

Kimi-K2.6 is the latest and most intelligent model by MoonShot (月之暗面), available through Anyfast via an OpenAI-compatible interface. Compared with Kimi-K2.5, it delivers major gains in agentic coding, long-context reasoning, long-horizon execution, and front-end design, and supports text, image, and video input as well as thinking and non-thinking modes.

## Key capabilities

* **OpenAI-compatible** — Works as a drop-in replacement with the OpenAI SDK
* **256K context** — 262,144 tokens for large documents and multi-turn conversations
* **Multimodal input** — Accepts text, image, and video content
* **Thinking mode** — Toggle via the `thinking` parameter; returns `reasoning_content` and supports Preserved Thinking
* **Long-horizon coding** — More reliable across languages (Rust, Go, Python) and tasks (front-end, ops, performance)
* **Rich features** — Tool Calls (function calling), JSON Mode, Partial Mode, web search, and automatic context caching

## Quick example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/chat/completions \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kimi-k2.6",
      "messages": [
        { "role": "user", "content": "Explain quantum entanglement in simple terms." }
      ]
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai/v1"
  )

  response = client.chat.completions.create(
      model="kimi-k2.6",
      messages=[
          {"role": "user", "content": "Explain quantum entanglement in simple terms."}
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```python Streaming theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai/v1"
  )

  stream = client.chat.completions.create(
      model="kimi-k2.6",
      messages=[
          {"role": "user", "content": "Write a short poem about the sea."}
      ],
      stream=True
  )

  for chunk in stream:
      print(chunk.choices[0].delta.content or "", end="")
  ```

  ```python Thinking mode theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai/v1"
  )

  # Thinking is enabled by default; pass {"type": "disabled"} to turn it off
  completion = client.chat.completions.create(
      model="kimi-k2.6",
      messages=[
          {"role": "user", "content": "Solve x² + 5x + 6 = 0 for x."}
      ],
      extra_body={"thinking": {"type": "enabled"}},
      stream=True
  )

  for chunk in completion:
      if chunk.choices and chunk.choices[0].delta:
          delta = chunk.choices[0].delta
          if hasattr(delta, "reasoning_content") and delta.reasoning_content:
              print(delta.reasoning_content, end="", flush=True)
          if delta.content:
              print(delta.content, end="", flush=True)
  ```

  ```python Image input theme={null}
  import base64
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai/v1"
  )

  with open("your_image.jpg", "rb") as f:
      img_base = base64.b64encode(f.read()).decode("utf-8")

  response = client.chat.completions.create(
      model="kimi-k2.6",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "Describe this image."},
                  {
                      "type": "image_url",
                      "image_url": {
                          "url": f"data:image/jpeg;base64,{img_base}"
                          # or a file reference: "url": "ms://<file_id>"
                      }
                  }
              ]
          }
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```python Video input theme={null}
  import base64
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai/v1"
  )

  with open("your_video.mp4", "rb") as f:
      video_base = base64.b64encode(f.read()).decode("utf-8")

  response = client.chat.completions.create(
      model="kimi-k2.6",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "Summarize this video."},
                  {
                      "type": "video_url",
                      "video_url": {
                          "url": f"data:video/mp4;base64,{video_base}"
                          # or a file reference: "url": "ms://<file_id>"
                      }
                  }
              ]
          }
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```bash cURL (image) theme={null}
  curl https://www.anyfast.ai/v1/chat/completions \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kimi-k2.6",
      "messages": [
        {
          "role": "user",
          "content": [
            {"type": "text", "text": "Describe this image."},
            {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgo..."}}
          ]
        }
      ]
    }'
  ```
</CodeGroup>

> **Note:** `image_url` and `video_url` accept two formats: a base64 data URI (`data:image/png;base64,...` / `data:video/mp4;base64,...`) or a file reference (`ms://<file_id>`). Tokens served from the context cache are reported in `usage.prompt_tokens_details.cached_tokens`.

## Parameters

| Parameter               | Type           | Required | Description                                                                                                                      |
| ----------------------- | -------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `model`                 | string         | Yes      | Must be `kimi-k2.6`                                                                                                              |
| `messages`              | array          | Yes      | List of `{ role, content }` objects. `content` may be a string or a multimodal array of `text`/`image_url`/`video_url`           |
| `thinking`              | object         | No       | Controls thinking mode, e.g. `{"type": "enabled"}` (default) or `{"type": "disabled"}`; `keep: "all"` enables Preserved Thinking |
| `max_completion_tokens` | integer        | No       | Maximum tokens to generate. (`max_tokens` is deprecated and not honored)                                                         |
| `temperature`           | float          | No       | `0`–`2`. Controls randomness. Default: `1`                                                                                       |
| `stream`                | boolean        | No       | Enable SSE streaming. Default: `false`                                                                                           |
| `top_p`                 | float          | No       | Nucleus sampling threshold. Default: `1`                                                                                         |
| `response_format`       | object         | No       | Set to `{"type": "json_object"}` to enable JSON Mode                                                                             |
| `tools`                 | array          | No       | A list of tools the model may call (function calling)                                                                            |
| `stop`                  | string / array | No       | Sequences that stop generation (up to 5, max 32 bytes each)                                                                      |

<Card title="API Reference" icon="code" href="/api-reference/model-api/moonshot/kimi-k2-6">
  View the interactive API playground for Kimi-K2.6.
</Card>

<script src="/feedback.js" />
