OpenCode OpenCode

Usage

OpenCode usage documentation.

Go

Low cost subscription for open coding models.

OpenCode Go is a low cost subscription -- $5 for your first month, then $10/month -- that gives you reliable access to popular open coding models.

Go works like any other provider in OpenCode. You subscribe to OpenCode Go and get your API key. It's completely optional and you don't need to use it to use OpenCode.

It is designed primarily for international users, with models hosted in the US, EU, and Singapore for stable global access.

Background

Open models have gotten really good. They now reach performance close to proprietary models for coding tasks. And because many providers can serve them competitively, they are usually far cheaper.

However, getting reliable, low latency access to them can be difficult. Providers vary in quality and availability.

To fix this, we did a couple of things:

Tip

We tested a select group of models and providers that work well with OpenCode.

  1. We tested a select group of open models and talked to their teams about how to best run them.
  2. We then worked with a few providers to make sure these were being served correctly.
  3. Finally, we benchmarked the combination of the model/provider and came up with a list that we feel good recommending.

OpenCode Go gives you access to these models for $5 for your first month, then $10/month.

How it works

OpenCode Go works like any other provider in OpenCode.

Note

Only one member per workspace can subscribe to OpenCode Go.

  1. You sign in to OpenCode Zen, subscribe to Go, and copy your API key.
  2. You run the /connect command in the TUI, select OpenCode Go, and paste your API key.
  3. Run /models in the TUI to see the list of models available through Go.

The current list of models includes:

The list of models may change as we test and add new ones.

Usage limits

OpenCode Go includes the following limits:

Limits are defined in dollar value. This means your actual request count depends on the model you use. Cheaper models like DeepSeek V4 Flash allow for more requests, while higher-cost models like GLM-5.2 allow for fewer.

Model Request Estimates

Modelrequests per 5 hourrequests per weekrequests per month
GLM-5.28802,1504,300
GLM-5.18802,1504,300
Kimi K2.61,1502,8805,750
Kimi K2.7 Code1,3504,6309,250
MiMo-V2.530,10075,200150,400
MiMo-V2.5-Pro3,2508,15016,300
MiniMax M33,2008,00016,000
MiniMax M2.73,4008,50017,000
Qwen3.7 Max9502,3904,770
Qwen3.7 Plus4,30010,80021,600
Qwen3.6 Plus3,3008,20016,300
DeepSeek V4 Pro3,4508,55017,150
DeepSeek V4 Flash31,65079,050158,150

The estimates are based on observed average request patterns:

Token Usage Patterns

ModelInputCachedOutput
GLM-5.270052,000150
GLM-5.170052,000150
Kimi K2.7/K2.687055,000200
DeepSeek V4 Pro75082,000290
DeepSeek V4 Flash79068,000280
MiniMax M351056,000190
MiniMax M2.730055,000125
MiMo-V2.583071,500295
MiMo-V2.5-Pro79086,000305
Qwen3.7 Max42066,000200
Qwen3.7 Plus50057,000190
Qwen3.6 Plus50057,000190

The estimates are also based on the following prices per 1M tokens:

Pricing (per 1M tokens)

ModelInputOutputCached ReadCached Write
GLM-5.2$1.40$4.40$0.26--
GLM-5.1$1.40$4.40$0.26--
Kimi K2.7 Code$0.95$4.00$0.19--
Kimi K2.6$0.95$4.00$0.16--
MiMo V2.5$0.14$0.28$0.0028--
MiMo V2.5 Pro$1.74$3.48$0.0145--
MiniMax M3$0.30$1.20$0.06--
MiniMax M2.7$0.30$1.20$0.06$0.375
MiniMax M2.5$0.30$1.20$0.06$0.375
Qwen3.7 Max$2.50$7.50$0.50$3.125
Qwen3.7 Plus (<=256K tokens)$0.40$1.60$0.04$0.50
Qwen3.7 Plus (>256K tokens)$1.20$4.80$0.12$1.50
Qwen3.6 Plus (<=256K tokens)$0.50$3.00$0.05$0.625
Qwen3.6 Plus (>256K tokens)$2.00$6.00$0.20$2.50
DeepSeek V4 Pro$1.74$3.48$0.0145--
DeepSeek V4 Flash$0.14$0.28$0.0028--

You can track your current usage in the console.

Tip

If you reach the usage limit, you can continue using the free models.

Usage limits may change as we learn from early usage and feedback.

Usage beyond limits

If you also have credits on your Zen balance, you can enable the Use balance option in the console. When enabled, Go will fall back to your Zen balance after you've reached your usage limits instead of blocking requests.

Endpoints

You can also access Go models through the following API endpoints.

The model id in your OpenCode config uses the format opencode-go/<model-id>. For example, for Kimi K2.7 Code, you would use opencode-go/kimi-k2.7-code in your config.

ModelModel IDEndpointAI SDK Package
GLM-5.2glm-5.2https://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
GLM-5.1glm-5.1https://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
Kimi K2.7kimi-k2.7https://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
Kimi K2.6kimi-k2.6https://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
DeepSeek V4 Prodeepseek-v4-prohttps://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
DeepSeek V4 Flashdeepseek-v4-flashhttps://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
MiMo-V2.5mimo-v2.5https://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
MiMo-V2.5-Promimo-v2.5-prohttps://opencode.ai/zen/go/v1/chat/completions@ai-sdk/openai-compatible
MiniMax M3minimax-m3https://opencode.ai/zen/go/v1/messages@ai-sdk/anthropic
MiniMax M2.7minimax-m2.7https://opencode.ai/zen/go/v1/messages@ai-sdk/anthropic
MiniMax M2.5minimax-m2.5https://opencode.ai/zen/go/v1/messages@ai-sdk/anthropic
Qwen3.7 Maxqwen3.7-maxhttps://opencode.ai/zen/go/v1/messages@ai-sdk/anthropic
Qwen3.7 Plusqwen3.7-plushttps://opencode.ai/zen/go/v1/messages@ai-sdk/anthropic
Qwen3.6 Plusqwen3.6-plushttps://opencode.ai/zen/go/v1/messages@ai-sdk/anthropic

