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

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
- Go to platform.moonshot.ai
- Create an account or sign in.
Once logged in, you’ll have access to your dashboard, where you can manage API keys, track usage, and access detailed documentation.

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:
- Locate the API Keys section in your dashboard.
- Click Create New Key to generate a new secret key.
Copy your key (it starts with sk-) and store it securely — a password manager is ideal.

⚠️ 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.

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.

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.

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.

👉 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

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.

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.

4. Configure Cursor:
Open Cursor and go to Settings → Models → API Keys.
- Replace the default URL
https://api.openai.com/v1with:
https://openrouter.ai/api/v1
- Paste your OpenRouter API key.

5. Add Kimi K2 Thinking as a Custom Model:
Click Add Custom Model and enter:
moonshotai/kimi-k2-thinking

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

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 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!



