How to use Kimi K2 Thinking with Claude Code & Cursor

Discover how to integrate Kimi K2 Thinking with Claude Code & Cursor using Moonshot AI’s API. Follow this step-by-step guide to unlock powerful reasoning and coding capabilities in your favorite development tools.

Ashley Goolam

Ashley Goolam

10 November 2025

How to use Kimi K2 Thinking with Claude Code & Cursor

Introduction

Artificial intelligence is entering a new era of thinking agents—models capable of reasoning, planning, and coding with human-like depth. Among these, Kimi K2 Thinking by Moonshot AI stands out for its trillion-parameter scale, expert-level reasoning ability, and full compatibility with modern development tools.

If you’re a developer working with Claude Code or Cursor, integrating Kimi K2 Thinking into your environment can significantly enhance your workflow. This guide will show you, step by step, how to set up kimi k2 thinking with claude code and kimi k2 thinking with cursor, so you can start leveraging this powerful AI model in your daily development tasks.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Understanding Kimi K2 Thinking

Before diving into setup, let’s briefly understand what makes Kimi K2 Thinking so remarkable. Developed by Moonshot AI, it’s a trillion-parameter model built as a thinking agent, capable of multi-step reasoning, code generation, and autonomous decision-making.

It features a 256K context window, executes up to 300 sequential tool calls, and consistently achieves state-of-the-art (SOTA) results in reasoning benchmarks. Kimi K2 Thinking is designed not just to respond, but to think through complex problems, making it ideal for programming, data analysis, and scientific research.

How to Use Kimi K2 Thinking API
Discover the Kimi K2 Thinking API—Moonshot AI’s trillion-parameter reasoning model that outperforms GPT-5, executes 300 tool calls, and integrates easily via OpenAI-compatible APIs.
Learn more about the Pricing, Benchmarks and Features of Kimi K2 Thinking model

Getting Started with Moonshot AI

Before using Kimi K2 Thinking in any IDE or coding tool, you’ll need to register for an API key.

Step 1: Register on the Moonshot AI Platform

Once logged in, you’ll have access to your dashboard, where you can manage API keys, track usage, and access detailed documentation.

navigate to moonshot ai console

This platform is your main control center for working with Kimi K2 Thinking and other Moonshot AI services.

Step 2: Get Your API Key

After registration:

Copy your key (it starts with sk-) and store it securely — a password manager is ideal.

create a moonshot ai api key

⚠️ Important: You won’t be able to view this key again after closing the page. Keep it private and never share it publicly or push it to repositories.

Step 3: Add Credits to Your Moonshot AI Account

Before you can start using Kimi K2 Thinking, you’ll need to add credits to your Moonshot AI account. Without credits, API requests to the Kimi K2 Thinking model won’t process.

1.   Go to the Billing Section:
From your Moonshot AI dashboard, navigate to the Billing tab.

navigate to the billing section in moonshot ai dashboard

2.   Recharge Your Account:
Under the Recharge section, select the amount you want to add. Enter your billing information, including details such as your card number, payment amount, and email address, etc.

recharge your moonshot ai account

3.   Confirm Payment:
After submitting your details, complete the payment process to fund your account.

4.   Track Your Spending:
Head over to the Overview section to view your monthly or yearly expenditures. This helps you keep track of your API usage and manage your budget efficiently.

Once your account is funded, you’ll be ready to start making calls to the Kimi K2 Thinking API without any interruptions.

How to Use Kimi K2 Thinking with Claude Code

Claude Code is a powerful AI coding assistant by Anthropic, built to work with the Claude family of models. However, thanks to Moonshot AI’s OpenAI- and Anthropic-compatible endpoints, you can easily redirect Claude Code to use Kimi K2 Thinking instead.

Step 1: Set the Base URL

Next, tell Claude Code where to send its API requests:

export ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic

This simple command reroutes all traffic intended for Anthropic’s servers to Moonshot AI’s servers.

Claude Code will “think” it’s talking to Claude—but behind the scenes, it’s powered by Kimi K2 Thinking.

change claude code's base url

Step 2: Set Your Authentication Token

Open your terminal or command prompt and type:

export ANTHROPIC_AUTH_TOKEN=sk-YOURKEY

Replace sk-YOURKEY with your actual Moonshot AI API key.

This tells Claude Code to authenticate requests using your Moonshot AI key.

change claude code's api key

👉 Windows users:
If you’re on Windows, use the set command instead:

set ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic
set ANTHROPIC_AUTH_TOKEN=sk-YOURKEY
using kimi-k2-thinking with claude code on windows

Step 3: Launch Claude Code

Start Claude Code as usual by typing:

claude

You should notice the default model name change—for instance, from sonnet-4.5 to kimi-k2-thinking-turbo.

That’s your confirmation that you’re now successfully running kimi k2 thinking with claude code.

How to Use Kimi K2 Thinking with Cursor

