DeepSeekDSH
Independent community guideNot affiliated with DeepSeek.Download versions and guide references

Configure DeepSeek API for Pi Coding Agent

Pi Agent is a lightweight terminal autonomous coding agent. Follow these steps to configure DeepSeek models in models.json and manage API credentials.

On this page
Prerequisites

Ensure the pi CLI tool is installed and obtain an API key from the DeepSeek Platform.

STEP 1

Edit the models.json configuration file

Locate or create models.json in your user home directory:

  • macOS / Linux: ~/.pi/agent/models.json
  • Windows: %USERPROFILE%\.pi\agent\models.json

Add the DeepSeek OpenAI-compatible provider definition:

{ "providers": { "deepseek": { "baseUrl": "https://api.deepseek.com", "api": "openai-completions", "apiKey": "$DEEPSEEK_API_KEY" } } }
STEP 2

Configure API key credentials

Export the key in your shell profile (~/.zshrc or ~/.bashrc):

export DEEPSEEK_API_KEY="sk-your_deepseek_api_key"

For Windows PowerShell sessions:

$env:DEEPSEEK_API_KEY="sk-your_deepseek_api_key"

Or save the key directly in ~/.pi/agent/auth.json:

{ "deepseek": { "type": "api_key", "key": "sk-your_deepseek_api_key" } }
STEP 3

Launch and select model

  1. Run pi in your terminal.
  2. Press Ctrl+P or type /model to open the selector.
  3. Choose deepseek and select deepseek-chat or deepseek-reasoner.
  4. Send a non-destructive verification prompt:
Reply only with "DeepSeek connected to Pi Agent successfully." Do not modify files.

Status bar balance tracker

Install the community balance widget to inspect remaining API credits in your status line:

pi install git:github.com/carlos-reynosa/pi-deepseek-balance-status

Troubleshooting

MISSING_CREDENTIAL Error

Verify that DEEPSEEK_API_KEY is exported in the active session before launching pi, or verify auth.json.

Connection Refused / Malformed URL

Ensure baseUrl is exactly https://api.deepseek.com with the https:// scheme and no trailing slash.

402 Insufficient Balance

Top up credit balance on the DeepSeek Platform.

References