Skip to main content
POST /v1/generations responds with a server-sent event stream (Content-Type: text/event-stream). The SVG is streamed as it is generated, followed by a frame with the stored asset, and a terminal frame that closes the stream.

Wire format

Each frame is a single data: line carrying one JSON object, terminated by a blank line:
Frames are distinguished by the type field inside the JSON - the stream does not use named SSE event: lines. Because the endpoint is a POST with a body, the browser EventSource API cannot consume it; read the response body and split on blank lines, as in the quickstart.

Frame types

Ordering

A successful stream is:
If storage fails, save_error replaces saved. done never arrives without one of the two: when the model returns nothing usable the stream ends in error (no_svg) instead. A failed stream is:
After done or error the connection closes; no further frames follow. A replay of a completed request (same Idempotency-Key) has the same shape, with the whole SVG in a single delta and the same diagram frame.

Zero data retention

A workspace can be set by f13 staff to keep nothing its generations produce: no stored asset, no hosted SVG or PNG file, no stored result for retries, no product analytics about the generation. Billing is the same: each completed generation is charged at the workspace’s price and counted on its usage. In that mode a successful stream is:
There is no saved or save_error event and no asset id, so a follow-up cannot pass parentAssetId (it is refused with 403, "code": "not_entitled"). photo appears only when the model returned a PNG copy. Keep the markup (and the photo and the diagram frame) you receive: the platform cannot give it back later. A retry with the same Idempotency-Key is not billed again, but it replays only the end of the stream:
The asset, share and library routes answer 403 with "code": "not_entitled" for such a workspace.

Failure modes to handle

  • HTTP errors happen before the stream starts. Validation problems, auth failures, 402, 409, 422, 429 and 503 are ordinary JSON responses with a non-200 status - check res.ok before reading the stream. See Errors.
  • Mid-stream failures arrive inside a 200. Once streaming has begun the status is already sent, so failures surface as an error frame. Nothing is charged for a stream that ends this way. Branch on its code (table below), not on message.
  • save_error is not a failed generation. The markup you assembled from the deltas is complete and the generation was billed; only the library copy is missing. Retry with a new request if you need the hosted URL.
  • A dropped connection ends the stream silently. Retry with the same Idempotency-Key to recover the result without being billed twice. Under zero data retention the retry is not billed but cannot return the image.

Error frame codes