Using Aegis With Agents

Configure OpenCode, Cline, and Claude Code Router with one Aegis key, and understand the current Codex limitation.

OpenCode

OpenCode is available as both a terminal interface and a desktop app. Both versions can use the same Aegis provider from your global OpenCode configuration, so you only need to configure Aegis once.

Follow these six steps in order: install the clients you want, create an Aegis key, add the shared provider configuration, then verify the CLI, Desktop, and Aegis Analytics.

The instructions below use the user-level `~/.config/opencode/opencode.jsonc` file so CLI and Desktop share the same provider. Never place your `aegis_...` key in a repository-level config.

Step 1: Install OpenCode CLI, Desktop, Or Both

Choose the OpenCode clients that match your workflow. Install the CLI for terminal sessions, Desktop for a graphical interface, or both if you want to switch between them.

CLI — macOS, Linux, or WSL

curl -fsSL https://opencode.ai/install | bash
opencode --version

Desktop — macOS with Homebrew

brew install --cask opencode-desktop

Step 2: Create Your Aegis API Key

Create a dedicated Aegis key for OpenCode before editing the shared configuration. The full `aegis_...` value is shown only once.

  • Sign in to Aegis.
  • Open Dashboard > API Keys.
  • Enter a clear name such as `OpenCode`.
  • Choose the default service tier and, if needed, set a monthly budget limit.
  • Click `Generate Key`, then copy the `aegis_...` value immediately.
  • Store it securely until you paste it into the global OpenCode configuration in Step 3.
If the key is exposed in a repository, screenshot, log, or shared message, delete it from Aegis and generate a replacement.

Step 3: Configure The Shared Aegis Provider

Register Aegis in the global OpenCode configuration. CLI and Desktop read this same file, so this one provider entry works in both clients.

Create the configuration directory if needed, then open the global config file:

  • Copy the configuration below into `~/.config/opencode/opencode.jsonc`.
  • Replace `your_aegis_api_key_here` with the full key from Step 2.
  • Keep the provider ID as `aegis`; the default model reference `aegis/glm-5.2` depends on that exact ID.
  • Keep the base URL as https://api.aegisrouter.com/v1.
  • Save and exit (`Ctrl-O`, `Enter`, `Ctrl-X` in nano).
  • If OpenCode Desktop is already running, fully quit and reopen it after saving.
This is a user-level file outside your projects. A project-level `opencode.json` or `opencode.jsonc` can override parts of the global configuration, so check both locations if a project behaves differently.
mkdir -p ~/.config/opencode
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 Verify OpenCode CLI

Open a terminal in your project and start OpenCode. Initialize the project on the first run, then select the Aegis model from the model picker.

  • Run `/init` once to analyze the project and create `AGENTS.md`.
  • Run `/models` and select `Aegis > GLM-5.2` (`aegis/glm-5.2`).
  • Send a short prompt and confirm OpenCode returns a response.
Commit the generated `AGENTS.md` when it accurately describes the project. It gives OpenCode persistent repository instructions.
cd /path/to/project
opencode

# In the OpenCode TUI:
#   /init
#   /models

Step 5: Launch And Verify OpenCode Desktop

Open OpenCode Desktop after saving the shared configuration. Desktop runs its own local OpenCode process but reads the same user-level provider configuration as the CLI.

  • Fully quit and reopen Desktop if it was running while you edited `opencode.jsonc`.
  • Open or select the project folder you want to work in.
  • Open the model picker and select `Aegis > GLM-5.2` (`aegis/glm-5.2`).
  • Start a new session and send a short prompt.
  • If you installed both clients, you do not need to paste the Aegis key a second time.

Step 6: Confirm Usage And Troubleshoot

After a successful CLI or Desktop prompt, open Aegis Dashboard > Analytics and confirm the request appears. This verifies that OpenCode is using Aegis rather than another configured provider.

  • Missing provider: confirm the global config is at `~/.config/opencode/opencode.jsonc` and the provider ID is exactly `aegis`.
  • Authentication error: replace `your_aegis_api_key_here` with the real key copied in Step 2.
  • Missing model: confirm `glm-5.2` exists under `provider.aegis.models`, then reopen `/models` or restart Desktop.
  • Wrong model in one project: check that project's `opencode.json` or `opencode.jsonc` for an override.
  • Desktop still shows old settings: fully quit the application, reopen it, and load the project again.
  • No Analytics event: confirm the endpoint is exactly https://api.aegisrouter.com/v1, send another prompt, and refresh Analytics.
