Skip to main content

Overview

The OpenCode SDK includes comprehensive TypeScript definitions generated from the OpenAPI specification. All types are exported from the main package.
View the complete types file in the OpenCode repository.

Core Types

Session

Represents an AI coding session.

Message

Union type for user and assistant messages.

Part

Message parts (text, file, tool use, etc.).

ToolState

Tool execution state.

Configuration Types

Config

Main configuration object.

AgentConfig

Configuration for individual agents.

ProviderConfig

Provider configuration.

Provider and Model Types

Provider

Provider information.

Model

Model information.

Agent

Agent information.

Event Types

Event

Union type for all server events.

GlobalEvent

Event with directory context.

File Types

File

File status information.

FileDiff

File diff information.

FileContent

File content response.

Symbol

Workspace symbol.

Project Types

Project

Project information.

Path

Path information.

Error Types

Message Errors

API Errors

Permission Types

Permission

Permission request.

Todo Types

Todo

Todo item.

Command Types

Command

Command definition.

Input Types

These types are used for creating messages:

Usage Example