Skip to main content

1. Create an API key

API keys are managed in the dashboard under Settings → API keys. Keys belong to a workspace; requests made with a key are billed to that workspace and its assets land in that workspace’s library.A key looks like this and is shown once at creation:
Store it in a secret manager or environment variable - you cannot retrieve it again later, only revoke it and create a new one.
There is no separate test mode. Every key is a live key, and every successful generation is billed. New personal workspaces include a small free credit grant so you can experiment before adding a payment method.

2. Make your first request

The -N flag disables curl’s buffering so you see the stream live. The response is a server-sent event stream: a series of data: lines, each carrying one JSON object.
Concatenate the delta texts to get the SVG markup as it streams. The saved event carries the stored asset - its id, hosted svgUrl, cost, and latency. done closes the stream. The full event flow, including error frames, is described in Streaming.

3. Consume the stream from code

The endpoint is a POST, so the browser EventSource API does not apply - read the body stream directly:

4. Retry safely with an idempotency key

Network failures happen mid-stream. Send an Idempotency-Key header so a retry never bills you twice:
If the original request completed, the retry replays its result (the finished SVG as one delta, then the saved and done events) instead of generating - and paying - again. Keep one key per request: the same key with a different prompt is rejected with 422. Details in the API reference.