Cursor is another modern AI-powered code editor that integrates seamlessly with large language models. While Cursor doesn’t yet natively support Kimi K2 Thinking, you can still use it effectively via OpenRouter or directly through Moonshot AI.

Option 1: Use Kimi K2 Thinking via OpenRouter

1. Create an OpenRouter Account:
Visit openrouter.ai and sign up.

create an account with openrouter

2. Add Credits:
Go to openrouter.ai/settings/credits to add credits for API access.

3. Generate an API Key:
Navigate to openrouter.ai/settings/keys and create a new API key.

create an openrouter api key

4. Configure Cursor:
Open Cursor and go to Settings → Models → API Keys.

https://openrouter.ai/api/v1
configure cursor to work with openrouter api and base url

5. Add Kimi K2 Thinking as a Custom Model:
Click Add Custom Model and enter:

moonshotai/kimi-k2-thinking
add kimi-k2-thinking model to cursor

6. Start Using Kimi K2 in Cursor:
You can now use Kimi K2 Thinking with Cursor for real-time code generation, refactoring, and reasoning.

💡 Note: Agent mode may not fully function since this is not a native integration, but most coding and reasoning features will work perfectly.

Option 2: Use Kimi K2 Thinking Directly via Moonshot AI

If you prefer not to use OpenRouter, you can connect directly to Moonshot AI:

  1. Register, generate your API key and add credits to your account at platform.moonshot.ai as explained in the "Getting Started with Moonshot AI" section earlier.

2.   In Cursor’s settings, replace the API base URL with:

https://api.moonshot.ai/v1

3.   Use your Moonshot AI API key in place of your OpenAI key.

configure cursor with moonshotai api key

Because Kimi’s API is fully compatible with OpenAI’s interface specifications, this setup works seamlessly in Cursor without major adjustments.

Frequently Asked Questions (FAQ)

1. What is Kimi K2 Thinking?

Kimi K2 Thinking is a trillion-parameter AI model developed by Moonshot AI. It’s designed as a thinking agent capable of advanced reasoning, coding, and long-context understanding, making it ideal for developers and researchers.

2. Is Kimi K2 Thinking compatible with OpenAI or Anthropic APIs?

Yes. The Kimi K2 Thinking API is fully compatible with both OpenAI and Anthropic interface specifications. You can use the same SDKs and simply change the base_url and api_key to connect your existing applications to Kimi.

3. How do I switch Claude Code to use Kimi K2 Thinking?

You can redirect Claude Code’s API calls to Moonshot AI by setting two environment variables:

export ANTHROPIC_AUTH_TOKEN=sk-YOURKEY
export ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic

Then, launch Claude Code normally. The model should update automatically to kimi-k2-thinking-turbo.

4. Can I use Kimi K2 Thinking in Cursor?

Absolutely. Cursor doesn’t yet have native support, but you can connect Kimi K2 Thinking through OpenRouter or directly via Moonshot AI’s API. It works with most core coding and reasoning features.

5. Where can I get my Kimi K2 Thinking API key?

You can register and generate your personal API key from platform.moonshot.ai. After logging in, go to the API Keys section, create a new key, and store it safely — it will be required to authenticate your applications.

Conclusion

The age of reasoning-driven coding is here, and Kimi K2 Thinking is leading the charge. By integrating kimi k2 thinking with claude code or kimi k2 thinking with cursor, developers gain access to one of the most capable AI reasoning systems available today—seamlessly woven into their preferred development environments.

With Moonshot AI’s simple API setup, OpenAI-compatible interface, and advanced thinking capabilities, it’s never been easier to supercharge your coding experience with true artificial reasoning.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Explore more

Claude Code vs Codex vs Cursor vs MiniMax Plan vs GLM Plan: A Comprehensive Comparison for Developers

Claude Code vs Codex vs Cursor vs MiniMax Plan vs GLM Plan: A Comprehensive Comparison for Developers

Explore the ultimate showdown in AI coding assistants: Claude Code vs CodeX vs Cursor vs Minimax Plan vs GLM plan. This technical analysis covers features, pricing, performance, and real-world applications to help developers choose the best tool.

10 November 2025

How to Get Started Using ElysiaJS with OpenAPI and Bun in 2025

How to Get Started Using ElysiaJS with OpenAPI and Bun in 2025

Discover ElysiaJS, a lightweight Node.js framework for REST APIs, and how it integrates with Bun and OpenAPI. This guide covers ElysiaJS benefits, Bun installation and setup, OpenAPI plugins, sample code for basic and OpenAPI-enabled apps, testing, and FAQs.

8 November 2025

Top 10 LLMs with No Restrictions in 2025

Top 10 LLMs with No Restrictions in 2025

Unlock the potential of LLMs with no restrictions in 2025. This guide ranks the top 10 uncensored LLMs, including Dolphin 3, Nous Hermes 3, and Llama variants, highlighting their architectures, features, and applications for developers and researchers seeking unfiltered AI performance.

7 November 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs