summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src/content
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-10-05 07:00:29 -0400
committerDax Raad <[email protected]>2025-10-05 07:00:29 -0400
commitf3c2d1b6c23f50aae9e60a61f283ac9eaf5bccb6 (patch)
tree3ebcd281c51be0a6e214c69ac762e1183caf3439 /packages/web/src/content
parent71a7e8ef3668a94325ba5d641b84051d7cfe5163 (diff)
downloadopencode-f3c2d1b6c23f50aae9e60a61f283ac9eaf5bccb6.tar.gz
opencode-f3c2d1b6c23f50aae9e60a61f283ac9eaf5bccb6.zip
sdk: simplify getting started with single createOpencode function
Makes it easier for developers to get started by providing a single function that creates both server and client, removing the need to manually coordinate separate server and client creation
Diffstat (limited to 'packages/web/src/content')
-rw-r--r--packages/web/src/content/docs/sdk.mdx44
1 files changed, 20 insertions, 24 deletions
diff --git a/packages/web/src/content/docs/sdk.mdx b/packages/web/src/content/docs/sdk.mdx
index 1e65064f4..2b90bd9bc 100644
--- a/packages/web/src/content/docs/sdk.mdx
+++ b/packages/web/src/content/docs/sdk.mdx
@@ -25,17 +25,16 @@ npm install @opencode-ai/sdk
## Create client
-Create a client instance to connect to your server:
+Create an instance of opencode:
```javascript
-import { createOpencodeClient } from "@opencode-ai/sdk"
+import { createOpencode } from "@opencode-ai/sdk"
-const client = createOpencodeClient({
- baseUrl: "http://localhost:4096",
- responseStyle: "data",
-})
+const { client } = await createOpencode()
```
+This starts both a server and a client
+
#### Options
| Option | Type | Description | Default |
@@ -48,39 +47,36 @@ const client = createOpencodeClient({
---
-## Start server
+## Config
-You can also programmatically start an opencode server:
+You can pass a configuration object to customize behavior. The instance still picks up your `opencode.json`, but you can override or add configuration inline:
```javascript
-import { createOpencodeServer } from "@opencode-ai/sdk"
+import { createOpencode } from "@opencode-ai/sdk"
-const server = await createOpencodeServer({
+const opencode = await createOpencode({
hostname: "127.0.0.1",
port: 4096,
+ config: {
+ model: "anthropic/claude-3-5-sonnet-20241022",
+ },
})
-console.log(`Server running at ${server.url}`)
+console.log(`Server running at ${opencode.server.url}`)
-server.close()
+opencode.server.close()
```
-You can pass a configuration object to customize server behavior. The server still picks up your `opencode.json`, but you can override or add configuration inline:
+## Client only
+
+If you aready have a running instance of opencode, you can create a client instance to connect to it:
```javascript
-import { createOpencodeServer } from "@opencode-ai/sdk"
+import { createOpencodeClient } from "@opencode-ai/sdk"
-const server = await createOpencodeServer({
- hostname: "127.0.0.1",
- port: 4096,
- config: {
- model: "anthropic/claude-3-5-sonnet-20241022",
- },
+const client = createOpencodeClient({
+ baseUrl: "http://localhost:4096",
})
-
-console.log(`Server running at ${server.url}`)
-
-server.close()
```
#### Options