Widget bundle served compressed, and session spend limits return 402
The <speechify-agent> bundle is now served compressed
GET /v1/widget/agents.js was served uncompressed. It now negotiates
compression like every other text response, cutting the transfer from roughly
676 kB to roughly 190 kB for every visitor of every page carrying the widget.
No embed change is required.
The bundle also now carries X-Content-Type-Options: nosniff and
Cross-Origin-Resource-Policy: cross-origin, so it loads on pages that set
a cross-origin embedder policy.
The widget can be pinned to an exact version
https://api.speechify.ai/v1/widget/v<MAJOR>.<MINOR>.<PATCH>/agents.js serves
one immutable build. Its bytes never change, so it can carry an integrity=
attribute for subresource integrity, and it is cached for a year. Asking for a
version we do not serve returns 404 rather than falling back to a different
build.
The unversioned https://api.speechify.ai/v1/widget/agents.js keeps tracking
the current release and is unchanged apart from its cache lifetime, which drops
from a day to five minutes so a correction reaches a returning visitor in
minutes rather than the next day.
Every loaded bundle now also publishes its own build id as
window.__SPEECHIFY_WIDGET_VERSION__, and agents.js.map is served rather
than 404ing, so a browser devtools stack trace points at real source.
POST /v1/agents/{agent_id}/sessions returns 402 when a spend limit is reached
Sessions refused because the API key reached its spend cap, or the workspace
reached its spend budget, previously returned 500 internal_error. They now
return 402 with the same codes the other agent endpoints already use, so a
client can tell the three funding states apart and act on them.
spend_cap_exceeded— the authenticating API key hit its own monthly ceiling. Raise the key’s cap.spend_budget_exceeded— the workspace hit its monthly budget. Raise the budget in workspace settings.payment_required— the account is out of credits. Top up the balance.
The endpoint’s documented responses now also list 400 and 429, both of
which it already returned.