Using Aegis With Agents
Configure OpenCode, Cline, and Claude Code Router with one Aegis key, and understand the current Codex limitation.
OpenCode
OpenCode talks to Aegis through the `@ai-sdk/openai-compatible` adapter, registered as a custom provider. The setup is four short steps: install OpenCode, generate an Aegis key, write the config file, then launch and pick a model.
Each step below has the exact command or file you need. Follow them in order.
Step 1: Install
Install OpenCode from the official installer. The command below works on macOS, Linux, and WSL.
Run the following command:
- Verify the install with `opencode --version`.
- Prefer a modern terminal (WezTerm, Alacritty, Ghostty, Kitty) for the best experience.
curl -fsSL https://opencode.ai/install | bashStep 2: Generate An Aegis API Key
You need an Aegis API key before configuring OpenCode. The full `aegis_...` value is shown only once at creation time.
- Sign in to Aegis.
- Open Console > API Keys.
- Enter a label such as `opencode` or `Local dev`.
- Click `Generate Key`, then copy the `aegis_...` value immediately.
- Store the key somewhere safe — you will not be able to see it again.
Step 3: Configure The Custom Provider
Open (or create) the OpenCode config file and register Aegis as a custom provider. Replace `your_aegis_api_key_here` with the key you copied in Step 2.
Run the following command to open the config file:
- Create the config directory if it does not exist: `mkdir -p ~/.config/opencode`.
- Copy the following snippet and paste it into the file.
- Replace the `apiKey` value with your real `aegis_...` key from Step 2.
- Set `"model"` to the model ID you want as the default — for example `aegis/glm-5.2`.
- Save and exit (`Ctrl-O`, `Enter`, `Ctrl-X` in nano).
nano ~/.config/opencode/opencode.jsonc~/.config/opencode/opencode.jsonc
{
"$schema": "https://opencode.ai/config.json",
"model": "aegis/glm-5.2",
"provider": {
"aegis": {
"name": "Aegis",
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.aegisrouter.com/v1",
"apiKey": "your_aegis_api_key_here"
},
"models": {
"glm-5.2": {
"name": "GLM-5.2",
"limit": {
"context": 1048560,
"output": 128072
}
}
}
}
}
}Step 4: Launch And Pick A Model
You are ready to use OpenCode against Aegis. Launch it from a project directory and switch models from the built-in model picker when needed.
Run the following commands:
- Initialize it for the project on first run: `/init`.
- To switch models, use the model picker (default keybinding `/`) and select `aegis/glm-5.2`.
- Send a prompt to confirm traffic flows through Aegis.
cd /path/to/project
opencode
# In the OpenCode TUI:
# /init # create AGENTS.md on first run
# /model # switch to aegis/glm-5.2Cline
Cline supports OpenAI-compatible providers directly from its settings panel.
- Open the Cline settings panel.
- Set `API Provider` to `OpenAI Compatible`.
- Set `Base URL` to `https://proxy.aegis.dev/v1`.
- Paste your `aegis_...` key into the API key field.
- Enter a model ID from the Aegis Models page, such as `glm-5.2` or `qwen3.6-35b`.
Claude Code
Claude Code does not speak the OpenAI format directly. Route it through `claude-code-router`, then send that router to Aegis's chat completions endpoint.
Shell
npm install -g @anthropic-ai/claude-code
npm install -g @musistudio/claude-code-router
export AEGIS_API_KEY="aegis_..."~/.claude-code-router/config.json
{
"Providers": [
{
"name": "aegis",
"api_base_url": "https://proxy.aegis.dev/v1/chat/completions",
"api_key": "$AEGIS_API_KEY",
"models": ["glm-5.2", "qwen3.5-397b", "kimi-k2.7-code"]
}
],
"Router": {
"default": "aegis,glm-5.2",
"background": "aegis,glm-5.2"
}
}Codex CLI
Codex CLI currently expects the OpenAI Responses API. Aegis currently documents and supports the OpenAI-compatible chat completions shape, not a direct Responses API integration.
That means you should not point Codex CLI at Aegis yet and expect full support. Use OpenCode, Cline, or Claude Code Router today for coding-agent workflows over the Aegis endpoint.