Widget bundle compression and session spend-limit 402

The voice-agent widget is now served compressed - 676 kB down to 190 kB when it was measured - supports version-pinned URLs with subresource integrity, and session creation returns 402 when a spend limit or budget is hit rather than a 500.

Developer Relations · SpeechifyAI Labs
1 min read

GET /v1/widget/agents.js used to be served uncompressed - the one thing every visitor of every embedded agent downloads, sent raw. It now negotiates compression like every other text response, cutting the transfer from roughly 676 kB to roughly 190 kB as measured on 28 July 2026. No embed change is required.

Those are the numbers that motivated the change, not the numbers you’ll see today: the bundle itself has since been cut down hard, and agents.js is now about 46 kB raw and 13 kB over the wire.

The widget also supports version-pinned URLs now: https://api.speechify.ai/v1/widget/v<MAJOR>.<MINOR>.<PATCH>/agents.js serves an immutable build that never changes - cache it for a year, add an integrity= attribute for subresource integrity. The unversioned URL keeps tracking the current release (cache drops from a day to five minutes so a correction reaches a returning visitor quickly).

On the API side: POST /v1/agents/{agent_id}/sessions previously returned a 500 when the API key or workspace hit its spend cap or budget. It now returns 402 with the same codes the other agent endpoints use - spend_cap_exceeded, spend_budget_exceeded, payment_required - so a client can tell the three funding states apart and act on each.

See the docs changelog entry for the full details on the X-Content-Type-Options header, source maps, and the build id published as window.__SPEECHIFY_WIDGET_VERSION__.