Documentation/Using Agent

Models & connectivity

Providers, credentials, model selection, and MCP.

The loop speaks one internal event format. Adapters translate vendor streams into text, supplied thinking, tool calls, and completion usage.

Supported connections

Provider IDConnection
openaiOPENAI_API_KEY
anthropicANTHROPIC_API_KEY
geminiGEMINI_API_KEY
openrouterOPENROUTER_API_KEY
opencodeDirect Zen API with OPENCODE_API_KEY, or the local CLI without it
codexStored OAuth, CODEX_ACCESS_TOKEN, or Codex CLI credential import
antigravityStored Google OAuth or ANTIGRAVITY_ACCESS_TOKEN
opencode-cliLocally installed, connected OpenCode CLI

The prefix identifies the adapter; the remainder identifies the model. The OpenCode CLI has a nested reference such as opencode-cli/opencode/beam-free. Direct opencode uses the Zen API when OPENCODE_API_KEY is set and this same local CLI transport when it is not; opencode-cli always uses the local CLI.

API keys

For Bash or Zsh:

bash
export OPENROUTER_API_KEY="your-key"
agent

For PowerShell:

powershell
$env:OPENROUTER_API_KEY="your-key"
agent

The auth manager checks environment credentials before the local store, normally ~/.myagent/auth.json. Do not commit this file or paste its contents into an issue.

Existing CLI logins

The Codex factory can import an existing CLI credential when an agent credential is missing. For OpenCode, install and sign in to OpenCode first; /model then browses what it serves.

OAuth login flows require configured client IDs: MYAGENT_CODEX_CLIENT_ID, or MYAGENT_GOOGLE_CLIENT_ID and the Google client secret where required. This project does not embed vendor client IDs. Use your own registered configuration and respect provider account terms.

Change models mid-conversation

Use /model, search the catalog, and select a model. During a running turn, the choice is staged for the next queued prompt. The footer shows the pending choice. When applied, a “Model changed” marker records the previous and new reference. UI sidecar metadata preserves the marker across resume.

Reasoning-effort choices appear only when advertised in the model catalog. Thinking appears only when the provider supplies it; the UI does not manufacture hidden reasoning.

The OpenCode bridge

OpenCode transport and host-owned tools
Preparing flowchart…
View Mermaid source (.mmd)
flowchart TD
  HOST[Host StreamRequest] --> REPLAY[Serialize conversation and tool specs]
  REPLAY --> GUARD[Load local native-execution guard]
  GUARD --> READY{Fresh guarded agent registered?}
  READY -->|No| FAIL[Stop with CLI configuration error]
  READY -->|Yes| CHILD[Local OpenCode CLI with built-in profile]
  CHILD --> MODEL[Connected model provider]
  MODEL --> JSONL[OpenCode JSONL events]
  JSONL --> FRAME[Assemble lines and normalize snapshots]
  FRAME --> ERR{Provider error?}
  ERR -->|Yes| VISIBLE[Report actionable failure]
  ERR -->|No| PROTOCOL[Parse text, thinking, or host tool request]
  PROTOCOL --> LOOP[Host agent loop]
  LOOP --> PERMISSION[Validate and check permissions]
  PERMISSION --> TOOL[Execute host tool]
  TOOL --> HOST
Download .mmd source

The adapter runs the locally installed OpenCode CLI through a private server of its own that lives as long as the provider does: opencode run --standalone starts a fresh server for every turn and pays its startup before the model is even asked, while one server for the session pays it once. The server is the adapter's — the user's background service and global configuration are never touched — and it is stopped when the provider closes.

The host agent is defined in the configuration handed to that server, not installed as a plugin. A plugin has to be resolved, activated and registered before the server will answer, and an OpenCode that has not finished activating answers "Location plugins did not finish activating", losing ten seconds or sometimes the whole turn. A configuration agent is there the moment the server is.

The agent has a prompt of its own and no native tool: every native tool of the agent is off, so the tools of the host are run by the host, under the permissions of the host. A model that asks for a tool of the CLI anyway is refused by it, and the call is run by the host instead; a model that writes the call as text is read as text. The user's own configuration is kept and added to — their model, their provider and their plugins still apply — and the host agent is added on top, inheriting the profile of the agent it is named after (build by default). It does not forge provider headers, reset quotas, or call the OpenCode inference API from Agent.

The outer loop applies the same permission and schema checks as other providers, and replay retains tool calls and their results.

This integration was verified against local OpenCode 2.3.0. Check opencode --version in the same shell that launches Agent. On Windows, Get-Command opencode -All can reveal multiple npm/pnpm installations. Set MYAGENT_OPENCODE_COMMAND to an absolute executable or shim path when PATH selects an older installation. No OpenCode API key is required for this local CLI transport; its existing login and model access apply.

The adapter assembles complete JSONL lines across stdout chunks, normalizes snapshots by part ID, surfaces JSON errors even on exit zero, and rejects empty responses. It supports cancellation and a two-minute process deadline. A quota failure is an upstream error, not a request to retry forever.

Connect external tools

MCP is a tool connection, not a model provider. Configure local stdio or remote HTTP servers in .myagent/mcp.json. Tools become server__tool and retain host permission checks. See extensions.

Costs and data

Access and quotas belong to the connected account. Usage is displayed when reported; estimates depend on model pricing metadata. Messages, relevant code, and tool results may be sent to the provider. This website does not connect to model accounts.

Improve this pageSource-backed guides · MDX