Models

You can fetch the full list of available models and their metadata from:

https://opencode.ai/zen/go/v1/models

Privacy

The plan is designed primarily for international users, with models hosted in the US, EU, and Singapore for stable global access. Our providers follow a zero-retention policy and do not use your data for model training.

Goals

We created OpenCode Go to:

  1. Make AI coding accessible to more people with a low cost subscription.
  2. Provide reliable access to the best open coding models.
  3. Curate models that are tested and benchmarked for coding agent use.
  4. Have no lock-in by allowing you to use any other provider with OpenCode as well.

TUI

Using the OpenCode terminal user interface.

OpenCode provides an interactive terminal interface or TUI for working on your projects with an LLM. Running OpenCode starts the TUI for the current directory.

Terminal window
opencode
Terminal window
opencode /path/to/project

File references

You can reference files in your messages using @. This does a fuzzy file search in the current working directory.

Tip

You can also use @ to reference files in your messages.

Give me a quick summary of the codebase.
How is auth handled in @packages/functions/src/api/index.ts?
Compare our setup with @docs/README.md

The content of the file is added to the conversation automatically. Configured references also appear in @ autocomplete. Type @alias to add the reference root as context, or type @alias/ to autocomplete files inside that reference.

Bash commands

Start a message with ! to run a shell command. The output of the command is added to the conversation as a tool result.

!ls -la

Commands

When using the OpenCode TUI, you can type / followed by a command name to quickly execute actions. For example:

/help

Most commands also have keyboard shortcuts using ctrl+x as the default leader key. Learn more about keybinds.

connect

Add a provider to OpenCode. Allows you to select from available providers and add their API keys.

compact

Compact the current session. Alias: /summarize. Keybind: ctrl+x c

details

Toggle tool execution details.

editor

Open external editor for composing messages. Uses the editor set in your EDITOR environment variable. Keybind: ctrl+x e

exit

Exit OpenCode. Aliases: /quit, /q. Keybind: ctrl+x q

export

Export current conversation to Markdown and open in your default editor. Uses the editor set in your EDITOR environment variable. Keybind: ctrl+x x

help

Show the help dialog.

init

Guided setup for creating or updating AGENTS.md. Learn more about rules.

models

List available models. Keybind: ctrl+x m

new

Start a new session. Alias: /clear. Keybind: ctrl+x n

redo

Redo a previously undone message. Only available after using /undo.

Tip

Any file changes will also be restored. Internally, this uses Git to manage the file changes. So your project needs to be a Git repository.

Keybind: ctrl+x r

sessions

List and switch between sessions. Aliases: /resume, /continue. Keybind: ctrl+x l

share

Share current session. Learn more about sharing.

themes

List available themes. Keybind: ctrl+x t

thinking

Toggle the visibility of thinking/reasoning blocks in the conversation. When enabled, you can see the model's reasoning process for models that support extended thinking.

Note

This command only controls whether thinking blocks are displayed - it does not enable or disable the model's reasoning capabilities. To toggle actual reasoning capabilities, use ctrl+t to cycle through model variants.

undo

Undo last message in the conversation. Removes the most recent user message, all subsequent responses, and any file changes.

Tip

Any file changes made will also be reverted. Internally, this uses Git to manage the file changes. So your project needs to be a Git repository.

Keybind: ctrl+x u

unshare

Unshare current session. Learn more about un-sharing.

Editor setup

Both the /editor and /export commands use the editor specified in your EDITOR environment variable.

Linux/macOS

bash
# Example for nano or vim
export EDITOR=nano
export EDITOR=vim
# For GUI editors, VS Code, Cursor, VSCodium, Windsurf, Zed, etc.
# include --wait
export EDITOR="code --wait"

To make it permanent, add this to your shell profile; ~/.bashrc, ~/.zshrc, etc.

Windows (CMD)

cmd
set EDITOR=notepad
# For GUI editors, VS Code, Cursor, VSCodium, Windsurf, Zed, etc.
# include --wait
set EDITOR=code --wait

To make it permanent, use System Properties > Environment Variables.

Windows (PowerShell)

powershell
$env:EDITOR = "notepad"
# For GUI editors, VS Code, Cursor, VSCodium, Windsurf, Zed, etc.
# include --wait
$env:EDITOR = "code --wait"

To make it permanent, add this to your PowerShell profile.

Note

Some editors like VS Code need to be started with the --wait flag. Some editors need command-line arguments to run in blocking mode. The --wait flag makes the editor process block until closed.

Popular editors

Configure

You can customize TUI behavior through tui.json (or tui.jsonc). This is separate from opencode.json, which configures server/runtime behavior. keybinds is merged with built-in defaults, so you only need to configure the shortcuts you want to change.

tui.json
{
  "$schema": "https://opencode.ai/tui.json",
  "theme": "opencode",
  "leader_timeout": 2000,
  "keybinds": {
    "leader": "ctrl+x",
    "command_list": "ctrl+p"
  },
  "scroll_speed": 3,
  "scroll_acceleration": {
    "enabled": false
  },
  "diff_style": "auto",
  "mouse": true,
  "attention": {
    "enabled": true,
    "notifications": true,
    "sound": true,
    "volume": 0.4,
    "sound_pack": "opencode.default",
    "sounds": {
      "error": "./sounds/error.mp3"
    }
  }
}

