fetch, and renders Server-Sent Events as they arrive.
This guide is for internal tools, trusted admin panels, and backend-proxied production apps.
What You Need
- A Bag of Words base URL — e.g.
http://localhost:3000orhttps://bow.example.com - A
bow_...API key created in Bag of Words Settings → API Keys - Optional data source or agent IDs to attach to the report
- A browser or backend that can call the Bow API
Do not include
/api in the user-facing base URL. Build the API base internally:Recommended Architecture
For a private internal app, the browser can call Bow directly with an API key. For a public app, proxy requests through your own backend:Minimum Streaming Flow
- Create a report with the data sources your chat should use.
POSTa streaming completion to that report.- Parse SSE frames from the response body.
- Render assistant text, reasoning, tool progress, and errors from the events.
Reports are the scope for data sources. Attach data sources when creating or updating the report — not in the completion prompt mentions.
Create a Report
Create a report when the user starts a new chat session or when you need a temporary scratch report.Stream a Completion
Usefetch, not EventSource, because the completion stream is a POST request with custom headers.
SSE Format
Bow sends standard Server-Sent Events:data: lines belong to the same event and should be joined with \n.
The data: payload is an envelope — parse it like this:
data: [DONE] means the stream is complete.
Tiny SSE Parser
Event Reference
Handle unknown events gracefully — the API may add events over time.Rendering a Chat UI
Keep the UI reducer small:- Store
status:idle,streaming,success, orerror - Store blocks by
id - Append
block.delta.tokenfor assistant text - Replace text on
block.delta.text - Show reasoning inside a collapsible disclosure
- Show tools as compact rows with name, status, and summary
- Keep raw JSON behind a disclosure for tool payloads
- Keep the raw SSE log available in a debug tab
Optional API Requests
Validate an API key:Error Handling
Copy-Paste cURL
Production Checklist
- Proxy public integrations through your backend
- Keep Bow API keys server-side for public apps
- Use
AbortControllerfor the Stop button - Persist report IDs if a chat should resume later
- Attach data sources through report creation or update
- Keep
mentions: []unless your integration intentionally supports Bow prompt mentions - Log raw SSE frames for support and debugging
- Render unknown future events without crashing
