docs: add config example to SDK server creation

This commit is contained in:
Dax Raad
2025-09-02 15:16:35 -04:00
parent 8952b3d246
commit 38a4bee1be

View File

@@ -65,6 +65,31 @@ console.log(`Server running at ${server.url}`)
server.close() server.close()
``` ```
You can also pass a configuration object to customize the server behavior:
```javascript
import { createOpencodeServer } from "@opencode-ai/sdk"
const server = await createOpencodeServer({
hostname: "127.0.0.1",
port: 4096,
config: {
theme: "dark",
model: "anthropic/claude-3-5-sonnet-20241022",
agent: {
general: {
temperature: 0.7,
model: "anthropic/claude-3-5-sonnet-20241022",
},
},
},
})
console.log(`Server running at ${server.url}`)
server.close()
```
#### Options #### Options
| Option | Type | Description | Default | | Option | Type | Description | Default |
@@ -73,6 +98,7 @@ server.close()
| `port` | `number` | Server port | `4096` | | `port` | `number` | Server port | `4096` |
| `signal` | `AbortSignal` | Abort signal for cancellation | `undefined` | | `signal` | `AbortSignal` | Abort signal for cancellation | `undefined` |
| `timeout` | `number` | Timeout in ms for server start | `5000` | | `timeout` | `number` | Timeout in ms for server start | `5000` |
| `config` | `Config` | Configuration object | `{}` |
--- ---