Options

Use OPENCODE_TUI_CONFIG to load a custom TUI config path.

Attention

The TUI can request attention for questions, permissions, session errors, and completed sessions. Enable it with attention.enabled; built-in events play sounds when triggered, and non-subagent events request desktop notifications only when the terminal is blurred.

Customization

You can customize various aspects of the TUI view using the command palette (ctrl+p). These settings persist across restarts.

Username display

Toggle whether your username appears in chat messages. Access this through: Command palette: Search for "username" or "hide username". The setting persists automatically and will be remembered across TUI sessions.


CLI

OpenCode CLI options and commands.

The OpenCode CLI by default starts the TUI when run without any arguments. But it also accepts commands as documented on this page. This allows you to interact with OpenCode programmatically.

Terminal window
opencode
Terminal window
opencode run "Explain how closures work in JavaScript"

Commands

The OpenCode CLI also has the following commands.

tui

Start the OpenCode terminal user interface.

Terminal window
opencode [project]

Flags

FlagShortDescription
--continue-cContinue the last session
--session-sSession ID to continue
--forkFork the session when continuing (use with --continue or --session)
--promptPrompt to use
--model-mModel to use in the form of provider/model
--agentAgent to use
--portPort to listen on
--hostnameHostname to listen on
--mdnsEnable mDNS discovery
--mdns-domainCustom mDNS domain name
--corsAdditional browser origin(s) to allow CORS

agent

Manage agents for OpenCode. This command will guide you through creating a new agent with a custom system prompt and permission configuration. Anything you don't allow is denied in the generated agent's frontmatter.

Terminal window
opencode agent [command]

create

Terminal window
opencode agent create

Passing all of --path, --description, --mode, and --permissions runs the command non-interactively.

Flags

FlagShortDescription
--pathDirectory to write the agent file to (defaults to global or .opencode/agent based on the prompt)
--descriptionWhat the agent should do
--modeAgent mode: all, primary, or subagent
--permissionsComma-separated list of permissions to allow (default: all). Available: bash, read, edit, glob, grep, webfetch, task, todowrite, websearch, lsp, skill. Anything omitted is denied. Alias: --tools
--model-mModel to use, in provider/model format

list

Terminal window
opencode agent list

attach

Attach a terminal to an already running OpenCode backend server started via serve or web commands. This allows using the TUI with a remote OpenCode backend. For example:

Terminal window
opencode attach [url]
Terminal window
# Start the backend server for web/mobile access
opencode web --port 4096 --hostname 0.0.0.0
# In another terminal, attach the TUI to the running backend
opencode attach http://10.20.30.40:4096

Flags

FlagShortDescription
--dirWorking directory to start TUI in
--continue-cContinue the last session
--session-sSession ID to continue
--forkFork the session when continuing (use with --continue or --session)
--password-pBasic auth password (defaults to OPENCODE_SERVER_PASSWORD)
--username-uBasic auth username (defaults to OPENCODE_SERVER_USERNAME or opencode)

auth

Command to manage credentials and login for providers. OpenCode is powered by the provider list at Models.dev, so you can use opencode auth login to configure API keys for any provider you'd like to use. This is stored in ~/.local/share/opencode/auth.json. When OpenCode starts up it loads the providers from the credentials file. And if there are any keys defined in your environments or a .env file in your project.

Terminal window
opencode auth [command]

login

Terminal window
opencode auth login

Flags

FlagShortDescription
--provider-pProvider ID or name to log in to
--method-mLogin method label to use, skipping method selection

list

Terminal window
opencode auth list
Terminal window
opencode auth ls

Lists all the authenticated providers as stored in the credentials file.

logout

Terminal window
opencode auth logout

Logs you out of a provider by clearing it from the credentials file.

github

Manage the GitHub agent for repository automation.

Terminal window
opencode github [command]

install

Install the GitHub agent in your repository. This sets up the necessary GitHub Actions workflow and guides you through the configuration process.

Terminal window
opencode github install

run

Run the GitHub agent. This is typically used in GitHub Actions.

Terminal window
opencode github run

Flags

FlagDescription
--eventGitHub mock event to run the agent for
--tokenGitHub personal access token

mcp

Manage Model Context Protocol servers.

Terminal window
opencode mcp [command]

add

Add an MCP server to your configuration. This command will guide you through adding either a local or remote MCP server.

Terminal window
opencode mcp add

list

List all configured MCP servers and their connection status.

Terminal window
opencode mcp list
Terminal window
opencode mcp ls

auth

Authenticate with an OAuth-enabled MCP server. If you don't provide a server name, you'll be prompted to select from available OAuth-capable servers. You can also list OAuth-capable servers and their authentication status.

Terminal window
opencode mcp auth [name]
Terminal window
opencode mcp auth list
Terminal window
opencode mcp auth ls

logout

Remove OAuth credentials for an MCP server.

Terminal window
opencode mcp logout [name]

debug

Debug OAuth connection issues for an MCP server.

Terminal window
opencode mcp debug <name>

models

List all available models from configured providers. This command displays all models available across your configured providers in the format provider/model. This is useful for figuring out the exact model name to use in your config. You can optionally pass a provider ID to filter models by that provider. Use the --refresh flag to update the cached model list. This is useful when new models have been added to a provider and you want to see them in OpenCode.

Terminal window
opencode models [provider]
Terminal window
opencode models anthropic
Terminal window
opencode models --refresh

Flags

FlagDescription
--refreshRefresh the models cache from models.dev
--verboseUse more verbose model output (includes metadata like costs)

