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

# Opencode

> Run Opencode agents in Replicas workspaces with OpenCode Go or OpenRouter.

Replicas supports [Opencode](https://opencode.ai) as a first-class coding agent alongside Claude Code, Codex, Cursor, and [Pi](/features/coding-agents/pi). Opencode chats run inside your workspace VM, with the same repository access and integrations as other agents.

Opencode authenticates one of two ways:

* **OpenCode Go subscription:** connect an OpenCode Go API key from OpenCode Zen.
* **OpenRouter API key:** bring your own OpenRouter key for pay-as-you-go model routing.

When both are configured, OpenCode Go is used and OpenRouter is the fallback.

## OpenCode Go Subscription

OpenCode Go uses your OpenCode Go subscription for Opencode's hosted open-source models. Create an API key in OpenCode Zen and store it in Coding Agents settings.

1. Open [Organization → Coding Agents](https://tryreplicas.com/dashboard/agents) during onboarding or anytime later, expand **Opencode → OpenCode Go**, and click **Connect OpenCode Go**.
2. Paste the API key from your OpenCode Zen account.
3. Replicas stores the key in the credential [vault](/admin/credentials) and injects it into OpenCode workspaces.

Set org-level credentials for the whole team, or connect a personal subscription in [Personal → Coding Agents](https://tryreplicas.com/dashboard/account/agents) that takes priority over org defaults. Use **Reconnect OpenCode Go** to replace the key, or **Disconnect** to remove the stored subscription.

<Note>
  Connecting or reconnecting an organization subscription refreshes warm workspaces so the new credentials take effect. Model usage bills to the connected OpenCode Go account.
</Note>

## OpenRouter API Key

Use an OpenRouter API key instead of, or as a fallback to, OpenCode Go.

The OpenRouter key is shared with Pi. Neither OpenCode Go nor OpenRouter uses an OAuth flow like Claude Code or Codex.

1. Create an API key from the [OpenRouter keys page](https://openrouter.ai/keys).
2. Paste it under **Opencode → OpenRouter API Key** in Coding Agents settings. The same credential also appears under **Pi → OpenRouter API Key**.

OpenCode Go is preferred when connected. If it is not connected, Opencode uses the available personal or organization OpenRouter key.

See [Credentials](/admin/credentials) for scope details and auth behavior.

<Note>
  OpenCode Go usage follows your subscription limits. OpenRouter usage bills to the OpenRouter account that owns the key.
</Note>

## Models

The workspace model picker follows the active Opencode credential. With an OpenCode Go key, it reads the active `opencode-go` entry from the [OpenCode catalog](https://models.dev/) and omits models marked alpha or deprecated. Without a Go key, Opencode and Pi share these OpenRouter model slugs through the workspace picker and [API](/features/api):

| Model ID               | Label         | Notes                       |
| ---------------------- | ------------- | --------------------------- |
| `z-ai/glm-5.2`         | GLM 5.2       | Default                     |
| `minimax/minimax-m3`   | MiniMax M3    | Long-context agentic coding |
| `xiaomi/mimo-v2.5-pro` | MiMo V2.5 Pro | Agent-focused Xiaomi model  |
| `moonshotai/kimi-k2.6` | Kimi K2.6     | Multimodal coding model     |

Set the default model under [Organization → Settings → Preferences](https://tryreplicas.com/dashboard/settings?tab=defaults) or per-user in [Personal → Preferences](https://tryreplicas.com/dashboard/account/preferences). Each workspace remembers the model selected for Opencode in the composer's harness/model picker.

Thinking levels use Opencode's native model variants when the selected model exposes a matching variant. Models without a matching variant use Opencode's model default.

## Using Opencode in Workspaces

Every workspace can have multiple chats. Pick **Opencode** from the composer's harness/model picker to start or continue an Opencode session.

Opencode agents can:

* Read and edit files in the cloned repository
* Run shell commands in the workspace VM
* Use environment [MCP servers](/features/environments#mcps)
* Create branches, commits, and pull requests
* Use [Plan Mode](/features/workspaces/plan-mode) to propose a plan before changing code
* Load repository skills when the runtime can discover them

Replicas pre-approves Opencode tool permissions inside disposable workspace VMs, so these actions do not pause for per-command approval.

Opencode does **not** support [Fast Mode](/features/workspaces/fast-mode) or Codex goal mode (`/goal`).

### Plan Mode

Start a message with `/plan` or toggle plan mode in the composer. Opencode runs in plan mode and returns a structured plan you can review in the [Canvas tab](/features/workspaces/plan-mode#viewing-plans-in-the-canvas-tab) before asking it to implement.

### Chat history

Opencode chat history persists across turns and survives workspace sleep. Use `replicas read` from the [CLI](/features/cli) to inspect transcript history from your terminal.

## Programmatic Use

Select Opencode anywhere Replicas accepts a coding agent:

| Surface                                                                                                      | How to choose Opencode                                                      |
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| [CLI](/features/cli)                                                                                         | `-a opencode` on `replicas create` and `replicas send`                      |
| [API](/features/api)                                                                                         | `"coding_agent": "opencode"` on create and message requests                 |
| [MCP](/features/mcp)                                                                                         | `"coding_agent": "opencode"` on `create_replica` and `send_replica_message` |
| [Automations](/features/automations)                                                                         | Set **Coding agent** to Opencode in the automation editor                   |
| [Slack](/features/slack), [Linear](/features/linear), [GitHub](/features/github), [GitLab](/features/gitlab) | Set Opencode as the [default coding agent](/admin/defaults)                 |

Example CLI:

```bash theme={null}
replicas create fix-tests \
  -e backend \
  -a opencode \
  -m "Fix the failing test suite"
```

Example API:

```bash theme={null}
curl -X POST "https://api.tryreplicas.com/v1/replica" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "fix-tests",
    "environment_id": "ENVIRONMENT_UUID",
    "message": "Fix the failing test suite",
    "coding_agent": "opencode",
    "model": "z-ai/glm-5.2"
  }'
```

## When to Use Opencode

Opencode is a strong fit when:

* You want to bill against an OpenCode Go subscription with a single API key
* You want OpenRouter-backed model routing inside Replicas workspaces
* You want to compare GLM 5.2, MiniMax M3, MiMo V2.5 Pro, and Kimi K2.6 on the same repository
* You want a non-Claude, non-OpenAI model family for implementation and iteration

Claude Code, Codex, and Cursor remain better choices when you need provider-specific features like Claude background tasks, Codex goal mode, Cursor Composer, or Fast Mode.
