opencode
An AI coding agent. Some subcommands such as `auth`, `models`, `web`, etc. have their own usage documentation.
More info →Subcommands (12)
Manage agents for OpenCode.
Manage credentials and login for AI providers.
Debugging and troubleshooting tools for OpenCode.
Export session data as JSON.
Import session data from a JSON file or URL.
Manage MCP (Model Context Protocol) servers.
List all available models from configured providers.
Manage OpenCode sessions.
Show token usage and cost statistics.
Uninstall OpenCode and remove all related files.
Upgrade OpenCode to the latest version or a specific version.
Start an OpenCode server with a web interface.
Options (4)
-c, --continuebooleanContinue the most recent session
opencode {{[-c|--continue]}}-m, --modelbooleanUse a specific model and agent
opencode run {{[-m|--model]}} {{provider}}/{{model}} --agent {{agent_name}} "{{message}}"-h, --hostnamebooleanStart a headless opencode server for API access
opencode serve {{[-h|--hostname]}} {{hostname}} {{[-p|--port]}} {{port}}-p, --portbooleanStart a headless opencode server for API access
opencode serve {{[-h|--hostname]}} {{hostname}} {{[-p|--port]}} {{port}}Examples (8)
Start the interactive TUI
Continue the most recent session
opencode [-c|--continue]Run opencode in non-interactive mode by passing a prompt directly
opencode run "message"Use a specific model and agent
opencode run [-m|--model] provider/model --agent agent_name "message"List all available models from configured providers
Manage credentials and login for providers
Start a headless opencode server for API access
Create a new agent with custom configuration
opencode agent create