Kursus
Kimi K2.7 Code is Moonshot’s flagship coding model, built for practical software development tasks such as writing and debugging code, navigating larger codebases, and handling multi-step engineering work.

Source: Kimi K2.7 Code: Open-Source Agentic Coding Model
Paired with Pi, a lightweight and highly extensible coding agent, it creates a flexible local development environment that supports skills, packages, command-line tools, persistent memory, and browser testing without adding unnecessary complexity.
Instead of installing an MCP for every task, Pi can combine Kimi’s reasoning with reliable developer tools such as GitHub CLI, Vercel CLI, Hugging Face CLI, pytest, Ruff, and uv.
This makes it possible to research, build, test, deploy, and maintain real projects from a single coding-agent workflow.
In this guide, I will show you how to set up Kimi K2.7 Code with Pi from start to finish.
You will configure your Moonshot API key, add Olostep for research, Context7 for up-to-date documentation, Webwright for browser testing, and Hermes Memory for cross-session context.
You will also install useful themes and engineering skills, connect practical CLIs for GitHub, Vercel, and Hugging Face, create a reproducible Python data-science project, and test the complete workflow by building, validating, and publishing a small machine learning application.
I also recommend checking out my guide on how to run Kimi K2.7 Code locally.
1. Install the Pi Coding Agent in Your Terminal
Pi is a lightweight coding agent that runs directly in your terminal.
It can work with your local files, run commands, use installed skills and packages, and connect to your preferred coding model.
Choose the installation command for your operating system.
Windows PowerShell
powershell -c "irm https://pi.dev/install.ps1 | iex"
macOS or Linux
curl -fsSL https://pi.dev/install.sh | sh
You can also install Pi through npm:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
2. Configure Your Moonshot API Key for Kimi K2.7
Before using Kimi K2.7 Code in Pi, add your Moonshot API key as an environment variable.
Pi can then access the key automatically when you select Moonshot as your model provider.
Windows PowerShell
setx MOONSHOT_API_KEY "your_moonshot_api_key"
Close and reopen PowerShell after running this command. The new environment variable will only be available in newly opened terminal sessions.
Git Bash, macOS, or Linux
export MOONSHOT_API_KEY="your_moonshot_api_key"
This command only applies to the current terminal session. To keep the key available after restarting your terminal, add the same line to your shell profile, such as ~/.bashrc or ~/.zshrc.
Keep your API key private. Do not add it to Git repositories, public notebooks, screenshots, .env.example files, or AGENTS.md.
Once the key is set, launch Pi:
pi
Then open the model selector:
/model

Choose moonshotai as the provider and select kimi-k2.7-code.
Pi should automatically detect the MOONSHOT_API_KEY environment variable and use it for authentication.
3. Install Olostep Skills for Research
Olostep gives Pi access to research workflows for web search, scraping, documentation crawling, debugging, and structured data extraction.
It helps Pi find current information when a task requires more than the model’s built-in knowledge.
Before continuing, create an Olostep account, generate an API key, and save it locally as an environment variable named OLOSTEP_API_KEY.
This allows Pi and any scripts it creates to authenticate with Olostep without storing secrets in your project files.
Next, install the Olostep skills directly into Pi’s global skills directory:
npx -y olostep-cli@latest add skills \
--no-global \
--agent-skills-dir ~/.pi/agent/skills

It installs Olostep skills into:
~/.pi/agent/skills/
After installation, Pi can follow the Olostep research workflow when you ask it to investigate a topic, find current documentation, compare tools, crawl a website, or collect structured information from the web.
Depending on your setup, Pi can use the configured Olostep API workflow directly or generate scripts that call the API when needed.
You should create a free Context7 account and API key, then save it locally as CONTEXT7_API_KEY.
The Pi package itself installs without a key, but Context7’s official API documentation says API requests require authentication.
Their GitHub docs describe the key as recommended for higher limits, but for a reliable Pi setup, set it before using the documentation tools.
4. Install Context7 for Current Documentation
Context7 gives Pi access to current, version-specific library documentation and code examples. This helps prevent outdated API usage when Pi is working with fast-moving frameworks, SDKs, and Python packages.
Before installation, create a Context7 account, generate an API key from the Context7 dashboard, and save it locally as an environment variable named CONTEXT7_API_KEY.
Keep the key private and do not commit it to your repository or include it in screenshots, notebooks, or project instruction files.
Install the official Context7 package for Pi:
pi install npm:@upstash/context7-pi
This adds Context7 documentation tools, a skill that guides Pi to use them when needed, and the /c7-docs command for manual lookups.
After restarting Pi, it can retrieve relevant documentation before writing code that depends on external libraries.

