Use DeepSeek in OpenCode and Aider
Updated 2026-10-18 · Terminal coding agents on DeepSeek, GLM and more: an opencode.json example and Aider's two environment variables.
Connection details
- Base URL (OpenAI compatible)
- https://api.aifans.fan/v1
- API key
- Create one in the console; it starts with sk- (no account yet? sign up)
- Recommended models
- deepseek-v4.1-flash, deepseek-v4-pro (all models and prices)
OpenCode and Aider are open-source coding agents that run in your terminal. Both accept any OpenAI-compatible API.
OpenCode
Put your key in an environment variable:
# macOS / Linux export AIFANS_API_KEY="YOUR_API_KEY" # Windows PowerShell $env:AIFANS_API_KEY = "YOUR_API_KEY"
Then write opencode.json in your project (or ~/.config/opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"aifans": {
"npm": "@ai-sdk/openai-compatible",
"name": "AIFans API",
"options": { "baseURL": "https://api.aifans.fan/v1", "apiKey": "{env:AIFANS_API_KEY}" },
"models": {
"deepseek-v4.1-flash": { "name": "deepseek-v4.1-flash" },
"deepseek-v4-pro": { "name": "deepseek-v4-pro" }
}
}
},
"model": "aifans/deepseek-v4.1-flash"
}
Run opencode; type /models inside it to switch to the other models in the file.
Aider
Aider talks to OpenAI-compatible APIs through two environment variables; prefix the model name with openai/:
export OPENAI_API_BASE="https://api.aifans.fan/v1" export OPENAI_API_KEY="YOUR_API_KEY" aider --model openai/deepseek-v4.1-flash
Aider may warn that it does not know the model's context size or price; that is harmless. Your real cost is in the console's Usage page.