run

Run opencode in non-interactive mode by passing a prompt directly. This is useful for scripting, automation, or when you want a quick answer without launching the full TUI. For example:

Terminal window
opencode run [message..]
Terminal window
opencode run Explain the use of context in Go

You can also attach to a running opencode serve instance to avoid MCP server cold boot times on every run:

Terminal window
# Start a headless server in one terminal
opencode serve
# In another terminal, run commands that attach to it
opencode run --attach http://localhost:4096 "Explain async/await in JavaScript"

Flags

FlagShortDescription
--commandThe command to run, use message for args
--continue-cContinue the last session
--session-sSession ID to continue
--forkFork the session when continuing (use with --continue or --session)
--shareShare the session
--model-mModel to use in the form of provider/model
--agentAgent to use
--file-fFile(s) to attach to message
--formatFormat: default (formatted) or json (raw JSON events)
--titleTitle for the session (uses truncated prompt if no value provided)
--attachAttach to a running opencode server (e.g., http://localhost:4096)
--password-pBasic auth password (defaults to OPENCODE_SERVER_PASSWORD)
--username-uBasic auth username (defaults to OPENCODE_SERVER_USERNAME or opencode)
--dirDirectory to run in, or path on the remote server when attaching
--portPort for the local server (defaults to random port)
--variantModel variant (provider-specific reasoning effort)
--thinkingShow thinking blocks
--dangerously-skip-permissionsAuto-approve permissions that are not explicitly denied (dangerous!)

serve

Start a headless OpenCode server for API access. Check out the server docs for the full HTTP interface. This starts an HTTP server that provides API access to opencode functionality without the TUI interface. Set OPENCODE_SERVER_PASSWORD to enable HTTP basic auth (username defaults to opencode).

Terminal window
opencode serve

Flags

FlagDescription
--portPort to listen on
--hostnameHostname to listen on
--mdnsEnable mDNS discovery
--mdns-domainCustom mDNS domain name
--corsAdditional browser origin(s) to allow CORS

session

Manage OpenCode sessions.

Terminal window
opencode session [command]

list

Terminal window
opencode session list

Flags

FlagShortDescription
--max-count-nLimit to N most recent sessions
--formatOutput format: table or json (table)

delete

Terminal window
opencode session delete <sessionID>

stats

Show token usage and cost statistics for your OpenCode sessions.

Terminal window
opencode stats

Flags

FlagDescription
--daysShow stats for the last N days (all time)
--toolsNumber of tools to show (all)
--modelsShow model usage breakdown (hidden by default). Pass a number to show top N
--projectFilter by project (all projects, empty string: current project)

export

Export session data as JSON. If you don't provide a session ID, you'll be prompted to select from available sessions.

Terminal window
opencode export [sessionID]

Flags

FlagDescription
--sanitizeRedact sensitive transcript/file data

import

Import session data from a JSON file or OpenCode share URL. You can import from a local file or an OpenCode share URL.

Terminal window
opencode import <file>
Terminal window
opencode import session.json
opencode import https://opncd.ai/s/abc123

web

Start a headless OpenCode server with a web interface. This starts an HTTP server and opens a web browser to access OpenCode through a web interface. Set OPENCODE_SERVER_PASSWORD to enable HTTP basic auth (username defaults to opencode).

Terminal window
opencode web

Flags

FlagDescription
--portPort to listen on
--hostnameHostname to listen on
--mdnsEnable mDNS discovery
--mdns-domainCustom mDNS domain name
--corsAdditional browser origin(s) to allow CORS

acp

Start an ACP (Agent Client Protocol) server. This command starts an ACP server that communicates via stdin/stdout using nd-JSON.

Terminal window
opencode acp

Flags

FlagDescription
--cwdWorking directory
--portPort to listen on
--hostnameHostname to listen on
--mdnsEnable mDNS discovery
--mdns-domainCustom mDNS domain name
--corsAdditional browser origin(s) to allow CORS

plugin

Install a plugin and update your config. Or use the alias.

Terminal window
opencode plugin <module>
Terminal window
opencode plug <module>

Flags

FlagShortDescription
--global-gInstall in global config
--force-fReplace existing plugin version

pr

Fetch and checkout a GitHub PR branch, then run OpenCode.

Terminal window
opencode pr <number>

db

Database tools.

Terminal window
opencode db [query]

path

Terminal window
opencode db path

Flags

FlagDescription
--formatOutput format: json or tsv

debug

Debugging and troubleshooting tools.

Terminal window
opencode debug [command]

uninstall

Uninstall OpenCode and remove all related files.

Terminal window
opencode uninstall

Flags

FlagShortDescription
--keep-config-cKeep configuration files
--keep-data-dKeep session data and snapshots
--dry-runShow what would be removed without removing
--force-fSkip confirmation prompts

upgrade

Updates opencode to the latest version or a specific version.

To upgrade to the latest version:

Terminal window
opencode upgrade

To upgrade to a specific version:

Terminal window
opencode upgrade v0.1.48

Flags

FlagShortDescription
--method-mThe installation method that was used; curl, npm, pnpm, bun, brew

Global Flags

The opencode CLI takes the following global flags.

FlagShortDescription
--help-hDisplay help
--version-vPrint version number
--print-logsPrint logs to stderr
--log-levelLog level (DEBUG, INFO, WARN, ERROR)
--pureRun without external plugins

Environment variables

OpenCode can be configured using environment variables.

VariableTypeDescription
OPENCODE_AUTO_SHAREbooleanAutomatically share sessions
OPENCODE_GIT_BASH_PATHstringPath to Git Bash executable on Windows
OPENCODE_CONFIGstringPath to config file
OPENCODE_TUI_CONFIGstringPath to TUI config file
OPENCODE_CONFIG_DIRstringPath to config directory
OPENCODE_CONFIG_CONTENTstringInline json config content
OPENCODE_DISABLE_AUTOUPDATEbooleanDisable automatic update checks
OPENCODE_DISABLE_PRUNEbooleanDisable pruning of old data
OPENCODE_DISABLE_TERMINAL_TITLEbooleanDisable automatic terminal title updates
OPENCODE_PERMISSIONstringInlined json permissions config
OPENCODE_DISABLE_DEFAULT_PLUGINSbooleanDisable default plugins
OPENCODE_DISABLE_LSP_DOWNLOADbooleanDisable automatic LSP server downloads
OPENCODE_ENABLE_EXPERIMENTAL_MODELSbooleanEnable experimental models
OPENCODE_DISABLE_AUTOCOMPACTbooleanDisable automatic context compaction
OPENCODE_DISABLE_CLAUDE_CODEbooleanDisable reading from .claude (prompt + skills)
OPENCODE_DISABLE_CLAUDE_CODE_PROMPTbooleanDisable reading ~/.claude/CLAUDE.md
OPENCODE_DISABLE_CLAUDE_CODE_SKILLSbooleanDisable loading .claude/skills
OPENCODE_DISABLE_MODELS_FETCHbooleanDisable fetching models from remote sources
OPENCODE_DISABLE_MOUSEbooleanDisable mouse capture in the TUI
OPENCODE_FAKE_VCSstringFake VCS provider for testing purposes
OPENCODE_CLIENTstringClient identifier (defaults to cli)
OPENCODE_ENABLE_EXAbooleanEnable Exa web search tools
OPENCODE_SERVER_PASSWORDstringEnable basic auth for serve/web
OPENCODE_SERVER_USERNAMEstringOverride basic auth username (default opencode)
OPENCODE_MODELS_URLstringCustom URL for fetching models configuration

Experimental

These environment variables enable experimental features that may change or be removed.

VariableTypeDescription
OPENCODE_EXPERIMENTALbooleanEnable the experimental umbrella flag
OPENCODE_EXPERIMENTAL_ICON_DISCOVERYbooleanEnable icon discovery
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECTbooleanDisable copy on select in TUI
OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MSnumberDefault timeout for bash commands in ms
OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAXnumberMax output tokens for LLM responses
OPENCODE_EXPERIMENTAL_FILEWATCHERbooleanEnable file watcher for entire dir
OPENCODE_EXPERIMENTAL_OXFMTbooleanEnable oxfmt formatter
OPENCODE_EXPERIMENTAL_LSP_TOOLbooleanEnable experimental LSP tool
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHERbooleanDisable file watcher
OPENCODE_EXPERIMENTAL_EXAbooleanEnable experimental Exa features
OPENCODE_EXPERIMENTAL_LSP_TYbooleanEnable TY LSP for python files
OPENCODE_EXPERIMENTAL_PLAN_MODEbooleanEnable plan mode
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTSbooleanEnable background subagent tasks
OPENCODE_EXPERIMENTAL_EVENT_SYSTEMbooleanEnable experimental event system
OPENCODE_EXPERIMENTAL_NATIVE_LLMbooleanEnable native LLM request path
OPENCODE_EXPERIMENTAL_PARALLELbooleanEnable parallel web search execution
OPENCODE_EXPERIMENTAL_SCOUTbooleanEnable Scout subagent
OPENCODE_EXPERIMENTAL_WORKSPACESbooleanEnable workspace support

Web

Using OpenCode in your browser.

OpenCode can run as a web application in your browser, providing the same powerful AI coding experience without needing a terminal.

Getting Started

Start the web interface by running:

Terminal window
opencode web

This starts a local server on 127.0.0.1 with a random available port and automatically opens OpenCode in your default browser.

Caution

If OPENCODE_SERVER_PASSWORD is not set, the server will be unsecured. This is fine for local use but should be set for network access.

Caution

Windows Users: For the best experience, run opencode web from WSL rather than PowerShell. This ensures proper file system access and terminal integration.

Configuration

You can configure the web server using command line flags or in your config file.

Port

By default, OpenCode picks an available port. You can specify a port:

Terminal window
opencode web --port 4096

Hostname

By default, the server binds to 127.0.0.1 (localhost only). To make OpenCode accessible on your network:

Terminal window
opencode web --hostname 0.0.0.0

When using 0.0.0.0, OpenCode will display both local and network addresses.

mDNS Discovery

Enable mDNS to make your server discoverable on the local network:

Terminal window
opencode web --mdns

This automatically sets the hostname to 0.0.0.0 and advertises the server as opencode.local.

You can customize the mDNS domain name to run multiple instances on the same network:

Terminal window
opencode web --mdns --mdns-domain myproject.local

CORS

To allow additional domains for CORS (useful for custom frontends):

Terminal window
opencode web --cors https://example.com

Authentication

To protect access, set a password using the OPENCODE_SERVER_PASSWORD environment variable:

Terminal window
OPENCODE_SERVER_PASSWORD=secret opencode web

The username defaults to opencode but can be changed with OPENCODE_SERVER_USERNAME.

Using the Web Interface

Once started, the web interface provides access to your OpenCode sessions.

Sessions

View and manage your sessions from the homepage. You can see active sessions and start new ones.

Server Status

Click "See Servers" to view connected servers and their status.

Attaching a Terminal

You can attach a terminal TUI to a running web server:

Terminal window
# Start the web server
opencode web --port 4096
# In another terminal, attach the TUI
opencode attach http://localhost:4096

This allows you to use both the web interface and terminal simultaneously, sharing the same sessions and state.

Config File

You can also configure server settings in your opencode.json config file:

opencode.json
{
  "server": {
    "port": 4096,
    "hostname": "0.0.0.0",
    "mdns": true,
    "cors": ["https://example.com"]
  }
}

Command line flags take precedence over config file settings.


IDE

The OpenCode extension for VS Code, Cursor, and other IDEs.

OpenCode integrates with VS Code, Cursor, or any IDE that supports a terminal. Just run opencode in the terminal to get started.

Usage

Installation

To install OpenCode on VS Code and popular forks like Cursor, Windsurf, VSCodium:

  1. Open VS Code
  2. Open the integrated terminal
  3. Run opencode - the extension installs automatically.

If on the other hand you want to use your own IDE when you run /editor or /export from the TUI, you'll need to set export EDITOR="code --wait".

Manual Install

Search for OpenCode in the Extension Marketplace and click Install.

Troubleshooting

If the extension fails to install automatically:


Zen

A list of tested and verified models provided by the OpenCode team.

OpenCode Zen is a list of tested and verified models provided by the OpenCode team. Zen works like any other provider in OpenCode. You login to OpenCode Zen and get your API key. It's completely optional and you don't need to use it to use OpenCode.

Background

There are a large number of models out there but only a few of these models work well as coding agents. Additionally, most providers are configured very differently; so you get very different performance and quality.

Tip

We tested a select group of models and providers that work well with OpenCode.

So if you are using a model through something like OpenRouter, you can never be sure if you are getting the best version of the model you want. To fix this, we did a couple of things:

  1. We tested a select group of models and talked to their teams about how to best run them.
  2. We then worked with a few providers to make sure these were being served correctly.
  3. Finally, we benchmarked the combination of the model/provider and came up with a list that we feel good recommending.

OpenCode Zen is an AI gateway that gives you access to these models.

How it works

OpenCode Zen works like any other provider in OpenCode.

  1. You sign in to OpenCode Zen, add your billing details, and copy your API key.
  2. You run the /connect command in the TUI, select OpenCode Zen, and paste your API key.
  3. Run /models in the TUI to see the list of models we recommend.

You are charged per request and you can add credits to your account.

Endpoints

You can also access our models through the following API endpoints.

The model id in your OpenCode config uses the format opencode/<model-id>. For example, for GPT 5.5, you would use opencode/gpt-5.5 in your config.

Models

You can fetch the full list of available models and their metadata from:

https://opencode.ai/zen/v1/models

The endpoints table includes 50+ models across providers including:

Endpoints use URLs under:

Pricing

We support a pay-as-you-go model. Below are the prices per 1M tokens.

You might notice Claude Haiku 3.5 in your usage history. This is a low cost model that's used to generate the titles of your sessions.

Note

Credit card fees are passed along at cost (4.4% + $0.30 per transaction); we don't charge anything beyond that.

The free models:

Contact us if you have any questions.

Auto-reload

If your balance goes below $5, Zen will automatically reload $20. You can change the auto-reload amount. You can also disable auto-reload entirely.

Monthly limits

You can also set a monthly usage limit for the entire workspace and for each member of your team. For example, let's say you set a monthly usage limit to $20, Zen will not use more than $20 in a month. But if you have auto-reload enabled, Zen might end up charging you more than $20 if your balance goes below $5.

Deprecated models

A deprecation table lists 14 models with deprecation dates ranging from February 2026 to July 2026.

Privacy

All our models are hosted in the US. Our providers follow a zero-retention policy and do not use your data for model training, with the following exceptions:

For Teams

Zen also works great for teams. You can invite teammates, assign roles, curate the models your team uses, and more.

Note

Workspaces are currently free for teams as a part of the beta.

Managing your workspace is currently free for teams as a part of the beta. We'll be sharing more details on the pricing soon.

Roles

You can invite teammates to your workspace and assign roles:

Admins can also set monthly spending limits for each member to keep costs under control.

Model access

Admins can enable or disable specific models for the workspace. Requests made to a disabled model will return an error. This is useful for cases where you want to disable the use of a model that collects data.

Bring your own key

You can use your own OpenAI or Anthropic API keys while still accessing other models in Zen. When you use your own keys, tokens are billed directly by the provider, not by Zen. For example, your organization might already have a key for OpenAI or Anthropic and you want to use that instead of the one that Zen provides.

Goals

We created OpenCode Zen to:

  1. Benchmark the best models/providers for coding agents.
  2. Have access to the highest quality options and not downgrade performance or route to cheaper providers.
  3. Pass along any price drops by selling at cost; so the only markup is to cover our processing fees.
  4. Have no lock-in by allowing you to use it with any other coding agent. And always let you use any other provider with OpenCode as well.

Share

Share your OpenCode conversations.

OpenCode's share feature allows you to create public links to your OpenCode conversations, so you can collaborate with teammates or get help from others.

Note

Shared conversations are publicly accessible to anyone with the link.

How it works

When you share a conversation, OpenCode:

  1. Creates a unique public URL for your session
  2. Syncs your conversation history to our servers
  3. Makes the conversation accessible via the shareable link -- opncd.ai/s/<share-id>

Sharing

Manual (default)

By default, OpenCode uses manual sharing mode. Sessions are not shared automatically, but you can manually share them using the /share command:

/share

This will generate a unique URL that'll be copied to your clipboard.

To explicitly set manual mode in your config file:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "share": "manual"
}

