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

# Opencode

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

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

Opencode authenticates one of these ways:

* **OpenCode Go subscription:** connect an OpenCode Go API key from OpenCode Zen.
* **Aster API key:** use Aster's OpenAI-compatible inference.
* **OpenRouter API key:** bring your own OpenRouter key for pay-as-you-go model routing.
* **OpenAI-compatible endpoint:** any endpoint that serves the OpenAI Responses API, and its models. See [setup](https://docs.replicas.dev/admin/credentials.md#openai-compatible-alternative).

Within a [credential scope](https://docs.replicas.dev/admin/credentials.md#scopes), authentication priority is OpenCode Go, Aster, OpenRouter, then an OpenAI-compatible endpoint. Any personal key wins over every organization one.

## 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://app.replicas.dev/dashboard/agents) during onboarding or anytime later, expand **Inference providers → 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](https://docs.replicas.dev/admin/credentials.md) and injects it into OpenCode workspaces.

Set org-level credentials for the whole team, or connect a personal subscription in [Personal → Coding Agents](https://app.replicas.dev/dashboard/account/agents) that takes priority over org defaults. Add up to 10 keys from different OpenCode Go subscriptions and drag them into the order to use them, as with [multiple accounts](https://docs.replicas.dev/admin/credentials.md#multiple-accounts). **Disconnect** removes every stored key.

> [!NOTE]
>
> Connecting an organization key refreshes warm workspaces so the new credentials take effect. Model usage bills to the OpenCode Go account that owns the key in use. When that subscription hits its limit, the chat moves to the next OpenCode Go key. With no other key, Replicas stops the turn and shows the provider message in chat.

## OpenRouter API Key

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

The OpenRouter key and enabled-model selection are 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 and Aster are preferred when connected. Otherwise, Opencode uses the available personal or organization OpenRouter key.

See [Credentials](https://docs.replicas.dev/admin/credentials.md) 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.

## Aster API Key

Use one Aster API key for Opencode and Pi.

1. Create a key in the [Aster console](https://asterlab.ai/inference/console).
2. Paste it under **Opencode → Aster API Key** or **Pi → Aster API Key** in Coding Agents settings.

Keys start with `sk_aster_`. Aster uses `https://api.asterlab.ai/v1` for OpenAI-compatible inference.

## Models

The workspace model picker follows the active Opencode credential. OpenCode Go starts with GLM 5.3, Kimi K3, DeepSeek V4.1 Flash, and MiniMax M3. Organization admins can add or remove models under **Inference providers → OpenCode Go → Models** in [Coding Agents settings](https://app.replicas.dev/dashboard/agents). The selection is shared with [Pi](https://docs.replicas.dev/features/coding-agents/pi.md#models). Settings lists the active [OpenCode catalog](https://models.dev/), excluding alpha and deprecated models.

With OpenCode Go, Settings also lists [OpenCode Zen](https://opencode.ai/docs/zen/)'s free models, such as DeepSeek V4.1 Flash Free (`opencode/deepseek-v4.1-flash-free`). They need no other key, run only in Opencode, and stay free only while OpenCode offers them. Some of their providers keep prompts to improve the model; see [Zen privacy](https://opencode.ai/docs/zen/#privacy).

If every selected OpenCode Go model is retired, Replicas keeps your selection until an admin enables a replacement; it never enables an unrelated model automatically.

Aster provides:

| Model ID |
| - |
| `kimi-k3` |
| `glm-5.2` |
| `gpt-oss-120b-fast` |
| `gpt-oss-120b` |

With OpenRouter, organization admins choose which models appear in the workspace picker. Expand **Opencode → OpenRouter models** in [Coding Agents settings](https://app.replicas.dev/dashboard/agents) and select models from the connected OpenRouter account, listed by weekly popularity. This controls visibility only; saved defaults, [automations](https://docs.replicas.dev/features/automations.md), and [API requests](https://docs.replicas.dev/features/api.md) can use other models available to the connected account.

Until an admin changes the selection, the picker shows:

| Model ID | Label | Notes |
| - | - | - |
| `z-ai/glm-5.3` | GLM 5.3 | Default |
| `deepseek/deepseek-v4-pro-0813` | DeepSeek V4 Pro | Flagship V4 coding model |
| `moonshotai/kimi-k3` | Kimi K3 | Multimodal coding model |
| `google/gemini-3.8-flash` | Gemini 3.8 Flash | Fast multimodal Google model |

Enable additional models under **OpenRouter models** in [Coding Agents settings](https://app.replicas.dev/dashboard/agents). Saved organization selections take precedence over these defaults.

Set the default model under [Organization → Settings → Preferences](https://app.replicas.dev/dashboard/settings?tab=defaults) or per-user in [Personal → Preferences](https://app.replicas.dev/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](https://docs.replicas.dev/features/environments.md#mcps)
* Create branches, commits, and pull requests
* Use [Plan Mode](https://docs.replicas.dev/features/workspaces/plan-mode.md) to propose a plan before changing code
* Load repository skills when the runtime can discover them

Replicas grants Opencode full tool permissions inside disposable workspace VMs, so actions do not pause for per-command approval. Before each tool runs, Replicas applies your organization's security policies and returns any block reason to the agent.

Opencode does **not** support [Fast Mode](https://docs.replicas.dev/features/workspaces/fast-mode.md) or 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 [Canvas](https://docs.replicas.dev/features/workspaces/plan-mode.md#view-plans-in-canvas) before asking it to implement.

### Provider errors

When inference fails upstream, the chat reports the provider, model, HTTP status, and any response detail the provider returned. Transient server errors add a retry hint; Opencode already retries them automatically before the turn fails.

### Chat history

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

## Programmatic Use

Select Opencode anywhere Replicas accepts a coding agent:

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

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.replicas.dev/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.3"
  }'
```

## 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 DeepSeek V4, GLM 5.3, MiniMax M3, MiMo V2.5 Pro, and Kimi K3 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, goal mode, Cursor Composer, or Fast Mode.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.