---
title: OpenCode
product: vercel
url: /docs/sandbox/ecosystem/opencode
canonical_url: "https://vercel.com/docs/sandbox/ecosystem/opencode"
last_updated: 2018-10-20
type: conceptual
prerequisites:
  - /docs/sandbox/ecosystem
  - /docs/sandbox
related:
  - /docs/sandbox/cli-reference
  - /docs/ai-gateway
  - /docs/sandbox/concepts/firewall
summary: Run OpenCode in Vercel Sandbox from your terminal, or use the plugin for sandbox-backed tools and remote workspaces.
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

# OpenCode

Use [OpenCode](https://opencode.ai) with Vercel Sandbox through the
[Sandbox CLI](/docs/sandbox/cli-reference#run-a-coding-agent) or the
[OpenCode plugin](https://github.com/vercel-labs/opencode-vercel-sandbox).

## Choose how to run OpenCode

| Option | What runs in the sandbox | How you start |
| --- | --- | --- |
| Sandbox CLI | The whole OpenCode session | Run `sandbox create opencode` in your terminal, before entering OpenCode |
| Plugin: automatic tools | Supported shell and file tools; OpenCode and model authentication stay local | Configure automatic mode, then use OpenCode normally. The first supported tool call creates the sandbox automatically |
| Plugin: remote workspace | The OpenCode server and agent tools | Inside OpenCode, enter `/warp` and select **Vercel Sandbox** |

### Start from your terminal

Use the CLI shortcut to run the whole OpenCode session remotely without
installing the plugin. Your local project files aren't uploaded automatically.
See [Run a coding agent](/docs/sandbox/cli-reference#run-a-coding-agent)
for CLI installation, authentication, and reconnecting or stopping the sandbox.

### Use the plugin

Follow the
[plugin setup guide](https://github.com/vercel-labs/opencode-vercel-sandbox#readme)
for installation and supported OpenCode versions. Choose one mode per OpenCode instance.

#### Automatic tools

Use OpenCode normally, with supported shell and file tools running in the sandbox.

- **Review changes:** Ask the agent to run `gitSync`. It waits for changes to return and shows a separate local Git branch to review. Your current branch and working files stay unchanged.
- **Stop:** Ask the agent to run `sandboxStop` to sync changes and stop compute.

#### Remote workspace

Remote workspaces require an [AI Gateway](/docs/ai-gateway) API key.
OAuth and subscription logins aren't supported. Follow the
[workspace guide](https://github.com/vercel-labs/opencode-vercel-sandbox/blob/main/docs/workspace.md)
to connect the key locally and set `remoteConfig.model` to one
`vercel/<provider>/<model>` model.

Inside OpenCode, enter `/warp` and select **Vercel Sandbox**. Changes don't
automatically sync back to your laptop. Use the workspace guide to export
changes and stop the sandbox.

> **💡 Note:** The plugin keeps your AI Gateway key outside the sandbox. Sandbox
> [credential brokering](/docs/sandbox/concepts/firewall#credentials-brokering)
> adds it to requests for your configured model. Code in the sandbox can still
> make billable model requests.

#### Files and cleanup

- Both modes upload committed files and Git history. Uncommitted changes and untracked files stay local. Check your Git history for secrets before starting.
- Exiting OpenCode doesn't stop the sandbox. Stop it explicitly when finished. Retained storage remains billable after compute stops.
- When upgrading from a version that copied credentials, create a fresh workspace. Upgrading doesn't remove credentials from existing sandboxes or snapshots.


---

[View full sitemap](/docs/sitemap)
