Skip to main content

createOpencode()

Create a complete OpenCode instance with both server and client.

Parameters

options
ServerOptions
Server configuration options

Returns

client
OpencodeClient
Type-safe client instance for API calls
server
object
Server instance with control methods

Example

With Abort Signal


createOpencodeClient()

Create a client to connect to an existing OpenCode server.

Parameters

options
OpencodeClientConfig
Client configuration options

Returns

client
OpencodeClient
Type-safe client instance for making API calls to the server

Example: Basic Client

Example: Custom Headers

Example: Override Directory

Example: Error Handling


createOpencodeTui()

Launch the OpenCode Terminal UI programmatically.

Parameters

options
TuiOptions
TUI configuration options

Returns

tui
object
TUI instance with control methods

Example


Client Namespaces

The client is organized into logical namespaces:

Global

Session

Project

Config

File Operations

App

TUI Control

Auth

Events

Response Format

By default, API calls return an object with the following structure:

Accessing Data

TypeScript Support

The client is fully typed with TypeScript:
See the Types reference for all available types.