Skip to main content

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:
The configuration is passed via the OPENCODE_CONFIG_CONTENT environment variable and merged with any existing opencode.json file.

Runtime Configuration

Update configuration at runtime:

Configuration Options

Model Selection

string
Default model to use (format: provider/model)
string
Small model for tasks like title generation

Logging

'DEBUG' | 'INFO' | 'WARN' | 'ERROR'
default:"INFO"
Log level for server output

Agent Configuration

Record<string, AgentConfig>
Configure individual agents

AgentConfig Properties

string
Model for this agent (overrides global model)
number
Temperature for model sampling (0-1)
number
Top-p sampling parameter
number
Maximum agentic iterations before forcing text-only response
string
Description of when to use this agent
'subagent' | 'primary' | 'all'
default:"all"
When this agent is available
string
Hex color code for the agent (e.g., #FF5733)
string
Custom system prompt for this agent
Record<string, boolean>
Enable/disable specific tools
PermissionConfig
Permission settings
Values: 'ask' | 'allow' | 'deny'

Provider Configuration

Record<string, ProviderConfig>
Configure custom providers or override defaults

MCP Servers

Record<string, McpConfig>
Configure Model Context Protocol servers

Commands

Record<string, CommandConfig>
Define custom commands

Plugins

string[]
Load custom plugins

TUI Settings

TuiConfig
Terminal UI settings
string
Theme name

Sharing

'manual' | 'auto' | 'disabled'
default:"manual"
Session sharing behavior

Other Options

string
Custom username for display
boolean
Enable/disable snapshots
boolean | 'notify'
Auto-update behavior
string[]
Additional instruction files to include
Record<string, boolean>
Global tool enable/disable
PermissionConfig
Global permission settings (can be overridden per agent)

Examples

Development Configuration

Production Configuration

Custom Provider

Multi-Agent Setup

Getting Provider Information

Retrieve information about available providers and models:

Type Safety

All configuration is fully typed: