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

# Quickstart

> Create an API Key and complete your first Kimi API call.

Kimi API Platform provides access to Kimi models through the OpenAI-compatible [Responses API](https://platform.kimi.ai/docs/api/responses.md) and the Anthropic-compatible [Messages API](https://platform.kimi.ai/docs/api/messages.md). To get started, create an API Key, choose a model, and configure the `base_url` for your client. You can then send requests directly over HTTP or use the OpenAI or Anthropic SDK.

> [!NOTE]
>
> [Kimi K3.1 Pro](https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart.md) is now available in standard and high-speed variants — Kimi's most capable flagship model to date, with a 1M-token context window and native visual understanding, delivering substantial improvements across coding, 3D creation, and financial research and modeling. It is well suited for programming agent scenarios such as [Kimi Code](https://platform.kimi.ai/docs/guide/kimi-code-cli.md), [Codex](https://platform.kimi.ai/docs/guide/codex-kimi.md), and [Claude Code](https://platform.kimi.ai/docs/guide/claude-code-kimi.md), as well as knowledge work and deep reasoning. Join the [Kimi developer community](https://platform.kimi.ai/docs/api/join-the-community.md) — let's build with kimi!

## Get started

**1. Get an API Key**

Visit the [Kimi API Platform](https://platform.kimi.ai/), sign in, then go to [API Keys](https://platform.kimi.ai/console/api-keys) to create and copy an API Key.

Keep your API Key secure. Do not share it with others or hard-code it directly in your application. We recommend storing it in an environment variable:

```bash theme={null}
export MOONSHOT_API_KEY="YOUR_KIMI_API_KEY"
```

> **[Kimi API Platform](https://platform.kimi.ai/)**
>
> Sign in to the platform to access the console, development workspace, and user center.

> **[API Keys](https://platform.kimi.ai/console/api-keys)**
>
> Create, copy, and manage the keys used for API calls.

**2. Choose a model**

For a quickstart, we recommend starting with Kimi K3.1 Pro; choose the Kimi K3.1 Pro high-speed variant when you need faster output.

> **[Kimi K3.1 Pro](https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart.md)**
>
> Kimi K3.1 Pro is the first flagship of our new K3.1 series — a 3T-class model with a 1M-token context window and major gains in coding, 3D creation, and financial research and modeling.

> **[Kimi K3.1 Pro Highspeed](https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart.md)**
>
> `kimi-k3.1-pro-highspeed` is the high-speed variant of Kimi K3.1 Pro — same capabilities at about 2-3× the speed, for scenarios that need faster output.

> [!TIP]
>
> If you are not sure which model to choose, start with `kimi-k3.1-pro`. If your task is mainly code generation, code editing, or programming agents and you need higher output speed, choose `kimi-k3.1-pro-highspeed`.

**3. Choose an integration method**

Kimi API is compatible with both the OpenAI and Anthropic API formats, so you can choose the integration method that best fits your technology stack.

> **[Chat Completions API](https://platform.kimi.ai/docs/api/chat.md)**
>
> OpenAI-compatible format, with support for the OpenAI SDK and HTTP access from any language.

> **[Responses API](https://platform.kimi.ai/docs/api/responses.md)**
>
> OpenAI-compatible format for generating text/JSON output or calling function tools.

> **[Messages API](https://platform.kimi.ai/docs/api/messages.md)**
>
> Anthropic Messages API compatible, for integrating with the Anthropic SDK, Claude Code, and similar tools.

> **[Playground](https://platform.kimi.ai/playground)**
>
> Test prompts, model behavior, and business examples without writing code.

**4. Make your first call**

The following examples use the Kimi K3.1 Pro model. Replace `MOONSHOT_API_KEY` with the API Key you created on the platform, or set an environment variable with the same name before running the examples.

> [!NOTE]
>
> The examples on this page use the latest model `kimi-k3.1-pro` by default. K3.1 Pro configures reasoning effort with the top-level `reasoning_effort` request field (supports `"low"` / `"high"` / `"max"`, default `"max"`). To use another model such as `kimi-k2.6`, just replace the `model` field — parameter configurations differ across models. See the [Model Parameter Reference](https://platform.kimi.ai/docs/api/models-overview.md).

> [!TIP]
>
> To use the high-speed model for coding scenarios, replace `kimi-k3.1-pro` in the examples with `kimi-k2.7-code-highspeed`.

**python**

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

client = OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url="https://api.moonshot.ai/v1",
)

completion = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=[
        {"role": "system", "content": "You are Kimi, an AI assistant provided by Moonshot AI. You are especially good at conversations in Chinese and English. You provide users with safe, helpful, and accurate answers. You also refuse to answer any questions involving terrorism, racism, pornography, violence, or similar harmful content. Moonshot AI is a proper noun and must not be translated into other languages."},
        {"role": "user", "content": "Hi, my name is Li Lei. What is 1+1?"}
    ]
)

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

**curl**

```bash theme={null}
curl https://api.moonshot.ai/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $MOONSHOT_API_KEY" \
    -d '{
        "model": "kimi-k3.1-pro",
        "messages": [
            {"role": "system", "content": "You are Kimi, an AI assistant provided by Moonshot AI. You are especially good at conversations in Chinese and English. You provide users with safe, helpful, and accurate answers. You also refuse to answer any questions involving terrorism, racism, pornography, violence, or similar harmful content. Moonshot AI is a proper noun and must not be translated into other languages."},
            {"role": "user", "content": "Hi, my name is Li Lei. What is 1+1?"}
        ]
   }'
```

**node.js**

```js theme={null}
const OpenAI = require("openai");

const client = new OpenAI({
  apiKey: process.env.MOONSHOT_API_KEY,
  baseURL: "https://api.moonshot.ai/v1",
});

async function main() {
  const completion = await client.chat.completions.create({
    model: "kimi-k3.1-pro",
    messages: [
      {"role": "system", "content": "You are Kimi, an AI assistant provided by Moonshot AI. You are especially good at conversations in Chinese and English. You provide users with safe, helpful, and accurate answers. You also refuse to answer any questions involving terrorism, racism, pornography, violence, or similar harmful content. Moonshot AI is a proper noun and must not be translated into other languages."},
      {"role": "user", "content": "Hi, my name is Li Lei. What is 1+1?"}
    ]
  });

  console.log(completion.choices[0].message.content);
}

main();
```

Before running the examples, prepare:

1. Python 3.8 or later, or Node.js 18 or later.
2. OpenAI SDK 1.0.0 or later. Kimi API is compatible with the OpenAI API format, so you can call Kimi directly with the OpenAI Python or Node.js SDK.
   ```text theme={null}
   pip install --upgrade 'openai>=1.0' # Python
   npm install openai@latest # Node.js
   ```
3. An API Key. Create an API Key in the [Kimi API Platform](https://platform.kimi.ai/console/api-keys), then pass it to the `OpenAI Client` so the platform can identify your account.

If the code runs successfully without errors, you will see output similar to:

```text theme={null}
Hello, Li Lei! 1+1 equals 2. This is a basic arithmetic question. If you have any other questions or need help, feel free to let me know.
```

*Note: Because Kimi models are nondeterministic, the actual response may not exactly match the example above.*

## Explore more features

> **[Streaming output](https://platform.kimi.ai/docs/api/chat.md)**
>
> Enable `stream` to receive tokens as they are generated. Useful for chat, code generation, and long-form text output.

> **[Multi-turn chat](https://platform.kimi.ai/docs/guide/engage-in-multi-turn-conversations-using-kimi-api.md)**
>
> Maintain a `messages` list to preserve context history, letting the model remember the conversation.

> **[Multimodal input](https://platform.kimi.ai/docs/guide/use-kimi-vision-model.md)**
>
> Kimi K3.1 Pro, Kimi K3, Kimi K2.7 Code, and Kimi K2.6 all support text, image, and video input.

> **[Tool calls](https://platform.kimi.ai/docs/guide/use-kimi-api-to-complete-tool-calls.md)**
>
> Let the model call external functions or APIs for Agent tasks, web search, and complex workflows.

> **[JSON Mode](https://platform.kimi.ai/docs/guide/use-json-mode-feature-of-kimi-api.md)**
>
> Force the model to output valid JSON for structured data extraction and downstream integration.

> **[Thinking models](https://platform.kimi.ai/docs/guide/use-thinking-models.md)**
>
> Use reasoning capabilities for complex tasks, multi-step tool use, and Agent workflows.

### Streaming output

```json theme={null}
{
  "model": "kimi-k3.1-pro",
  "messages": [
    {
      "role": "user",
      "content": "Please explain what recursion is and give a Python example."
    }
  ],
  "stream": true
}
```

### Multimodal input

```json theme={null}
{
  "model": "kimi-k3.1-pro",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "data:image/png;base64,..."
          }
        },
        {
          "type": "text",
          "text": "Please describe this image."
        }
      ]
    }
  ]
}
```

> [!WARNING]
>
> For larger videos, or images and videos that need to be referenced multiple times, we recommend using file uploads. Images should be no larger than 4K resolution, and videos should be no larger than 1080p.

## Related resources

> **[Kimi K3.1 Pro model](https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart.md)**
>
> View Kimi K3.1 Pro capabilities, calling examples, and best practices.

> **[Kimi K2.7 Code model](https://platform.kimi.ai/docs/guide/kimi-k2-7-code-quickstart.md)**
>
> View Kimi K2.7 Code capabilities, calling examples, and best practices.

> **[Model list](https://platform.kimi.ai/docs/models.md)**
>
> View currently available model names and descriptions.

> **[Join the Kimi Developer Community](https://platform.kimi.ai/docs/api/join-the-community.md)**
>
> Ask questions, share feedback, and showcase what you are building with Kimi.
