Getting Started
By default, OpenCode starts the TUI when run without arguments:Available Commands
serve
Start a headless OpenCode server for API access
web
Start server with web interface
attach
Attach terminal to running backend server
models
List all available models from providers
auth
Manage provider credentials and login
agent
Manage custom agents
upgrade
Update to latest or specific version
TUI Mode
Start the OpenCode terminal user interface:Options
flag
Continue the last session. Short form:
-cstring
Session ID to continue. Short form:
-sflag
Fork the session when continuing (use with
--continue or --session)string
Initial prompt to use
string
Model to use in the form of
provider/model. Short form: -mstring
Agent to use
number
Port to listen on
string
Hostname to listen on
Examples
Run Mode
Run OpenCode non-interactively with a direct message:Global Flags
These flags work with any command:flag
Display help information. Short form:
-hflag
Print version number. Short form:
-vflag
Print logs to stderr
string
Set log level:
DEBUG, INFO, WARN, or ERROREnvironment Variables
OpenCode can be configured using environment variables:For a complete list of environment variables including experimental features, see the source documentation.
Next Steps
In-Session Commands
Learn about commands you can use during a session
Configuration
Customize OpenCode to your needs