Auto-share

You can enable automatic sharing for all new conversations by setting the share option to "auto" in your config file:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "share": "auto"
}

With auto-share enabled, every new conversation will automatically be shared and a link will be generated.

Disabled

You can disable sharing entirely by setting the share option to "disabled" in your config file:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "share": "disabled"
}

To enforce this across your team for a given project, add it to the opencode.json in your project and check into Git.

Un-sharing

To stop sharing a conversation and remove it from public access:

/unshare

This will remove the share link and delete the data related to the conversation.

Privacy

There are a few things to keep in mind when sharing a conversation.

Data retention

Shared conversations remain accessible until you explicitly unshare them. This includes:

Recommendations

For enterprises

For enterprise deployments, the share feature can be:

Learn more about using opencode in your organization at Enterprise.


GitHub

Use OpenCode in GitHub issues and pull-requests.

OpenCode integrates with your GitHub workflow. Mention /opencode or /oc in your comment, and OpenCode will execute tasks within your GitHub Actions runner.

Features

Installation

Run the following command in a project that is in a GitHub repo:

Terminal window
opencode github install

This will walk you through installing the GitHub app, creating the workflow, and setting up secrets.

Manual Setup

1. Install the GitHub app

Head over to github.com/apps/opencode-agent. Make sure it's installed on the target repository.