The screenshots for these steps will be added after the final CLI and Desktop images are provided.

Cline

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://api.aegisrouter.com/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`.
If Cline asks for optional model metadata such as context window, pricing, or image support, use the values listed on the Aegis Models page.

Claude Code

Claude Code Router (CCR) connects Claude Code to Aegis. CCR runs a local gateway at `127.0.0.1:3456`, sends Claude Code requests to Aegis's OpenAI-compatible endpoint, and translates the responses back for Claude Code.

The current CCR Desktop setup uses a guided wizard: Choose provider, Add credentials, Pick models, Verify connection, Connect agent, then Let's start.

Watch the setup demo
The YouTube URL is a placeholder until the demo is published. Keep the CCR Desktop App open while you use Claude Code because it hosts the local gateway.

Step 1: Download Claude Code Router Desktop

Open the Claude Code Router Releases page, expand `Assets`, and download the installer for your operating system.

  • macOS Apple Silicon: choose the `arm64` DMG.
  • macOS Intel: choose the `x64` DMG.
  • Windows: choose the `.exe` installer.
  • Linux: choose the `.AppImage` file.
  • Install the app, launch it, and leave it running.
Download the installer itself, not a blockmap or source-code archive.
Claude Code Router GitHub release assets showing macOS, Windows, and Linux downloads
Expand the release assets and choose the installer that matches your operating system and processor.

Step 2: Download Claude Code

Install Claude Code as a desktop app, a command-line tool, or both. CCR can configure both entry modes.

  • Desktop: open claude.com/download, download the app for your OS, and install it.
  • CLI: run the native installer for your operating system below, then verify the installation with `claude --version`.
  • If you want to use Claude Code from both the desktop app and your terminal, install both.
Official Claude download page with the Claude desktop download button
Download the Claude desktop app from the official Claude website, or use the CLI installer shown in this step.

macOS, Linux, or WSL

curl -fsSL https://claude.ai/install.sh | bash
claude --version

Windows PowerShell

irm https://claude.ai/install.ps1 | iex
claude --version

Step 3: Create An Aegis API Key

Sign in to Aegis, open `API Keys`, and create a key for Claude Code. The full `aegis_...` value is shown only once, so copy it immediately.

  • Enter a clear key name, such as `Claude Code`.
  • Choose the default service tier you want this key to use.
  • Optionally set a monthly budget limit.
  • Click `Generate Key`, copy the full key, and store it securely.
Never commit your `aegis_...` key to version control. If it leaks, delete it from API Keys and generate a replacement.
Aegis API Keys page with the Claude Code key creation form
Create a dedicated Aegis key for Claude Code and copy it as soon as it is generated.

Step 4: Configure The Aegis Provider

Open CCR Desktop. On a fresh install, the Configure provider wizard opens automatically. Otherwise, open `Providers`, click `Add`, and choose `Other / custom API endpoint`.

  • Name: `aegis` (or another short, clear provider name).
  • API endpoint: https://api.aegisrouter.com/v1.
  • Click `Next step`, select `API key`, and paste the `aegis_...` key from Step 3.
  • Do not select `Credential pool` unless you intentionally want CCR to rotate between multiple Aegis keys.
The endpoint must end with `/v1`, not `/v1/chat/completions`. CCR adds the request path automatically.
Claude Code Router Configure provider wizard with Aegis selected as a custom API endpoint
Choose `Other / custom API endpoint`, name the provider `aegis`, and enter the exact Aegis `/v1` endpoint.

Step 5: Pick Models And Verify The Connection

