OpenCode Harness Integration
Configure OpenCode CLI to use Interference as its high-speed AI inference provider.
OpenCode × Interference
OpenCode is an autonomous terminal-based AI coding assistant. Because Interference implements the standard OpenAI chat-completions API with streaming Server-Sent Events (SSE) and full tool-calling support, OpenCode can use Interference as a custom provider with zero proxy overhead.
1. Prerequisites
- OpenCode CLI installed (
opencode --version) - An Interference account with a live API key (
sk_live_...) - Positive credit balance in your account (Top up in Console via instant UPI or Card)
2. Configuration Setup
OpenCode allows you to define custom providers in your configuration file using the @ai-sdk/openai-compatible adapter.
You can configure Interference either globally (for all projects) or locally (for a specific repository):
- Global Config:
~/.config/opencode/opencode.json(oropencode.jsonc) - Project-Level Config:
opencode.jsonlocated at the root of your project
opencode.json Configuration
Add the interference provider block under the provider section:
Configuration Details
| Field | Value | Description |
|---|---|---|
npm | @ai-sdk/openai-compatible | Uses the standard OpenAI-compatible wire adapter. |
options.baseURL | https://api.interference.dev/v1 | Points to Interference's inference gateway. |
options.apiKey | {env:INTERFERENCE_API_KEY} | Safely references your API key from your environment without hardcoding secrets in version control. |
models | Object mapping | Defines model IDs recognized by Interference to human-readable names in OpenCode's picker. |
3. Set Your API Key
Export your Interference live key in your shell profile (~/.bashrc, ~/.zshrc, or Windows PowerShell profile):
Alternatively, you can authenticate using the OpenCode CLI credential store:
4. Verify & Select Models
Once your configuration is saved and your environment variable is exported:
- Open OpenCode in your project terminal:
- Type
/modelsinside the OpenCode session to open the interactive model picker. - You will see Interference listed with your configured models (
kimi-k2.7-code,glm-5.3-flash,qwen3-coder, etc.). - Select your preferred model, or launch directly into a task with the model flag:
5. Tool Calling & Streaming
OpenCode relies heavily on autonomous multi-step tool execution (editing files, executing shell commands, reading file trees).
Interference supports standard OpenAI tool calls and streaming token reconstruction seamlessly:
- Instant Chunk Aggregation: Partial tool arguments streamed over Server-Sent Events (SSE) are delivered without truncation.
- Two-Phase Credit Hold: Credits are reserved safely before execution and settled strictly for tokens produced. If OpenCode cancels a stream midway (e.g. user hits
Ctrl+C), unused reservations are released back to your balance immediately.
6. Troubleshooting
| Issue | Potential Cause | Resolution |
|---|---|---|
Provider 'interference' not found | Syntax error in opencode.json | Ensure opencode.json is valid JSON and located in your root directory or ~/.config/opencode/opencode.json. |
401 Unauthorized | Invalid or missing API key | Ensure INTERFERENCE_API_KEY is set and begins with sk_live_.... |
402 Payment Required | Zero or insufficient balance | Top up credits in the Interference Console. |
429 Too Many Requests | Concurrency limit reached | Check that you don't have parallel background tasks flooding the gateway. |