Configure OpenCode to use OpenDunes as its model provider, billed in DA.
OpenCode is an open-source, terminal-based coding agent with full support for custom OpenAI-compatible endpoints. Pointing it at OpenDunes takes one config change and gives you access to any model in the catalog, billed in Algerian Dinars.
OpenCode picks up the standard OpenAI base URL and key variables:
export OPENAI_BASE_URL="https://opendunes.com/v1"
export OPENAI_API_KEY="$OPENDUNES_API_KEY"Add these to your shell profile for a permanent setup:
# ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://opendunes.com/v1"
export OPENAI_API_KEY="sk-0a1b2c3d..."OpenCode also reads a opencode.json config file. Create or update it in your home directory or project root:
{
"provider": {
"openai": {
"baseUrl": "https://opendunes.com/v1",
"apiKey": "${OPENDUNES_API_KEY}"
}
},
"model": "anthropic/claude-opus-4.8"
}The ${OPENDUNES_API_KEY} syntax reads from your environment at runtime — your key never sits in plain text in the config file.
Pass a model flag when invoking OpenCode, or set it in opencode.json. Use the provider/model slug from the OpenDunes catalog:
opencode --model anthropic/claude-opus-4.8 "Add input validation to the registration form"Models with the tools capability work best with OpenCode's agentic loop (file reads, writes, shell execution). Check the models page for the capability filter.
opencode --model anthropic/claude-sonnet-5 "What files are in the current directory?"OpenCode should list directory contents by invoking a shell tool, then return the summary. Check Dashboard → Analytics to confirm the request was routed through OpenDunes.
OpenCode agentic sessions can generate many sequential requests. Create a dedicated key with a spend cap to keep costs predictable:
opencode, set a budget (e.g., 400 DA = 4,000,000 micro-DA).OPENAI_API_KEY.When the budget is exhausted, OpenCode will receive a 402 (payment_required) and halt. Raise the cap or add DA to continue.
| Symptom | Likely cause | Fix |
|---|---|---|
401 authentication | OPENAI_API_KEY not set in the current shell | Re-export the variable |
404 not_found | Wrong slug format | Use provider/model format (e.g., openai/gpt-5.4) |
OpenCode ignores OPENAI_BASE_URL | Config file is overriding env var | Check opencode.json for a conflicting baseUrl |
402 payment_required | Key cap spent or balance at zero | Top up at Dashboard → Billing |