Overview
The SDK allows you to configure OpenCode programmatically. You can pass configuration when creating a server instance, or update it at runtime via the API.Initial Configuration
Pass configuration when creating an OpenCode instance:OPENCODE_CONFIG_CONTENT environment variable and merged with any existing opencode.json file.
Runtime Configuration
Update configuration at runtime:Configuration Options
Model Selection
Default model to use (format:
provider/model)Small model for tasks like title generation
Logging
Log level for server output
Agent Configuration
Configure individual agents
AgentConfig Properties
Model for this agent (overrides global model)
Temperature for model sampling (0-1)
Top-p sampling parameter
Maximum agentic iterations before forcing text-only response
Description of when to use this agent
When this agent is available
Hex color code for the agent (e.g.,
#FF5733)Custom system prompt for this agent
Enable/disable specific tools
Permission settingsValues:
'ask' | 'allow' | 'deny'Provider Configuration
Configure custom providers or override defaults
MCP Servers
Configure Model Context Protocol servers
Commands
Define custom commands
Plugins
Load custom plugins
TUI Settings
Terminal UI settings
Theme name
Sharing
Session sharing behavior
Other Options
Custom username for display
Enable/disable snapshots
Auto-update behavior
Additional instruction files to include
Global tool enable/disable
Global permission settings (can be overridden per agent)