How to Use Kimi-K2 in Claude Code on Windows and Mac

Table of contents
Claude Code offers more powerful agent capabilities than traditional code editors like Cursor. By integrating Kimi-K2 through Novita AI’s platform, developers can access enterprise-grade AI functionality at a fraction of the cost. This guide covers setting up Kimi-K2 with Claude Code on both Windows and Mac systems.
What is Claude Code
Source: http://www.anthropic.com/claude-code
Claude Code is an agentic command line tool that revolutionizes the way developers interact with AI for coding tasks. Unlike traditional code editors, Claude Code offers more powerful agent abilities than Cursor.
This innovative tool enables developers to delegate complex coding tasks directly from their terminal. It transforms natural language descriptions into fully functional code, making it an indispensable asset for modern development workflows.
The tool operates as an interactive session where developers can describe their requirements in plain English. Claude Code intelligently generates, modifies, and optimizes code accordingly. Its advanced understanding of context and project structure allows it to make informed decisions about code architecture, dependencies, and implementation patterns.
Why Use Kimi-K2 in Claude Code
Kimi-K2 presents a compelling alternative to traditional Claude models, offering similar capabilities at significantly reduced costs. The economic advantages are substantial:
Kimi-K2 on Novita AI: $0.57 per 1M input tokens and $2.3 per 1M output tokens
Claude Sonnet: $3 per 1M input tokens and $15 per 1M output tokens
This represents an 81% cost reduction for input tokens and an 85% reduction for output tokens.
Beyond cost savings, Kimi-K2 through Novita AI provides an anthropic-compatible LLM API with higher rate limits than official channels. This compatibility ensures seamless integration with existing Claude Code workflows while offering improved performance and reliability.
The combination delivers enterprise-grade AI capabilities without the premium pricing. This makes advanced AI development accessible to a broader range of developers and organizations.
Getting Your API Key on Novita AI
Sign up for a Novita AI account to get started with free trial credits. Navigate to the Key Management page in your dashboard and click “Create New Key.”
Copy the generated API key immediately and store it securely – it won’t be displayed again. You’ll need this key for the configuration steps below.
Installing Claude Code
Before installing Claude Code, ensure your system meets the minimum requirements. Node.js 18 or higher must be installed on your local environment. You can verify your Node.js version by running node --version
in your terminal.
For Windows
Open Command Prompt and execute the following commands:
cmd
npm install -g @anthropic-ai/claude-code
npx win-claude-code@latest
The global installation ensures Claude Code is accessible from any directory on your system. The npx win-claude-code@latest
command downloads and runs the latest Windows-specific version.
For Mac
Open Terminal and run:
bash
npm install -g @anthropic-ai/claude-code
Mac users can proceed directly with the global installation without requiring additional platform-specific commands. The installation process automatically configures the necessary dependencies and PATH variables.
Setting Up Environment Variables
Environment variables configure Claude Code to use Kimi-K2 through Novita AI’s API endpoints. These variables tell Claude Code where to send requests and how to authenticate.
For Windows
Open Command Prompt and set the following environment variables:
cmd
set ANTHROPIC_BASE_URL=https://api.novita.ai/anthropic
set ANTHROPIC_AUTH_TOKEN=<Novita API Key\>
set ANTHROPIC_MODEL=moonshotai/kimi-k2-instruct
set ANTHROPIC_SMALL_FAST_MODEL=moonshotai/kimi-k2-instruct
Replace <Novita API Key>
with your actual API key obtained from the Novita AI platform. These variables remain active for the current session and must be reset if you close the Command Prompt.
For Mac
Open Terminal and export the following environment variables:
bash
export ANTHROPIC_BASE_URL="https://api.novita.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="<Novita API Key>"
export ANTHROPIC_MODEL="moonshotai/kimi-k2-instruct"
export ANTHROPIC_SMALL_FAST_MODEL="moonshotai/kimi-k2-instruct"
Starting Claude Code
With installation and configuration complete, you can now start Claude Code in your project directory. Navigate to your desired project location using the cd
command:
cd <your-project-directory\>
claude .
The dot (.) parameter instructs Claude Code to operate in the current directory. Upon startup, you’ll see the Claude Code prompt appear in an interactive session.
This indicates the tool is ready to receive your instructions. The interface provides a clean, intuitive environment for natural language programming interactions.
Building Your First Project
Claude Code excels at transforming detailed project descriptions into functional applications. After entering your prompt, press Enter to begin the task. Claude Code will analyze your requirements, create the necessary files, implement the functionality, and provide a complete project structure with documentation.
Here’s an example of how to create a Python Flask web app with MBTI personality guessing game:
Using Claude Code in VSCode or Cursor
Claude Code integrates seamlessly with popular development environments. It enhances your existing workflow rather than replacing it.
You can use Claude Code directly in the terminal within VSCode or Cursor. This maintains access to your familiar development tools while leveraging AI assistance.
Additionally, Claude Code plugins are available for both VSCode and Cursor. These plugins provide deeper integration with these editors, offering inline AI assistance, code suggestions, and project management features directly within your IDE interface.
The terminal integration allows you to run Claude Code commands without leaving your development environment. This creates a streamlined workflow for AI-assisted development.
Help and Documentation Resources
Claude Code includes comprehensive help documentation accessible through the /help
command. This command displays available commands, usage examples, and troubleshooting information.
The help system is context-aware, providing relevant information based on your current project and session state.
For additional support, Novita AI provides extensive documentation . This covers advanced configuration options, API usage patterns, and best practices.
The Anthropic documentation offers detailed information about Claude Code’s capabilities and features.
Conclusion
Kimi-K2 integration with Claude Code through Novita AI delivers enterprise-grade capabilities at significantly reduced costs. The combination transforms natural language descriptions into functional code, dramatically accelerating development workflows. Start your journey with Kimi-K2 and Claude Code today to experience the future of AI-assisted programming.
Novita AI is an AI cloud platform that offers developers an easy way to deploy AI models using our simple API, while also providing the affordable and reliable GPU cloud for building and scaling.
Subscribe to my newsletter
Read articles from NovitaAI directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