2. Add the workflow

Add the following workflow file to .github/workflows/opencode.yml in your repo. Make sure to set the appropriate model and required API keys in env.

.github/workflows/opencode.yml
name: opencode
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
jobs:
  opencode:
    if: |
      contains(github.event.comment.body, '/oc') ||
      contains(github.event.comment.body, '/opencode')
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 1
          persist-credentials: false
      - name: Run OpenCode
        uses: anomalyco/opencode/github@latest
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        with:
          model: anthropic/claude-sonnet-4-20250514
          # share: true
          # github_token: xxxx

3. Store the API keys in secrets

In your organization or project settings, expand Secrets and variables on the left and select Actions. And add the required API keys.

Configuration

Configuration parameters:

Required permissions:

.github/workflows/opencode.yml
permissions:
  id-token: write
  contents: write
  pull-requests: write
  issues: write

Supported Events

Event TypeTriggered ByDetails
issue_commentComment on an issue or PRMention /opencode or /oc in your comment. OpenCode reads context and can create branches, open PRs, or reply.
pull_request_review_commentComment on specific code lines in a PRMention /opencode or /oc while reviewing code. OpenCode receives file path, line numbers, and diff context.
issuesIssue opened or editedAutomatically trigger OpenCode when issues are created or modified. Requires prompt input.
pull_requestPR opened or updatedAutomatically trigger OpenCode when PRs are opened, synchronized, or reopened. Useful for automated reviews.
scheduleCron-based scheduleRun OpenCode on a schedule. Requires prompt input. Output goes to logs and PRs (no issue to comment on).
workflow_dispatchManual trigger from GitHub UITrigger OpenCode on demand via Actions tab. Requires prompt input. Output goes to logs and PRs.

Schedule Example

Run OpenCode on a schedule to perform automated tasks:

.github/workflows/opencode-schedule.yml
name: Scheduled OpenCode Task
on:
  schedule:
    - cron: "0 9 * * 1" # Every Monday at 9am UTC
jobs:
  opencode:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: write
      pull-requests: write
      issues: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          persist-credentials: false
      - name: Run OpenCode
        uses: anomalyco/opencode/github@latest
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        with:
          model: anthropic/claude-sonnet-4-20250514
          prompt: |
            Review the codebase for any TODO comments and create a summary.
            If you find issues worth addressing, open an issue to track them.

For scheduled events, the prompt input is required since there's no comment to extract instructions from. Scheduled workflows run without a user context to permission-check, so the workflow must grant contents: write and pull-requests: write if you expect OpenCode to create branches or PRs.

Pull Request Example

Automatically review PRs when they are opened or updated:

.github/workflows/opencode-review.yml
name: opencode-review
on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
      pull-requests: read
      issues: read
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: anomalyco/opencode/github@latest
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          model: anthropic/claude-sonnet-4-20250514
          use_github_token: true
          prompt: |
            Review this pull request:
            - Check for code quality issues
            - Look for potential bugs
            - Suggest improvements

For pull_request events, if no prompt is provided, OpenCode defaults to reviewing the pull request.

Issues Triage Example

Automatically triage new issues. This example filters to accounts older than 30 days to reduce spam:

.github/workflows/opencode-triage.yml
name: Issue Triage
on:
  issues:
    types: [opened]
jobs:
  triage:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: write
      pull-requests: write
      issues: write
    steps:
      - name: Check account age
        id: check
        uses: actions/github-script@v7
        with:
          script: |
            const user = await github.rest.users.getByUsername({
              username: context.payload.issue.user.login
            });
            const created = new Date(user.data.created_at);
            const days = (Date.now() - created) / (1000 * 60 * 60 * 24);
            return days >= 30;
          result-encoding: string
      - uses: actions/checkout@v6
        if: steps.check.outputs.result == 'true'
        with:
          persist-credentials: false
      - uses: anomalyco/opencode/github@latest
        if: steps.check.outputs.result == 'true'
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        with:
          model: anthropic/claude-sonnet-4-20250514
          prompt: |
            Review this issue. If there's a clear fix or relevant docs:
            - Provide documentation links
            - Add error handling guidance for code examples
            Otherwise, do not comment.

Custom prompts

Override the default prompt to customize OpenCode's behavior for your workflow.

.github/workflows/opencode.yml
- uses: anomalyco/opencode/github@latest
  with:
    model: anthropic/claude-sonnet-4-5
    prompt: |
      Review this pull request:
      - Check for code quality issues
      - Look for potential bugs
      - Suggest improvements

