Diffinery

homeflare/celldpublic

35 lines · 1.0 KBRaw History
1# OpenCode Workerd SDK
2
3This example runs the OpenCode Workerd SDK in a Durable Object. The Durable
4Object storage holds the SDK state, so a session survives a restart. The example
5creates a session, sends a prompt, waits for the run to complete, and returns
6the assistant reply.
7
8The example needs no credentials. The SDK resolves a free model from its own
9provider registry, and it reports the model that answered.
10
11Install the example dependencies with `npm ci`, then start it:
12
13```sh
14celld dev .
15curl http://127.0.0.1:9876/
16```
17
18A successful response contains the reply and the model that produced it:
19
20```json
21{
22 "ok": true,
23 "model": {
24 "providerID": "opencode",
25 "modelID": "nemotron-3.5-lightning-free"
26 },
27 "prompt": "hello world",
28 "reply": "Hello! How can I help you today?",
29 "checks": [{ "name": "model.default", "ok": true, "ms": 12 }]
30}
31```
32
33The response has status 502 when the run completes but no assistant reply
34arrives, and status 500 when an SDK call fails. Therefore a broken model path
35fails the probe instead of passing it.