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

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

Logging

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

Agent Configuration

agent
Record<string, AgentConfig>
Configure individual agents

AgentConfig Properties

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

Provider Configuration

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

MCP Servers

mcp
Record<string, McpConfig>
Configure Model Context Protocol servers

Commands

command
Record<string, CommandConfig>
Define custom commands

Plugins

plugin
string[]
Load custom plugins

TUI Settings

tui
TuiConfig
Terminal UI settings
theme
string
Theme name

Sharing

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

Other Options

username
string
Custom username for display
snapshot
boolean
Enable/disable snapshots
autoupdate
boolean | 'notify'
Auto-update behavior
instructions
string[]
Additional instruction files to include
tools
Record<string, boolean>
Global tool enable/disable
permission
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: