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

# Use Kimi K2.5 Model in ClaudeCode/Cline/RooCode

Kimi K2.5 is a MoE architecture foundation model with exceptional code and Agent capabilities. We use Claude Code, VS Code & Cline/RooCode as examples to illustrate how to use the Kimi K2.5 series models.

## Usage Notes

When using large models for code generation, due to the randomness and complexity of the model, multiple attempts may be required to generate code that meets expectations. Programming tools will automatically perform multiple rounds of retries and calls, which may lead to rapid token usage growth. To better control costs and improve the user experience, we recommend you pay attention to the following points:

* **Budget Control**
  * **Set Daily Spending Limit**: Before use, please go to [Kimi Open Platform Project Settings](https://platform.kimi.ai/console/projects/settings) to configure the "Project Daily Spending Budget". Once the budget limit is reached, the system will automatically reject all API requests under this project (Note: Due to billing delays, the limit may take about 10 minutes to take effect). For setup instructions, please see [Organization Management Best Practices](/guide/org-best-practice)
  * **Balance Alert Reminder**: It is recommended to enable the account balance reminder function. When the account balance falls below the preset amount (default ¥20), the system will notify you via SMS to recharge in a timely manner.
* **Usage Recommendations**
  * **Continuous Monitoring**: It is recommended to keep monitoring while the programming software is running, and handle abnormal situations promptly to avoid unnecessary resource consumption due to infinite loops or excessive retries.
  * **Model Selection**: If response speed is not a high priority, you can choose to use the `kimi-k2.5` model.

## K2 Vendor Verifier

Kimi models have always focused on agentic loops, and the reliability of tool calls is crucial. To this end, we launched [K2 Vendor Verifier (K2VV)](https://github.com/MoonshotAI/K2-Vendor-Verifier) to evaluate the quality of Kimi API tool calls from different vendors, helping you intuitively compare the accuracy differences among various vendors.

**Latest Update**: K2VV has been expanded to 12 vendors, and more test data has been open-sourced. Welcome to provide feedback on the test metrics you care about [here](https://github.com/MoonshotAI/K2-Vendor-Verifier/issues/9).

## Obtaining API Key

* Visit the Open Platform at [https://platform.kimi.ai/console/api-keys](https://platform.kimi.ai/console/api-keys) to create and obtain an API Key, selecting the default project.

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/apikey.jpeg?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=1902bb9524d3f53d9dd12a3c66bf4f87" alt="key" width="2966" height="1472" data-path="assets/pics/cline/apikey.jpeg" />

## Using kimi k2.5 model in Claude Code

### Install Claude Code

If you have already installed Claude Code, you can skip this step

#### MacOS and Linux

```shell theme={null}
# Install nodejs on MacOS and Linux
curl -fsSL https://fnm.vercel.app/install | bash

# Open a new terminal to make fnm take effect
fnm install 24.3.0
fnm default 24.3.0
fnm use 24.3.0

# Install claude-code
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

# Initialize configuration
node --eval "
    const homeDir = os.homedir(); 
    const filePath = path.join(homeDir, '.claude.json');
    if (fs.existsSync(filePath)) {
        const content = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
        fs.writeFileSync(filePath,JSON.stringify({ ...content, hasCompletedOnboarding: true }, 2), 'utf-8');
    } else {
        fs.writeFileSync(filePath,JSON.stringify({ hasCompletedOnboarding: true }), null, 'utf-8');
    }"
```

#### Windows

```powershell theme={null}
# Open the PowerShell terminal in Windows Terminal
# Install nodejs on Windows
# Right-click the Windows button and select "Terminal"

# Then execute the following commands in sequence
winget install OpenJS.NodeJS
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

# Then close the terminal window and open a new one

# Install claude-code
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

# Initialize configuration
node --eval "
    const homeDir = os.homedir(); 
    const filePath = path.join(homeDir, '.claude.json');
    if (fs.existsSync(filePath)) {
        const content = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
        fs.writeFileSync(filePath,JSON.stringify({ ...content, hasCompletedOnboarding: true }, 2), 'utf-8');
    } else {
        fs.writeFileSync(filePath,JSON.stringify({ hasCompletedOnboarding: true }), null, 'utf-8');
    }"
```

### Configure Environment Variables

After completing the installation of Claude Code, please set the environment variables as follows to use the `kimi-k2.5` model and start Claude.

#### MacOS and Linux

```shell theme={null}
# Start the high-speed kimi-k2.5 model on Linux/macOS
export ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic
export ANTHROPIC_AUTH_TOKEN=${YOUR_MOONSHOT_API_KEY}
export ANTHROPIC_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_OPUS_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_SONNET_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=kimi-k2.5
export CLAUDE_CODE_SUBAGENT_MODEL=kimi-k2.5
export ENABLE_TOOL_SEARCH=false
claude
```

#### Windows

```powershell theme={null}
# Start the high-speed kimi-k2.5 model on Windows PowerShell
$env:ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic";
$env:ANTHROPIC_AUTH_TOKEN="YOUR_MOONSHOT_API_KEY"
$env:ANTHROPIC_MODEL="kimi-k2.5"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="kimi-k2.5"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="kimi-k2.5"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="kimi-k2.5"
$env:CLAUDE_CODE_SUBAGENT_MODEL="kimi-k2.5"
$env:ENABLE_TOOL_SEARCH=false
claude
```

#### Verify Environment Variables

Enter `/status` in Claude Code to check the model status:

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/status.png?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=051f6e987302797e4bde2ce4fc277cab" alt="status" width="1138" height="458" data-path="assets/pics/cline/status.png" />

* How to experience the thinking capabilities of `kimi-k2.5` in Claude Code
  * After configuring the model, click the `Tab` button to switch after entering the Claude Code page. A "Thinking on" indicator will appear when the switch is successful.

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/thinking-on.png?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=acf616ab4147291f80c8713a1a35bb5e" alt="status" width="1140" height="656" data-path="assets/pics/cline/thinking-on.png" />

You can now use Claude Code for development as usual!

## Using kimi k2.5 model in Cline

### Install Cline

1. Open VS Code
2. Click the Extensions icon in the left activity bar (or use the shortcut `Ctrl+Shift+X` / `Cmd+Shift+X`)
3. Enter `cline` in the search box
4. Find the `Cline` extension (usually published by Cline Team)
5. Click the `Install` button to install it
6. After installation, you may need to restart VS Code

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/search_cline.jpeg?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=f02abbb0ab8d1751203539a06c1b7633" alt="cline" width="1582" height="976" data-path="assets/pics/cline/search_cline.jpeg" />

### Verify Installation

After installation, you can:

1. See the Cline icon in the left activity bar of VS Code
2. Or search for "Cline" related commands through the command palette (`Ctrl+Shift+P` / `Cmd+Shift+P`) to verify the installation was successful

### Official Recommendation: Configure Moonshot Provider to use Kimi K2.5 model

* Select 'Moonshot' as the API Provider
* Select 'api.moonshot.ai' as the Moonshot Entrypoint
* Configure the Moonshot API Key with the Key obtained from the Kimi Open Platform
* Select 'kimi-k2.5' as the Model
* Check 'Disable browser tool usage' under Browser
* Click 'Done' to save the configuration

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/moonshot_cline_en.png?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=772e07f210bd3545c2a4d5619ddcba59" alt="moonshot_cline" width="1500" height="1274" data-path="assets/pics/cline/moonshot_cline_en.png" />

### Experience the effects of Kimi K2.5 model in cline

* We asked the Kimi K2.5 model to write a Snake game

<Frame>
  <video controls style={{ width: '100%', height: 'auto' }}>
    <source src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/cline-run.mp4?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=0f3ae22ed36ec054e74702839af038e5" type="video/mp4" data-path="assets/pics/cline/cline-run.mp4" />

    Your browser does not support video playback.
  </video>
</Frame>

* Game effects

<Frame>
  <video controls style={{ width: '100%', height: 'auto' }}>
    <source src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/snake.mp4?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=e544c10e016ddc6f96a1a8a40db680ac" type="video/mp4" data-path="assets/pics/cline/snake.mp4" />

    Your browser does not support video playback.
  </video>
</Frame>

## Using Kimi K2.5 model in RooCode

### Install RooCode

1. Open VS Code
2. Click the Extensions icon in the left activity bar (or use the shortcut `Ctrl+Shift+X` / `Cmd+Shift+X`)
3. Enter `roo code` in the search box
4. Find the `Roo Code` extension (usually published by RooCode Team)
5. Click the "Install" button to install it
6. After installation, you may need to restart VS Code

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/search_roocode.png?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=8799d73907d0821eb0378c7ede6e4c2d" alt="cline" width="1192" height="1390" data-path="assets/pics/cline/search_roocode.png" />

### Verify Installation

After installation, you can:

1. See the RooCode icon in the left activity bar of VS Code
2. Or search for "RooCode" related commands through the command palette (`Ctrl+Shift+P` / `Cmd+Shift+P`) to verify the installation was successful

### Official Recommendation: Configure Moonshot Provider to use Kimi K2.5 model

* Select 'Moonshot' as the API Provider
* Select 'api.moonshot.ai' as the Moonshot Entrypoint
* Configure the Moonshot API Key with the Key obtained from the Kimi Open Platform
* Select 'kimi-k2.5' as the Model
* Check 'Disable browser tool usage' under Browser

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/moonshot_roocode_en.png?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=e7b445fd717492cde3122622a76ebe9a" alt="roocode" width="1492" height="1474" data-path="assets/pics/cline/moonshot_roocode_en.png" />

## Using kimi k2.5 Model in OpenCode

### Install OpenCode

The easiest way to install OpenCode is through the install script.

```bash theme={null}
curl -fsSL https://opencode.ai/install | bash
```

You can also install it with npm:

```bash theme={null}
npm install -g opencode-ai
```

### Configure API key

1. Run `opencode auth login` and select **Moonshot AI**.
   ```bash theme={null}
   $ opencode auth login
   ┌  Add credential
   │
   ◆  Select provider
   │  ● Moonshot AI
   │  ...
   └
   ```
2. Enter your Moonshot AI API key.
   ```bash theme={null}
   $ opencode auth login
   ┌  Add credential
   │
   ◇  Select provider
   │  Moonshot AI
   │
   ◇  Enter your API key
   │  _
   └
   ```
3. Run `opencode` to launch OpenCode.
   ```bash theme={null}
   $ opencode
   ```
   Use the `/models` command to select the *Kimi K2.5* model.
   ```text theme={null}
   /models
   ```

Let's get started. For more information, please visit [opencode.ai/docs](https://opencode.ai/docs)

<img src="https://mintcdn.com/moonshotai/dink2O4VJx7ks4ld/assets/pics/cline/opencode.jpeg?fit=max&auto=format&n=dink2O4VJx7ks4ld&q=85&s=68c313b43abd21950a0ee27f7a9c4ffb" alt="opencode" width="2024" height="1534" data-path="assets/pics/cline/opencode.jpeg" />

## Direct API Calls to Kimi K2.5 model

<Tabs>
  <Tab title="python">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        api_key = "$MOONSHOT_API_KEY",
        base_url = "https://api.moonshot.ai/v1",
    )

    completion = client.chat.completions.create(
        model = "kimi-k2.5",
        messages = [
            {"role": "system", "content": "You are Kimi, an artificial intelligence assistant provided by Moonshot AI. You are more proficient in Chinese and English conversations. You will provide users with safe, helpful, and accurate answers. At the same time, you will refuse to answer any questions involving terrorism, racial discrimination, pornography, or violence. Moonshot AI is a proper noun and cannot be translated into other languages."},
            {"role": "user", "content": "Hello, my name is Li Lei, what is 1+1?"}
        ]
    )

    print(completion.choices[0].message.content)
    ```
  </Tab>

  <Tab title="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-k2.5",
            "messages": [
                {"role": "system", "content": "You are Kimi, an artificial intelligence assistant provided by Moonshot AI. You are more proficient in Chinese and English conversations. You will provide users with safe, helpful, and accurate answers. At the same time, you will refuse to answer any questions involving terrorism, racial discrimination, pornography, or violence. Moonshot AI is a proper noun and cannot be translated into other languages."},
                {"role": "user", "content": "Hello, my name is Li Lei, what is 1+1?"}
            ]
       }'
    ```
  </Tab>

  <Tab title="node.js">
    ```js theme={null}
    const OpenAI = require("openai");

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

    async function main() {
        const completion = await client.chat.completions.create({
            model = "kimi-k2.5",         
            messages: [ 
                {"role": "system", "content": "You are Kimi, an artificial intelligence assistant provided by Moonshot AI. You are more proficient in Chinese and English conversations. You will provide users with safe, helpful, and accurate answers. At the same time, you will refuse to answer any questions involving terrorism, racial discrimination, pornography, or violence. Moonshot AI is a proper noun and cannot be translated into other languages."},
                {"role": "user", "content": "Hello, my name is Li Lei, what is 1+1?"}
            ]
        });
        console.log(completion.choices[0].message.content);
    }

    main();
    ```
  </Tab>
</Tabs>

Where \$MOONSHOT\_API\_KEY needs to be replaced with the API Key you created on the platform.

When running the code in the documentation using the OpenAI SDK, ensure that the Python version is at least 3.7.1, the Node.js version is at least 18, and the OpenAI SDK version is not lower than 1.0.0.
