@zerowidth/api
v2.0.0
Published
Official JavaScript client for the ZeroWidth API — run and stream Workbench flows.
Maintainers
Readme
zerowidth
Official JavaScript client for the ZeroWidth API — run and stream Workbench flows. Zero dependencies, Node 18+.
Preview. This client targets ZeroWidth's next-generation API (
api.zerowidth.ai/1.0), currently in limited preview ahead of general availability. It will light up for everyone the day the new surface ships — no update required.
npm install @zerowidth/apiRun a flow
import ZeroWidth from "@zerowidth/api"
const zw = new ZeroWidth() // reads ZEROWIDTH_API_KEY
const result = await zw.flows.run("your-flow-uuid", {
input: { kind: "chat", messages: [{ role: "user", content: "Hello!" }] },
source: { kind: "published", version: "1.0.0" }, // pin for production
})
console.log(result.outputs, result.costSummary.total)Inputs are { kind: "chat", messages } for agent flows or { kind: "form", values } keyed by your input nodes. Outputs come back keyed by your output nodes.
Stream
const stream = zw.flows.streamText("your-flow-uuid", {
input: { kind: "chat", messages },
})
for await (const delta of stream) process.stdout.write(delta)
console.log(stream.finalResult.outputs)flows.stream(...) gives the raw event iterator (node_start / node_update / node_complete / node_error / run_complete / run_error) for progress UIs and traces.
Errors
Failures throw ZeroWidthError with status, code (the API's machine-readable code, e.g. plan_limit), and body.
Full API reference: zerowidth.ai/docs/workbench/api/run-flow. To run flows in your own infrastructure instead, see @zerowidth/workbench-sdk.