5. Customize Your Terminal Workspace with Pi Themes
Pi supports third-party theme packages, making it easy to improve the terminal interface without changing how the agent works.
The @spences10/pi-themes package includes several polished dark themes, including Catppuccin Mocha, Dracula, Gruvbox Dark, Nord, One Dark, and Tokyo Night.
Install the community theme package:
pi install npm:@spences10/pi-themes
Then open Pi:
pi
Open the settings menu:
/settings

Select Catppuccin Mocha from the available themes. It is a clean, dark theme with strong contrast and is a good default for longer coding sessions.
You can switch themes at any time through /settings. Pi also supports locally stored themes and package-based themes, so you can customize the interface later without changing your model, tools, or project setup.
6. Add Engineering Skills and Reduce Noisy Output
Pi can be extended with reusable engineering workflows that make it more consistent when planning, debugging, testing, reviewing code, writing documentation, and preparing projects for handoff or release.
The @barlevalon/skills package provides portable SKILL.md workflows for these common software engineering tasks.
Install the skills package:
pi install npm:@barlevalon/skills

Next, install Hypa to keep long terminal output from taking over Pi’s context window:
pi install npm:@hypabolic/pi-hypa
Hypa automatically rewrites supported shell commands through a local compression layer. It keeps important evidence, such as errors and final results, while reducing repetitive logs from package installations, test suites, model runs, builds, and deployments.
The Pi package also installs Hypa as a dependency and creates a best-effort local hypa command shim.
7. Use Direct CLIs for GitHub, Vercel, and Hugging Face
You do not need an MCP, extension, or package for every service you use.
For common workflows such as managing repositories, deploying an application, checking logs, or publishing a model, an authenticated command-line tool is often simpler, more reliable, and easier for Pi to use.
GitHub CLI
GitHub CLI lets Pi work with repositories, pull requests, issues, releases, and GitHub Actions directly from the terminal. Install it on Windows with:
winget install --id GitHub.cli --source winget
Then sign in:
gh auth login
Use GitHub CLI when you want Pi to inspect a repository, create or review pull requests, check workflow runs, manage issues, or publish a project to GitHub.
Vercel CLI
Vercel CLI lets Pi deploy web applications, inspect projects, view deployment logs, and manage environment variables from the terminal.
npm install -g vercel
vercel login
Use Vercel CLI for preview deployments, production releases, deployment troubleshooting, project linking, and environment-variable checks.
Hugging Face CLI
The current Hugging Face command-line tool is hf, which is included with the huggingface_hub package. Install it with:
pip install -U huggingface_hub
Then authenticate:
hf auth login
Use Hugging Face CLI to create and manage model, dataset, and Space repositories; upload project files; download models or datasets; and confirm which account is currently authenticated.
8. Add Browser Testing with Webwright
Unit tests are useful for checking Python logic, but they do not show whether a real user can use your application.
Webwright lets Pi run browser-based tests with Playwright against local or deployed apps, including Streamlit, Gradio, FastAPI front ends, React or Next.js projects, Vercel previews, and Hugging Face Spaces.
Install Webwright in Pi:
pi install npm:pi-webwright
Then install Chromium for Playwright:
npx playwright install chromium

Webwright lets Pi open the app in Chromium, test the main user flow, interact with forms or file uploads, check that results render correctly, inspect browser errors, and save screenshots and logs.
The package includes a browser-testing skill designed for inspectable, artifact-based workflows.
9. Give Your AI Agent Persistent Memory with Hermes
Pi starts each new session with limited context from earlier work.
Hermes Memory adds local, persistent memory so Pi can search previous sessions, retain useful project context, consolidate repeated information, and scan for secrets.
It runs locally, so you do not need a separate hosted-memory API key.
Install Hermes Memory:
pi install npm:pi-hermes-memory
Restart Pi after installation.