This is useful for enforcing specific review criteria, coding standards, or focus areas relevant to your project.

Examples

Explain an issue

Add this comment in a GitHub issue:

/opencode explain this issue

OpenCode will read the entire thread, including all comments, and reply with a clear explanation.

Fix an issue

In a GitHub issue, say:

/opencode fix this

And OpenCode will create a new branch, implement the changes, and open a PR with the changes.

Review PRs and make changes

Leave the following comment on a GitHub PR:

Delete the attachment from S3 when the note is removed /oc

OpenCode will implement the requested change and commit it to the same PR.

Review specific code lines

Leave a comment directly on code lines in the PR's Files tab. OpenCode automatically detects the file, line numbers, and diff context to provide precise responses.

When commenting on specific lines, OpenCode receives:

This allows for more targeted requests without needing to specify file paths or line numbers manually.


GitLab

Use OpenCode in GitLab issues and merge requests.

OpenCode integrates with your GitLab workflow through your GitLab CI/CD pipeline or with GitLab Duo.

In both cases, OpenCode will run on your GitLab runners.

GitLab CI

OpenCode works in a regular GitLab pipeline. You can build it into a pipeline as a CI component.

Here we are using a community-created CI/CD component for OpenCode -- nagyv/gitlab-opencode.

Features

Setup

Store your OpenCode authentication JSON as a File type CI environment variables under Settings > CI/CD > Variables. Make sure to mark them as 'Masked and hidden'.

Add the following to your .gitlab-ci.yml file:

.gitlab-ci.yml
include:
  - component: $CI_SERVER_FQDN/nagyv/gitlab-opencode/opencode@2
    inputs:
      config_dir: ${CI_PROJECT_DIR}/opencode-config
      auth_json: $OPENCODE_AUTH_JSON
      command: optional-custom-command
      message: "Your prompt here"

For more inputs and use cases check out the docs for this component.

GitLab Duo

OpenCode integrates with your GitLab workflow. Mention @opencode in a comment, and OpenCode will execute tasks within your GitLab CI pipeline.

Features

Setup

OpenCode runs in your GitLab CI/CD pipeline, here's what you'll need to set it up:

  1. Configure your GitLab environment
  2. Set up CI/CD
  3. Get an AI model provider API key
  4. Create a service account
  5. Configure CI/CD variables
  6. Create a flow config file
Tip

Check out the GitLab docs for up to date instructions.

You can refer to the GitLab CLI agents docs for detailed instructions.

Flow configuration

flow.yml
image: node:22-slim
commands:
  - echo "Installing opencode"
  - npm install --global opencode-ai
  - echo "Installing glab"
  - export GITLAB_TOKEN=$GITLAB_TOKEN_OPENCODE
  - apt-get update --quiet && apt-get install --yes curl wget gpg git && rm --recursive --force /var/lib/apt/lists/*
  - curl --silent --show-error --location "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | bash
  - apt-get install --yes glab
  - echo "Configuring glab"
  - echo $GITLAB_HOST
  - echo "Creating OpenCode auth configuration"
  - mkdir --parents ~/.local/share/opencode
  - |
    cat > ~/.local/share/opencode/auth.json << EOF
    {
      "anthropic": {
        "type": "api",
        "key": "$ANTHROPIC_API_KEY"
      }
    }
    EOF
  - echo "Configuring git"
  - git config --global user.email "opencode@gitlab.com"
  - git config --global user.name "OpenCode"
  - echo "Testing glab"
  - glab issue list
  - echo "Running OpenCode"
  - |
    opencode run "
    You are an AI assistant helping with GitLab operations.
    Context: $AI_FLOW_CONTEXT
    Task: $AI_FLOW_INPUT
    Event: $AI_FLOW_EVENT
    Please execute the requested task using the available GitLab tools.
    Be thorough in your analysis and provide clear explanations.
    <important>
    Please use the glab CLI to access data from GitLab. The glab CLI has already been authenticated. You can run the corresponding commands.
    If you are asked to summarize an MR or issue or asked to provide more information then please post back a note to the MR/Issue so that the user can see it.
    You don't need to commit or push up changes, those will be done automatically based on the file changes you make.
    </important>
    "
  - git checkout --branch $CI_WORKLOAD_REF origin/$CI_WORKLOAD_REF
  - echo "Checking for git changes and pushing if any exist"
  - |
    if ! git diff --quiet || ! git diff --cached --quiet || [ --not --zero "$(git ls-files --others --exclude-standard)" ]; then
      echo "Git changes detected, adding and pushing..."
      git add .
      if git diff --cached --quiet; then
        echo "No staged changes to commit"
      else
        echo "Committing changes to branch: $CI_WORKLOAD_REF"
        git commit --message "Codex changes"
        echo "Pushing changes up to $CI_WORKLOAD_REF"
        git push https://gitlab-ci-token:$GITLAB_TOKEN@$GITLAB_HOST/gl-demo-ultimate-dev-ai-epic-17570/test-java-project.git $CI_WORKLOAD_REF
        echo "Changes successfully pushed"
      fi
    else
      echo "No git changes detected, skipping push"
    fi
variables:
  - ANTHROPIC_API_KEY
  - GITLAB_TOKEN_OPENCODE
  - GITLAB_HOST

Examples

Here are some examples of how you can use OpenCode in GitLab.

Tip

You can configure to use a different trigger phrase than @opencode.

Explain an issue

@opencode explain this issue

OpenCode will read the issue and reply with a clear explanation.

Fix an issue

@opencode fix this

OpenCode will create a new branch, implement the changes, and open a merge request with the changes.

Review a merge request

@opencode review this MR

OpenCode will review the merge request and provide feedback.