Skip to main content
OpenCode is a terminal-based AI coding agent. You can point it at Consus Gateway to get Claude in your terminal while keeping all traffic within government-authorized cloud environments.

1. Set Your API Key

Add your Consus Gateway API key as an environment variable:
export CONSUS_API_KEY="your-api-key-here"
Add this to your ~/.zshrc or ~/.bashrc to persist it.

2. Configure OpenCode

Add the following to your opencode.json config file:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "consus": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Consus Gateway",
      "options": {
        "baseURL": "https://api.consus.io/v1",
        "headers": {
          "x-api-key": "{env:CONSUS_API_KEY}"
        }
      },
      "models": {
        "claude-3-7-sonnet:il5": {
          "name": "Claude 3.7 Sonnet (IL5)",
          "attachment": true,
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "claude-sonnet-4-5:il5": {
          "name": "Claude Sonnet 4.5 (IL5)",
          "attachment": true,
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "gemini-2-5-pro:il5": {
          "name": "Gemini 2.5 Pro (IL5)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "gemini-2-5-flash:il5": {
          "name": "Gemini 2.5 Flash (IL5)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        }
      }
    }
  }
}

3. Select the Model

Launch OpenCode and use the /models command to verify Consus Gateway models appear. Select one and start coding.
opencode
That’s it. Your requests now route through Consus Gateway to government-authorized cloud infrastructure. Streaming, tool use (file reads, writes, shell commands), multi-turn conversations, and image input all work out of the box.

Image & PDF Input

Claude and Gemini models support images and PDF documents. The config above already includes the required fields:
  • attachment: true: enables file/image attachments in OpenCode’s UI
  • modalities.input: ["text", "image", "pdf"]: tells OpenCode the model accepts image and PDF input
Note: These fields are required for custom providers. Without them, OpenCode intercepts attachments client-side and replaces them with an error before they ever reach the server. They are currently undocumented in the official OpenCode docs.
Paste a screenshot (Ctrl+V / Cmd+V) or attach a PDF using the attachment button. Images and files must be under 3.5 MB each; total base64 data per message (images + files combined) must be under 4.5 MB (enforced by the Lambda payload ceiling). Only application/pdf is supported for file attachments.