跪拜 Guibai
← Back to the summary

Pi CLI Agent Paired With DeepSeek-v4-Flash Burns 20M Tokens for Under a Cent

Hello everyone, I'm cxuan.

Today let's talk about Pi. I've been wanting to write about this Agent for a while.

If you're new to Pi, you can think of it as a Coding Agent running in the CLI. Its design philosophy can be summed up in four words — minimalist kernel.

It's as minimalist as Linux 0.11 with only the kernel.

Pi itself only has the most basic tools like read, bash, edit, write.

If you need skills and MCP, you have to install them yourself.

In this article, I'll first talk about Pi, then explain how to connect it to DeepSeek, and finally run Pi + DeepSeek-v4-Flash through a real-world scenario.

What is Pi?

Pi's official positioning is minimal terminal coding harness, which is a minimal Coding Agent. Pi's focus is on harness: it is responsible for running models, providing tools, saving sessions, and allowing you to replace or extend almost every part of the workflow.

image-20260806060937325

The workflow of a basic Pi session is as follows:

image-20260806084506363

Pi's core only provides a few file and Shell tools. Many capabilities that other Coding Agents have, such as Plan Mode, Subagent, browser automation, WebSearch, and custom status bars, need to be added through Extensions, Skills, or Packages.

Pi's core, Skills, Extensions, Packages, and project rules

Pi's design is somewhat similar to VS Code: it prioritizes providing an editing and running framework, and you can expand it through plugins as you wish.

Get Pi installed in five minutes

Enough talk, let me tell you how to install it directly. It's just one command:

npm install -g --ignore-scripts @earendil-works/pi-coding-agent

Enter the project and start:

cd your-project
pi

That's it.

image-20260805230847199

Look at this homepage, it's really damn minimalist, not even a Logo...

On first launch, you can execute:

Some of the most common operations:

You don't need to install any plugins at the beginning; just start experiencing it directly.

Why use Pi

There are so many Coding Agents on the market now, why use Pi? What are its advantages?

I've listed a few points:

First is freedom of model choice. Multi-provider support isn't new anymore, but it's still an advantage for Pi, because many Coding Agents don't natively support other models and need external tools to do so.

Workflow is up to you. Pi doesn't force the use of built-in Plan or Subagent. You can combine them on demand through Skills and Extensions, which ensures high freedom, but the trade-off is that configuration and maintenance are your own responsibility.

Can be embedded into your own system. Besides terminal interaction, Pi also provides JSON, RPC, and TypeScript SDK. It can be used as a Coding Agent, and also as a foundational component for internal bots, automated reviews, or dedicated workbenches.

Skills can be reused across tools. Pi supports the Agent Skills standard and can reuse .agents/skills, Claude Code, and Codex Skills. No need to configure your own skills for every Coding Agent.

So how to choose between Pi, Codex CLI, Claude Code, and Gemini CLI

The only difference is: Official CLIs are more hassle-free, Pi is more free.

How to choose between Pi, Codex CLI, Claude Code, and Gemini CLI

If you don't want to tinker, the official CLI is usually more suitable; if you can't stand tools deciding the model and workflow for you, Pi is what appeals to you.

So if you are a beginner or newbie, Pi is generally not recommended. Pi is more suitable for veterans, geeks who want to tinker themselves.

This reminds me of when I wrote an article about local deployment of DeepSeek-v4-Flash, someone in the comments said:

image-20260806072142293

All I can say is life never stops, tinkering never ends...

Connecting DeepSeek-v4-Flash to Pi

Pi's custom providers are all written in ~/.pi/agent/models.json. Just add a deepseek entry to providers, supporting OpenAI-compatible APIs:

{
  "providers": {
    "deepseek": {
      "baseUrl": "https://api.deepseek.com/v1",
      "api": "openai-completions",
      "apiKey": "sk-your-key",
      "authHeader": true,
      "compat": {
        "supportsStore": false,
        "supportsReasoningEffort": true
      },
      "models": [
        {
          "id": "deepseek-v4-flash",
          "name": "DeepSeek V4 Flash",
          "reasoning": true,
          "input": ["text"],
          "contextWindow": 1000000,
          "maxTokens": 65536,
          "thinkingLevelMap": {
            "off": null,
            "low": "high",
            "medium": "high",
            "high": "high",
            "xhigh": "max",
            "max": "max"
          }
        }
      ]
    }
  }
}

thinkingLevelMap is the essence: DeepSeek only has high/max levels, Pi's low/medium/high will all map to high, xhigh/max map to max.

The apikey can be read from the keychain like I do:

"apiKey": "!security find-generic-password -a lx -s pi-deepseek-api-key -w"

Storing the key in the keychain is just one line:

security add-generic-password -a lx -s pi-deepseek-api-key -w 'sk-your-key'

Then change the defaults to DeepSeek in ~/.pi/agent/settings.json, and every time you open Pi it will be DeepSeek:

{
  "defaultProvider": "deepseek",
  "defaultModel": "deepseek-v4-flash",
  "defaultThinkingLevel": "xhigh"
}

After saving, restart Pi, and use /model (or Ctrl+L) to switch between DeepSeek and GPT with one click, without changing any configuration.

image-20260806080058068

I started my first task, which was to investigate the usage issue of Codex Plus, using DeepSeek to investigate Codex's usage problem... lol.

I recently found that my Codex Plus quota is very insufficient. Since I stopped using the Codex app and started using Pi + CPA connected to GPT-5.6, I burned through a Plus account's weekly quota in the time of one long class.

I was very puzzled, why is it consuming so much quota? It made me suspect that someone was stealing my quota, so I had DeepSeek investigate the reason.

The final investigation result: It wasn't stolen, I just burned through it myself in an hour and a half.

One thing that felt really good during the entire investigation process was that DeepSeek-v4-Flash automatically identifies path dependencies, automatically judges whether the current path is correct, doesn't go too deep, and automatically corrects itself if it judges wrong.

Below is a real thinking process of its automatic judgment at that time.

image-20260806083124683

DeepSeek-v4-Flash's complete report is as follows.

image-20260806075435405

This investigation process was really satisfying. The whole investigation consumed 20M tokens, costing less than 1 yuan. And it was fast.

image-20260806073517971

I thought of a question someone previously asked on Zhihu, my answer was:

image-20260806090208547

A few things that feel smooth about Pi + DeepSeek-v4-Flash:

  1. Cheap enough to run casually: 20M tokens cost less than 1 yuan. For the same investigation scale, GPT directly burned through half a Plus account's weekly quota;
  2. 1M context: Supports long projects and long reports.
  3. Path self-correction: When working, if it finds it has gone down the wrong path, it will automatically backtrack and switch to another, not stubbornly sticking to one path. This is a bit like a real human's troubleshooting process.
  4. Seamless switching on Pi: Supports multiple Providers and model switching.

I think from now on, the GPT account will be kept for heavy tasks, and my daily base will be Pi + DeepSeek-v4-Flash.

This "daily" only lasts until the release of DeepSeek-v4-Pro :)

I was about to publish this article after writing it, then I saw the news from DeepSeek, they're going to raise prices.

ea1e0a9cb93c8c44b807c678415bf5b9

Damn......

Is it too late for me to retract this article now?