Skip to content

How to use uncensored abliterated models with Pi coding agent

A models.json that adds abliterated DeepSeek and GLM models to the Pi coding agent, and the fix for its 401 error. Tested on Pi 1.7.0.

Published Updated 4 min read

Pi is a small terminal coding agent that reads custom providers from a models.json file, so you can run it on an uncensored, abliterated model. We set up Pi 1.7.0 against CommentLLM's abliterated DeepSeek V4.1 Flash model and gave it a real bug to fix. It fixed it and the tests passed.

The short version: add a commentllm provider to ~/.pi/agent/models.json with baseUrl set to https://api.commentllm.com/v1, api set to openai-completions and apiKey set to "$COMMENTLLM_API_KEY", with the dollar sign. Then run pi --provider commentllm --model deepseek-v4.1-flash-abliterated.

How a coding agent connects to an abliterated model: the agent sends prompts to the CommentLLM API, which passes them to the model and returns its tool calls

What you need

  • Pi. We used version 1.7.0, installed with npm install -g @earendil-works/pi-coding-agent. The older @mariozechner/pi-coding-agent package stops at 0.73.1.
  • A CommentLLM API key. Create one under Keys in the console after you sign up and add credit.

Step 1: put your key in an environment variable

export COMMENTLLM_API_KEY="cllm_..."

Step 2: write ~/.pi/agent/models.json

{
  "providers": {
    "commentllm": {
      "baseUrl": "https://api.commentllm.com/v1",
      "api": "openai-completions",
      "apiKey": "$COMMENTLLM_API_KEY",
      "models": [
        { "id": "deepseek-v4.1-flash-abliterated", "name": "DeepSeek V4.1 Flash Abliterated", "contextWindow": 1048576, "maxTokens": 32768 },
        { "id": "glm-5.3-abliterated", "name": "GLM 5.3 Abliterated", "contextWindow": 1048576, "maxTokens": 32768 }
      ]
    }
  }
}
Setting Why
"api": "openai-completions" Tells Pi to call the OpenAI Chat Completions endpoint
"apiKey": "$COMMENTLLM_API_KEY" The dollar sign makes Pi read the environment variable. See the 401 error below
contextWindow and maxTokens The model's limits, which Pi shows in its footer

Step 3: start Pi

pi --provider commentllm --model deepseek-v4.1-flash-abliterated

A new version prints its changelog on the first run. The footer then shows the model.

Pi 1.7.0 starting on the commentllm provider with deepseek-v4.1-flash-abliterated

Type /model to pick another model, and press Ctrl+S in the picker to save it as the default so you can start with plain pi.

Step 4: give it a task

Our test project had a log-triage script with a bug: it counted failed SSH logins by username instead of by source address, so both tests failed. We asked:

The test suite fails. Run the tests, find the bug in auth_triage.py and fix it. Then run the tests again.

Pi read the files, edited one line and ran pytest: 2 passed. It sent about 14,000 tokens and received about 500.

Pi on DeepSeek V4.1 Flash Abliterated fixing the bug in auth_triage.py, with 2 passed

Pi has no approval prompts. It runs commands and edits files directly, so start it in a sandbox or a project under version control.

The 401 error and other common problems

Our first attempt failed with 401 invalid_api_key.

Pi showing a 401 invalid_api_key error after the key variable's name was sent as the key

We had written "apiKey": "COMMENTLLM_API_KEY". Pi 0.73 treated a bare name as an environment variable, but Pi 1.x sends it as the key itself. Writing "$COMMENTLLM_API_KEY" fixed it.

What you see Why Fix
401 invalid_api_key apiKey holds a bare variable name, which Pi 1.x sends literally Write "$COMMENTLLM_API_KEY" with the dollar sign
A warning about tmux extended-keys Pi needs extended key reporting inside tmux Add set -g extended-keys on to ~/.tmux.conf
npm installs version 0.73.1 That is the old package name Install @earendil-works/pi-coding-agent
A long changelog at start Pi prints it once after an upgrade Nothing to do

Which model to use

Start with deepseek-v4.1-flash-abliterated, the model that fixed the bug here. glm-5.3-abliterated is the one to try for harder reasoning. Both take text only, so image input does not work. If the agent feels slow, switch the model ID to deepseek-v4.1-flash-abliterated-fast: it is the same model served about five times faster, at the same input and output rates and a higher cached-input rate. The pricing page lists every model and its rate.

Run it in a sandbox

Abliterated models refuse far fewer requests than standard ones, and that includes commands an agent should not run on your machine. Try it first in a throwaway project, as we did, and review what the model writes before you ship it.

Setting up a different agent? Uncensored coding AI lists every agent we tested, with a guide for each.

Questions

Can the Pi coding agent use uncensored or abliterated models?

Yes. Pi reads custom OpenAI-compatible providers from models.json. We ran Pi 1.7.0 on DeepSeek V4.1 Flash Abliterated through CommentLLM, and it fixed a failing test.

How do I add a custom provider to Pi?

Add an entry under providers in ~/.pi/agent/models.json with the API's baseUrl, api set to openai-completions, apiKey set to an environment variable written with a dollar sign, and a models list with each model's id, contextWindow and maxTokens.

Why does Pi return 401 invalid_api_key with a custom provider?

In Pi 1.x, an apiKey value without a dollar sign is sent as the key itself. Write the variable as "$COMMENTLLM_API_KEY" so Pi reads it from the environment.

Does Pi ask before it runs commands?

No. Pi 1.7.0 ran commands and edited files without approval prompts in our test, so run it in a sandbox or a project you can restore.

Start building today.

Create an account, tell us what you work on, and send your first request.