Skip to main content

createOpencode()

Create a complete OpenCode instance with both server and client.

Parameters

ServerOptions
Server configuration options

Returns

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

Example

With Abort Signal


createOpencodeClient()

Create a client to connect to an existing OpenCode server.

Parameters

OpencodeClientConfig
Client configuration options

Returns

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

TuiOptions
TUI configuration options

Returns

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.