Use Hermes Memory alongside clear project documentation:
- MEMORY.md: project facts, preferences, and instructions you want to review and commit
- docs/decisions/: important architecture, data, and engineering decisions stored with the repository
- pi-hermes-memory: local cross-session recall, searchable session history, and automatic memory consolidation
Keep MEMORY.md and docs/decisions/ as the visible source of truth for your project.
Hermes Memory helps Pi continue work across sessions, while Markdown files make the context easy for you or another contributor to inspect later.
10. Build a Reproducible Python Data Science Project
A strong Pi setup also needs a clear project structure.
This keeps your experiments, code, tests, data, and results organized, so Pi can make changes without mixing temporary notebook work with reusable pipeline code.
Create a new project and initialize it with uv:
mkdir data-science-pi-project
cd data-science-pi-project
uv init
uv add pandas scikit-learn matplotlib pytest ruff
Use this structure:
data-science-pi-project/
├── AGENTS.md
├── MEMORY.md
├── README.md
├── src/
│ ├── data.py
│ ├── train.py
│ └── evaluate.py
├── tests/
├── notebooks/
├── data/
│ ├── raw/
│ └── processed/
├── reports/
│ ├── figures/
│ └── metrics/
└── docs/
└── decisions/
Keep reusable data loading, preprocessing, training, and evaluation code in src/.
Use notebooks/ only for exploration and quick experiments.
Store unchanged source files in data/raw/, cleaned data in data/processed/, and save charts, metrics, and model outputs in reports/.
Create an AGENTS.md file so Pi follows the right workflow when working in the repository:
# Project Rules
- Use Olostep for current research and Context7 for library documentation.
- Inspect the dataset, missing values, duplicates, leakage risks, class balance, and baseline before training.
- Keep reusable logic in `src/`, not notebooks.
- Add tests when changing preprocessing or evaluation behaviour.
- Run formatting, linting, and tests before declaring work complete.
- Record important decisions in `docs/decisions/`.
This gives Pi a repeatable workflow for building data-science projects that are easier to test, maintain, and improve.
11. End-to-End Test: Building an ML App with Kimi and Pi
Now it is time to test the complete Pi setup in a real project. For this example, I asked Pi to build a reproducible binary classification application for student placement prediction using factors such as academic performance, internships, projects, certifications, and skills.
Start Pi from inside your project folder:
pi
Then give Pi the following prompt:
Build a simple, reproducible Python machine-learning project for a binary classification problem.
First inspect the dataset for schema, missing values, duplicates, categorical columns, leakage risks, class balance, and a suitable stratified train/test split.
Use Olostep for any current research or dataset references, and Context7 before using scikit-learn APIs.
Create clear modules for data loading/preprocessing, model training, evaluation, tests, a short README, and project rules.
Use a fixed random seed, uv, pytest, and Ruff.
After the model workflow works, build a small Streamlit or Gradio interface and test it in Chromium with Webwright, including the main user journey, result rendering, console errors, screenshots, and logs.
Report accuracy, weighted F1, macro F1, a baseline comparison, and a confusion matrix. Initialize and push the repository with GitHub CLI.

Pi first checked Hermes Memory for any earlier context related to the project.
As shown in the screenshot, it did not find anything useful, so it moved on to inspect the current project directory.

Once Pi understood the directory structure, it used Context7 to check the current Python and scikit-learn documentation before writing the project files.
This is useful because it helps the agent use current APIs instead of relying on outdated examples.

Next, Pi used the Olostep research skill to look for a suitable dataset and gather relevant information for the project.

After collecting enough context, it started creating the files one by one, including the preprocessing pipeline, training code, evaluation script, tests, README, and project instructions.

After the machine learning workflow was complete, Pi created a small Streamlit application.
It then installed Chromium for Playwright and used Webwright to test the interface in a real browser.
The browser test checked the main user flow, verified that results rendered correctly, inspected console errors, and saved screenshots and logs.
Pi also ran the Python tests and project checks before generating the final summary.

