summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src/content/docs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/web/src/content/docs')
-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