cover_image: https://aiwave.live/images/cover_04_developer_guide.png
title: Using DeepSeek API with OpenCode CLI in Your Terminal
published: true
tags: ai, aiwave, deepseek, cli, developer-tools
Published: 2026-07-07 | Category: Developer Tools | Reading Time: 8 min
If you live in the terminal, you want your AI coding assistant to live there too. OpenCode CLI is a terminal-based coding assistant that works with any OpenAI-compatible API. Pair it with DeepSeek's models through AIWave, and you get a fast, cheap, and powerful coding workflow — no browser, no IDE plugin, just your shell.
This guide covers installation, configuration, model selection, and practical usage patterns.
OpenCode is an open-source terminal AI assistant. It provides:
It's designed for developers who prefer vim/neovim or just don't want another Electron app eating RAM.
OpenCode is distributed as a standalone binary. Install it via your preferred method:
# macOS / Linux (Homebrew)
brew install opencode
# Or download directly
curl -fsSL https://opencode.dev/install.sh | bash
# Go users
go install github.com/opencode-ai/opencode@latest
Verify installation:
$ opencode --version
opencode v1.x.x
OpenCode needs an API key and base URL:
https://aiwave.live/v1OpenCode reads configuration from environment variables. Set them in your shell profile:
# ~/.bashrc or ~/.zshrc
export OPENCODE_API_BASE="https://aiwave.live/v1"
export OPENCODE_API_KEY="sk-your-aiwave-key-here"
export OPENCODE_MODEL="deepseek-v4-flash"
Reload your shell:
source ~/.bashrc
For Windows (PowerShell), add to your profile:
# In $PROFILE (run: notepad $PROFILE)
$env:OPENCODE_API_BASE = "https://aiwave.live/v1"
$env:OPENCODE_API_KEY = "sk-your-aiwave-key-here"
$env:OPENCODE_MODEL = "deepseek-v4-flash"
Test that OpenCode can reach the API:
$ opencode chat "Say 'connection successful' and nothing else"
If configured correctly, you'll see the response in your terminal. If you get an authentication error, double-check your API key and base URL.
Different models serve different purposes in a terminal workflow. Here's how to configure model switching.
The best default for terminal use:
export OPENCODE_MODEL="deepseek-v4-flash"
For complex refactoring or architecture questions:
# Switch for a single session
OPENCODE_MODEL="deepseek-v4-pro" opencode chat "Refactor this module to use a pub/sub pattern"
# Pricing: $0.42 input / $0.84 output per 1M tokens
# HumanEval: 92.1%
# Context: 1M tokens
DeepSeek V4 Pro is the flagship — 92.1% HumanEval, beating GPT-4o's 90.2%. Use it when accuracy matters more than cost.
For debugging and logic puzzles:
export OPENCODE_MODEL="deepseek-r1"
# Pricing: $0.605 input / $2.409 output per 1M tokens
# Context: 128K tokens
DeepSeek R1 uses chain-of-thought reasoning. It's slower and more expensive, but produces step-by-step reasoning that's invaluable for tracking down subtle bugs.
export OPENCODE_MODEL="glm-4.7-flash"
# Pricing: FREE ($0.00/$0.00)
# Context: 128K tokens
# HumanEval: 72.5%
GLM-4.7 Flash is completely free — zero cost per token. Not the strongest coder, but at $0.00/1M you can use it as much as you want. Use it for quick lookups and simple questions.
Pipe code directly to OpenCode for explanation:
# Explain a function from your codebase
grep -A 20 "def process_order" app/orders.py | opencode chat "Explain this function"
# Explain a shell command
opencode chat "Explain this command: find . -name '*.py' -exec grep -l 'import os' {} \;"
Describe what you want in plain English:
$ opencode chat "Find all Python files modified in the last 7 days and print their sizes"
# Response: find . -name "*.py" -mtime -7 -exec ls -lh {} \; | awk '{print $5, $9}'
Feed a file for review:
$ opencode file-review app/auth.py
# OpenCode reads the file and provides inline review comments
$ opencode chat "Generate a FastAPI endpoint that accepts a JSON payload with user_id (int) and action (str), validates with Pydantic, and returns a status dict"
Expected output:
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field
app = FastAPI()
class ActionRequest(BaseModel):
user_id: int = Field(..., gt=0)
action: str = Field(..., min_length=1, max_length=100)
@app.post("/action")
async def handle_action(req: ActionRequest):
try:
# Process the action here
return {"status": "ok", "user_id": req.user_id, "action": req.action}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
$ git diff --staged | opencode chat "Write a concise conventional commit message for this diff"
If you frequently switch models, create shell functions:
# Add to ~/.bashrc or ~/.zshrc
oc() {
local model="${OPENCODE_MODEL:-deepseek-v4-flash}"
local cmd="$1"
shift
case "$cmd" in
flash) OPENCODE_MODEL="deepseek-v4-flash" opencode "$@" ;;
pro) OPENCODE_MODEL="deepseek-v4-pro" opencode "$@" ;;
reason) OPENCODE_MODEL="deepseek-r1" opencode "$@" ;;
budget) OPENCODE_MODEL="glm-4.7-flash" opencode "$@" ;;
coder) OPENCODE_MODEL="qwen3-coder-480b-a35b-instruct" opencode "$@" ;;
*) opencode "$@" ;;
esac
}
# Usage:
# oc flash chat "explain this regex"
# oc coder file-review main.py
# oc reason chat "find the bug in this function: ..."
Terminal interactions tend to be shorter than IDE chat sessions. Here's a realistic monthly estimate:
| Usage Pattern | Avg Tokens per Call | Calls/Day | Model | Monthly Cost |
|---|---|---|---|---|
| Quick questions | 1K/500 | 20 | DeepSeek V4 Flash | ~$0.01 |
| Code generation | 3K/2K | 10 | Qwen3 Coder | ~$0.01 |
| Code review | 8K/2K | 5 | DeepSeek V4 Pro | ~$0.03 |
| Debugging | 5K/3K | 3 | DeepSeek R1 | ~$0.03 |
| Misc (free model) | — | — | GLM-4.7 Flash | $0.00 |
Total: ~$0.08/month. Compare this to Cursor at $20/month or Copilot at $10/month — that's 250× to 250× cheaper.
If you use Neovim, you can integrate OpenCode through its command interface:
-- In your Neovim config
vim.keymap.set('v', 'oc', ':!'
.. 'opencode chat "Explain the selected code and suggest improvements"')
Select code in visual mode, press , and OpenCode opens in a terminal split with the analysis.
Connection timeout: AIWave servers are in Singapore. If you're in North America or Europe and see >2s latency, try the free GLM-4.7 Flash ($0.00/1M) for latency-sensitive tasks — it routes through the same endpoint but responses are faster due to smaller model size.
Rate limiting: AIWave's budget tier has rate limits. If you hit them, consider upgrading. Check pricing for details.
JSON parse errors: Ensure your base URL is exactly https://aiwave.live/v1 with no trailing slash or path additions.
Terminal AI isn't a novelty — for developers who live in the shell, it's the most natural interface. DeepSeek's models deliver GPT-4o-level coding quality at a fraction of the cost, and OpenCode makes it seamless.
We're a small team behind AIWave. No VC money, no big marketing budget — just a few people who believe Chinese AI models should be accessible to everyone in the world. Your API calls keep this project alive. If you find value in what we're building, stick around. It means more than you know.