In this test, the final model achieved about 86% accuracy and a 0.85 F1 score.
Pi then committed the changes, created a GitHub repository, and pushed the complete project to GitHub.
The repository includes the README, project structure, source code, tests, model evaluation files, and Streamlit application:

Source: kingabzpro/data-science-pi-project
You can run the application locally with:
streamlit run app.py

The interface is clean and easy to navigate, and the model returns predictions quickly.

More importantly, this test shows the value of the full setup: Pi can research the task, inspect the data, use current documentation, build the pipeline, create an interface, test the browser experience, validate the model, and publish the finished project from one workflow.
Final Thoughts: Why Kimi K2.7 and Pi Make the Perfect Developer Stack
Kimi K2.7 Code and Pi proved to be a powerful combination for practical coding work.
Kimi is fast, capable, and handles multi-step engineering tasks well without overcomplicating straightforward decisions.
If you are using the API instead of a coding subscription, adding at least $10 in credits is worth considering to access the higher usage tier and avoid hitting daily limits too quickly.
What impressed me most was how little manual coordination the workflow needed once everything was set up.
After giving Pi one detailed prompt, it checked Hermes Memory for relevant project context, reviewed the project directory, used Context7 to verify current Streamlit and scikit-learn documentation, and used Olostep to research the dataset and problem setup.
It then created the project files, built the machine learning pipeline, developed the Streamlit app, and tested the interface with Webwright and Playwright.
Pi also ran the Python tests, checked the model metrics, reviewed browser behavior, generated a final summary, committed the changes, and pushed the completed repository to GitHub.
If you want to dive deeper into how AI agents work under the hood? I recommend DataCamp’s Building Scalable Agentic Systems course to learn the design principles, testing frameworks, and protocols (like MCP) required to take AI agents from proof-of-concept to production.
FAQs
How much does Kimi K2.7 Code cost to run via API?
Kimi K2.7 Code is highly competitive for a flagship agentic model, priced at approximately $0.74 per 1M input tokens and $3.50 per 1M output tokens. Because agentic workflows and 256K context windows can consume tokens quickly during autonomous research, using compression tools like Hypa (as recommended in this guide) is a great way to keep API costs down.
Can I run Kimi K2.7 Code entirely locally on my own hardware?
Yes, but you will need serious hardware. Kimi K2.7 Code is a massive 1T-parameter MoE (Mixture-of-Experts) model. Even if you use heavily quantized GGUF versions (such as Unsloth’s Dynamic 2-bit quantization), you will need a workstation with roughly 310GB to 345GB of combined RAM/VRAM (e.g., a high-end Mac Studio or a multi-GPU rig) running llama.cpp or Unsloth Studio. For most developers, the API method detailed in this guide is vastly more accessible.
How does the Pi agent handle context limits during long coding sessions?
This guide covers Hermes Memory for remembering things across different days or projects, but Pi also has built-in protection for your current session. Pi features an automatic background compaction system. If your ongoing terminal session starts approaching the model's context limit, Pi quietly compresses and summarizes the older chat history. This ensures the agent does not crash or lose its train of thought during complex, multi-step data science workflows.
Am I locked into Moonshot AI if I use the Pi Coding Agent?
No. One of Pi's biggest strengths is its flexibility. If Kimi K2.7 Code experiences an outage or you want to experiment with a different model family for a specific task, Pi natively supports OpenAI, Anthropic, DeepSeek, Google Gemini, Groq, xAI, and OpenRouter. You can switch models instantly during a session by typing /model or pressing Ctrl+L to open the provider selector.
As a certified data scientist, I am passionate about leveraging cutting-edge technology to create innovative machine learning applications. With a strong background in speech recognition, data analysis and reporting, MLOps, conversational AI, and NLP, I have honed my skills in developing intelligent systems that can make a real impact. In addition to my technical expertise, I am also a skilled communicator with a talent for distilling complex concepts into clear and concise language. As a result, I have become a sought-after blogger on data science, sharing my insights and experiences with a growing community of fellow data professionals. Currently, I am focusing on content creation and editing, working with large language models to develop powerful and engaging content that can help businesses and individuals alike make the most of their data.

