> ## Documentation Index
> Fetch the complete documentation index at: https://gateway.consus.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Connect OpenCode to Consus Gateway for AI-assisted coding in government environments.

[OpenCode](https://opencode.ai) 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:

```bash theme={null}
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:

```json theme={null}
{
  "$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-sonnet-4-5:il5+itar": {
          "name": "Claude Sonnet 4.5 (IL5 + ITAR)",
          "attachment": true,
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "claude-opus-4-8:il2": {
          "name": "Claude Opus 4.8 (IL2)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "claude-opus-4-7:il2": {
          "name": "Claude Opus 4.7 (IL2)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "claude-opus-4-6:il2": {
          "name": "Claude Opus 4.6 (IL2)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "claude-sonnet-4-6:il2": {
          "name": "Claude Sonnet 4.6 (IL2)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "claude-haiku-4-5:il2": {
          "name": "Claude Haiku 4.5 (IL2)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "gemini-3-1-pro:il4": {
          "name": "Gemini 3.1 Pro (IL4)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "gemini-3-1-pro:fedramp-high": {
          "name": "Gemini 3.1 Pro (FedRAMP High)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "gemini-3-flash:il4": {
          "name": "Gemini 3 Flash (IL4)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "gemini-3-5-flash:il4": {
          "name": "Gemini 3.5 Flash (IL4)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "gemini-3-5-flash:fedramp-high": {
          "name": "Gemini 3.5 Flash (FedRAMP High)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 8192
          }
        },
        "gpt-5.1:il5+itar": {
          "name": "GPT 5.1 (IL5 + ITAR)",
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "limit": {
            "context": 400000,
            "output": 8192
          }
        },
        "gpt-oss-120b:il5+itar": {
          "name": "GPT OSS 120B (IL5 + ITAR)",
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          },
          "limit": {
            "context": 128000,
            "output": 8192
          }
        },
        "gpt-5.4:il5+itar": {
          "name": "GPT-5.4 (IL5 + ITAR)",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 272000,
            "output": 8192
          }
        }
      }
    }
  }
}
```

## 3. Select the Model

Launch OpenCode and use the `/models` command to verify Consus Gateway models appear. Select one and start coding.

```bash theme={null}
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 gateway's request payload limit). Only `application/pdf` is supported for file attachments.