On `Pick models`, move the Aegis models you want to the Added models column. Continue to `Verify connection` and run `Check Connection` before creating the Claude Code profile.

  • If Provider models loads normally, select `glm-5.2` or any other supported model you want to expose.
  • If it says `No provider models`, click `Custom model`, enter `glm-5.2` exactly, and confirm it. You do not need to wait for automatic discovery.
  • On `Verify connection`, wait for the protocol check, then click `Check Connection` to send a small real request.
  • Continue only after the connection succeeds.
A failed model-discovery list does not mean the Aegis endpoint is unavailable. Adding the model manually lets the connection check proceed.
Claude Code Router Pick models screen with glm-5.2 added as a custom model when provider discovery is empty
Fresh install fallback: add `glm-5.2` as a custom model if CCR does not automatically load the provider model list.

Step 6: Connect The Claude Code Profile

On `Connect agent`, create the Claude Code profile using the settings below. The new CCR interface calls this an Agent Profile.

  • Agent: `Claude Code`.
  • Profile name: `Claude Code`.
  • Effect scope: `System default`.
  • Entry mode: `CLI & APP` when both are installed; otherwise select the entry mode you use.
  • Default model: `aegis/glm-5.2`.
  • Fable, Opus, Sonnet, and Haiku model aliases are optional. Leave them on `Keep Claude Code default` unless you want explicit per-alias routing.
  • Click `Next step` and make sure Provider and Profile both show a green check on `Let's start`.
Do not choose `CLI only` if you expect the Claude desktop app to use the profile. After setup, you can edit or enable the profile from `Agent Profiles`.
Claude Code Router Connect agent screen configured for Claude Code, System default, CLI and app, and the Aegis glm-5.2 model
Use `System default`, select the entry modes you installed, and choose `aegis/glm-5.2` as the Default model.

Step 7: Start CCR And Test Claude Code

Click `Let's start`. CCR should start its local endpoint at `http://127.0.0.1:3456`. Leave CCR Desktop running, open Claude Code in the desktop app or terminal, select an Aegis model if prompted, and send a short test request.

  • Confirm the Claude Code profile is enabled under `Agent Profiles`.
  • Send a short prompt, then open Aegis Dashboard > Analytics and confirm the request appears.
  • `EADDRINUSE: address already in use 127.0.0.1:3456` means another CCR process already owns the port. Quit the duplicate Desktop or CLI instance, then start one CCR instance.
  • `400 All target providers failed` is a CCR wrapper error. Open `Logs` and inspect the target attempt, then recheck the `/v1` endpoint, Aegis key, selected model ID, and detected protocol.
  • If only the CLI works, edit the profile and change Effect scope to `System default` and Entry mode to `CLI & APP`, then fully restart Claude.
If you rotate or delete the Aegis key, edit the provider in CCR and paste the replacement key before testing again.
curl http://127.0.0.1:3456/

# Then launch Claude Code and send a short test prompt.
Claude Code Router Let's start screen showing a configured provider, profile, service, and local endpoint
Provider and Profile should be ready before CCR starts the local endpoint at `127.0.0.1:3456`.

Connecting Claude Desktop Directly (No Router)

Aegis also exposes a native Anthropic-compatible `/v1/messages` endpoint, so Claude Desktop and other Anthropic-native clients can connect directly without CCR.

Point the client at the Aegis base URL, send your `aegis_...` key as `x-api-key`, and set the model to any Claude-style alias — Aegis normalizes `claude-3-5-sonnet-latest`, `claude-sonnet-*`, `claude-opus-*`, `claude-haiku-*`, and `claude-ccr-*` probes to the upstream `glm-5.2` model automatically.

The direct `/v1/messages` path is best suited for Claude Desktop and custom Anthropic SDK clients. For the Claude Code CLI specifically, the CCR Desktop App setup above remains the documented path because Claude Code does not yet expose a configurable base URL override natively.
curl https://api.aegisrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $AEGIS_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-3-5-sonnet-latest",
    "system": "You are a concise coding assistant.",
    "messages": [{"role": "user", "content": "Say hello from Aegis."}],
    "max_tokens": 128,
    "stream": false
  }'

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.

When Aegis adds a supported Responses API surface, this page should be expanded with a `~/.codex/config.toml` example.