Ointerference
DOCS
Harnesses & Agents

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 (or opencode.jsonc)
  • Project-Level Config: opencode.json located at the root of your project

opencode.json Configuration

Add the interference provider block under the provider section:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "interference": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Interference",
      "options": {
        "baseURL": "https://api.interference.dev/v1",
        "apiKey": "{env:INTERFERENCE_API_KEY}"
      },
      "models": {
        "deepseek-v4.1-flash": {
          "name": "DeepSeek V4.1 Flash (Ultra Fast & Sub-Cent)"
        },
        "kimi-k2.7-code": {
          "name": "Kimi K2.7 Code (Recommended for Complex Refactoring)"
        },
        "glm-5.3-flash": {
          "name": "GLM 5.3 Flash (Ultra Fast & Sub-Cent)"
        },
        "qwen3.8-flash": {
          "name": "Qwen 3.8 Flash (Specialized Code Synthesis)"
        },
        "gpt-6-luna": {
          "name": "GPT 6 Luna (Sub-Cent Long-Context Reasoning)"
        },
        "claude-haiku-5-5": {
          "name": "Claude Haiku 5.5 (Agentic Tool-Use)"
        },
        "grok-4.7": {
          "name": "Grok 4.7 (Frontier Reasoning)"
        }
      }
    }
  }
}

Configuration Details

FieldValueDescription
npm@ai-sdk/openai-compatibleUses the standard OpenAI-compatible wire adapter.
options.baseURLhttps://api.interference.dev/v1Points 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.
modelsObject mappingDefines 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):

# Linux / macOS
export INTERFERENCE_API_KEY="sk_live_YOUR_ACTUAL_KEY_HERE"
# Windows PowerShell
$env:INTERFERENCE_API_KEY = "sk_live_YOUR_ACTUAL_KEY_HERE"

Alternatively, you can authenticate using the OpenCode CLI credential store:

opencode auth login
# Follow the interactive prompt and enter your Interference API key when prompted

4. Verify & Select Models

Once your configuration is saved and your environment variable is exported:

  1. Open OpenCode in your project terminal:
    opencode
  2. Type /models inside the OpenCode session to open the interactive model picker.
  3. You will see Interference listed with your configured models (kimi-k2.7-code, glm-5.3-flash, qwen3-coder, etc.).
  4. Select your preferred model, or launch directly into a task with the model flag:
    opencode --model interference:kimi-k2.7-code

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

IssuePotential CauseResolution
Provider 'interference' not foundSyntax error in opencode.jsonEnsure opencode.json is valid JSON and located in your root directory or ~/.config/opencode/opencode.json.
401 UnauthorizedInvalid or missing API keyEnsure INTERFERENCE_API_KEY is set and begins with sk_live_....
402 Payment RequiredZero or insufficient balanceTop up credits in the Interference Console.
429 Too Many RequestsConcurrency limit reachedCheck that you don't have parallel background tasks flooding the gateway.

On this page