Inquiry: Programmatic access or Node.js SDK for OpenCode #2657

Closed
opened 2026-02-16 17:36:38 -05:00 by yindo · 4 comments
Owner

Originally created by @i18nsite on GitHub (Nov 7, 2025).

Originally assigned to: @rekram1-node on GitHub.

Hello, I am looking for a way to call the OpenCode agent programmatically from a Node.js environment.

Is there an existing Node.js SDK, or an API, that allows for this?

My goal is to integrate OpenCode's functionality into other automated workflows, and having an SDK or API would be very helpful for this purpose.

Originally created by @i18nsite on GitHub (Nov 7, 2025). Originally assigned to: @rekram1-node on GitHub. Hello, I am looking for a way to call the OpenCode agent programmatically from a Node.js environment. Is there an existing Node.js SDK, or an API, that allows for this? My goal is to integrate OpenCode's functionality into other automated workflows, and having an SDK or API would be very helpful for this purpose.
yindo closed this issue 2026-02-16 17:36:38 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2266: This is a very similar request asking for a Python SDK for programmatic integration with OpenCode server functionality

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 7, 2025): This issue might be a duplicate of existing issues. Please check: - #2266: This is a very similar request asking for a Python SDK for programmatic integration with OpenCode server functionality Feel free to ignore if none of these address your specific case.
Author
Owner

@sandipwane commented on GitHub (Nov 7, 2025):

Hey @i18nsite,

Yes, OpenCode has a Node.js SDK for programmatic access.

Install:

npm install @opencode-ai/sdk

Source: https://github.com/sst/opencode/tree/dev/packages/sdk/js

Docs: https://opencode.ai/docs/sdk/

Quick start:

import { createOpencodeClient, createOpencodeServer } from "@opencode-ai/sdk"

// Start server
const server = await createOpencodeServer()
const client = createOpencodeClient({ baseUrl: server.url })

// Create session & send prompt
const session = await client.session.create()
await client.session.prompt({
  path: { id: session.data.id },
  body: {
    parts: [
      { type: "text", text: "Your prompt here" }
    ]
  }
})

SDK handles sessions, file ops, streaming responses - everything needed for automation.

Note: Last time I used @opencode-ai/sdk, the npm package wasn't up to date. I ended up using the SDK directly from the monorepo - cloned sst/opencode and installed the JS SDK folder directly into my project using bun. Check the npm version first, but if you need latest features, the monorepo approach works well.

Let me know if you need help with specific use cases.

@sandipwane commented on GitHub (Nov 7, 2025): Hey @i18nsite, Yes, OpenCode has a Node.js SDK for programmatic access. **Install:** ```bash npm install @opencode-ai/sdk ``` **Source:** https://github.com/sst/opencode/tree/dev/packages/sdk/js **Docs:** https://opencode.ai/docs/sdk/ **Quick start:** ```javascript import { createOpencodeClient, createOpencodeServer } from "@opencode-ai/sdk" // Start server const server = await createOpencodeServer() const client = createOpencodeClient({ baseUrl: server.url }) // Create session & send prompt const session = await client.session.create() await client.session.prompt({ path: { id: session.data.id }, body: { parts: [ { type: "text", text: "Your prompt here" } ] } }) ``` SDK handles sessions, file ops, streaming responses - everything needed for automation. **Note:** Last time I used @opencode-ai/sdk, the npm package wasn't up to date. I ended up using the SDK directly from the monorepo - cloned sst/opencode and installed the JS SDK folder directly into my project using bun. Check the npm version first, but if you need latest features, the monorepo approach works well. Let me know if you need help with specific use cases.
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

The sdk should be up to date now

and thank u @sandipwane for being so helpful

@rekram1-node commented on GitHub (Nov 7, 2025): The sdk should be up to date now and thank u @sandipwane for being so helpful
Author
Owner

@mrlubos commented on GitHub (Jan 12, 2026):

@i18nsite is your issue solved now?

@mrlubos commented on GitHub (Jan 12, 2026): @i18nsite is your issue solved now?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2657