curl -N https://api.f13.com/v1/generations \
-H "Authorization: Bearer $F13_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: hero-icon-4f9d36c0" \
-d '{
"prompt": "a minimal line-art icon of a paper plane"
}'
const res = await fetch("https://api.f13.com/v1/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.F13_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "hero-icon-4f9d36c0",
},
body: JSON.stringify({
prompt: "a minimal line-art icon of a paper plane",
}),
});
// read res.body as an SSE stream - see the Streaming guide
data: {"type":"delta","text":"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">"}
data: {"type":"delta","text":"<path d=\"M2 21l21-9L2 3v7l15 2-15 2z\"/></svg>"}
data: {"type":"saved","asset":{"id":"9b2f7c1e-8a41-4d6b-9e0f-2c5a7d3b1f42","prompt":"a minimal line-art icon of a paper plane","svgUrl":"https://cdn.f13.com/assets/9b2f7c1e.svg","pngUrl":null,"visibility":"private","source":"playground","modelVersion":"<model id>","parentAssetId":null,"costCents":3,"latencyMs":1840,"createdAt":"2026-07-31T12:04:05.000Z","share":null}}
data: {"type":"done"}
API reference
Create generation
Generates an SVG from a text prompt. The response is a server-sent event stream: delta frames carry the SVG markup as it is produced, a saved frame carries the stored asset, and done closes the stream. See Streaming for the wire format and full event flow.
POST
/
v1
/
generations
curl -N https://api.f13.com/v1/generations \
-H "Authorization: Bearer $F13_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: hero-icon-4f9d36c0" \
-d '{
"prompt": "a minimal line-art icon of a paper plane"
}'
const res = await fetch("https://api.f13.com/v1/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.F13_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "hero-icon-4f9d36c0",
},
body: JSON.stringify({
prompt: "a minimal line-art icon of a paper plane",
}),
});
// read res.body as an SSE stream - see the Streaming guide
data: {"type":"delta","text":"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">"}
data: {"type":"delta","text":"<path d=\"M2 21l21-9L2 3v7l15 2-15 2z\"/></svg>"}
data: {"type":"saved","asset":{"id":"9b2f7c1e-8a41-4d6b-9e0f-2c5a7d3b1f42","prompt":"a minimal line-art icon of a paper plane","svgUrl":"https://cdn.f13.com/assets/9b2f7c1e.svg","pngUrl":null,"visibility":"private","source":"playground","modelVersion":"<model id>","parentAssetId":null,"costCents":3,"latencyMs":1840,"createdAt":"2026-07-31T12:04:05.000Z","share":null}}
data: {"type":"done"}
Headers
Bearer f13_sk_live_… - see Authentication.Optional retry-safety key, 1–255 characters. The key is bound to the body
it is first used with; reusing it with a different body is rejected with
422. See Idempotency.Body
Description of the graphic to generate. Maximum 2,000 characters. Required
unless
images is sent: on illustration endpoints a single image without a
prompt is drawn on its own (its main subject becomes the illustration).
Models that need a prompt refuse an image-only request with 422.The model to run this request on: an
id from
GET /v1/models. Omit it to use the workspace’s
default model. A model the workspace cannot use is refused with 403
(model_unavailable) before charging; nothing falls back to another
model. Each model’s capabilities say which of the fields below it takes.vector returns the editable SVG without the final photo-rendering pass,
billed at the workspace’s image price. image also requests the final
rendered image alongside its vector geometry and is billed at the
workspace’s photo price (photoPriceCents in GET /v1/usage); if that
image cannot be produced or kept, the request fails and its charge is
refunded. Workspaces with a vector-only renderer reject image before
charging, and a model that takes freeform draws an
image for its freeform drawings only. Reusing an idempotency key with a different output is rejected.How the vector is painted on illustration endpoints:
fill draws filled
regions with white seams between the parts, outline draws coloured
outlines. Sending only outline_fill keeps outline. With
output: "image" the photo is drawn over the same stencil. Workspaces with
a vector-only renderer reject this field before charging.Fill the regions under
outline lines. Defaults to true when
paint_mode is outline; false leaves bare outlines. Sending true
with paint_mode: "fill" is rejected with 400.The color the drawing’s accent is drawn in, as
#rrggbb (case does not
matter), for example "#ffcf22". Omit it to use the model’s own accent.
Only models whose capabilities.accent is true in
GET /v1/models take it; the others refuse it
with 400 (unsupported_input) before charging. A value that is not a
#rrggbb color is rejected with 400.Takes one of two forms, depending on the model:
trueorfalse, on illustration models (capabilities.drawingOptionsinGET /v1/models): whether to retrieve visual grounding.falseuses the prompt-only vector pipeline."off","on"or"auto", on models whosecapabilities.groundingistrue:onlooks up real figures on the web before drawing (for example the numbers on a chart),autolets the model decide, andoffdraws from the prompt alone.
400 (unsupported_input) before charging. Any other value
is rejected with 400.The language the drawing’s words are written in, as a BCP 47 tag such as
"fr", "pt-BR" or "sr-Latn" (case does not matter; _ works as
-). Omit it for the model’s own default, English. Only models whose
capabilities.language is true in
GET /v1/models take it; the others refuse it
with 400 (unsupported_input) before charging. A value that is not
shaped like a language tag is rejected with 400.Each model keeps its own list of languages. A well-formed tag the model
does not draw in ends the stream with an error frame, code
unsupported_input, whose message names the languages it takes, for
example Unsupported language "sw". Supported: en, fr, de, …. You are not
charged.Turns on freeform drawings. With
true, a model that takes it may answer
a request for a picture of one real thing (an animal, an object, a
landmark) with a drawing traced from a photo of it, as well as what it
draws anyway. The model decides per request: a request it reads as one of
its usual drawings is drawn as before. A freeform drawing takes longer
than the model’s other drawings.Only models whose capabilities.freeform is true in
GET /v1/models take it; the others refuse
true with 400 (unsupported_input) before charging. Omitting it and
sending false are the same request.On such a model output: "image" needs freeform: true (without it the
request is refused with 400 before charging) and returns the photo the
drawing was traced from, framed on the SVG. A request the model draws as
anything other than a freeform drawing has no photo: the stream ends with
an error frame, code unsupported_request, and you are not charged.
Send it again with output: "vector".Names a freeform drawing’s parts beside it, each on a leader line to a dot
on its part, like a textbook figure (“neck”, “tail”, “hoof” around a
horse). The names are written in the request’s
language, English without one. Only with
freeform: true: without it the request is refused with 400
(unsupported_input) before charging.Ask for the thing and send the field: the prompt still decides what is
drawn, and “a horse with its parts labelled” is read as a textbook
diagram, not as a labelled horse. The names are the parts the model found
in the drawing, not a list you choose, and they can differ between
requests. A request the model draws as anything other than a freeform
drawing is drawn as without the field.The labelled drawing is the SVG, in a frame of its own around the drawing
and its names; with output: "image" the photo is framed to match. When
no name can be placed the drawing comes without them. Labels add no
charge. Omitting it and sending false are the same request.How a diagram is presented and what question it poses: one JSON object,
passed to the model as you send it. Only models whose
A top-level field wins over the same setting in
capabilities.accent is true in
GET /v1/models take it; the others refuse it
with 400 (unsupported_input) before charging.| Key | Values |
|---|---|
text | "all" or "none": the diagram with or without its words |
hide | Kinds of element, or parts by id or name, to leave out |
labels | "names", "numbers", "letters", "blank" or "none" |
highlight, mark | One part or several to pick out, and how: "accent", "ring" or "arrow" |
question | An object with a type of "name", "identify", "label", "find", "read" or "spot-error", and that type’s own fields (for label: markers and blanks; for spot-error: count and error, "label" or "value") |
views | Any of "question", "answer" and "explain": the versions of the diagram to return. explain is the answer with its worked steps |
unknown, seed, strict | The mark that stands for an unknown; a number that makes the model’s own choices repeatable; true to decline a request that only a generated picture could answer |
style | theme, ink, surface, accent, fill, muted, outline, background, font, letters, line, corners, grid, palette (a chart’s series colours), roles (colours by what a word or a rule is), and dark with switch (the colours of a dark form of the same figure, and what turns it on) |
size | width, aspect, padding |
options: accent over
options.style.accent. What the model made of the options comes back on
the diagram frame.A saved style. A workspace can have one style saved for it, so that
plain requests come back in its own look; ask us to set or change yours.
The saved style is the starting point of every request, and the request’s
own options.style goes over it field by field: a field you send wins, a
field you send as null is left out of that request, and "style": null
draws that request without the saved style. The style a figure was drawn
with is on the diagram frame, in applied.style.The object can be at most 16,384 characters of JSON, nested at most 8
levels; a larger one, or a value that is not a JSON object, is rejected
with 400. The model checks the contents: a key or a value it does not
take ends the stream with an error frame, code unsupported_input,
whose message names the field and what it takes. You are not charged.Up to 4 reference images that give the model visual context for the
prompt, as public HTTPS URLs or base64 data URLs
(
data:image/png;base64,…; png, jpeg, webp or non-animated gif).
HTTPS URLs must use port 443, be at most 8,192 characters, and contain no
embedded credentials or fragments. Signed query-string URLs work; images
must be accessible without authorization headers. The model fetches the
URL and applies its image limits. Inline data URLs are limited to 8MB of
image data each; the request body is bounded at 48MB.
Illustration endpoints take one image: the photo to draw,
with or without a prompt. Sending more is refused with 422, and sending
one with grounding: false with 400, both before charging.{
"prompt": "a minimal line-art drawing",
"images": ["https://your-image-host.example/reference.png"]
}
n parameter.
Response
200 with Content-Type: text/event-stream. Each frame is a data: line
holding one JSON object discriminated by type:
type | Fields | Meaning |
|---|---|---|
delta | text | Next chunk of SVG markup |
diagram | diagram | The model’s description of its drawing: the diagram object |
saved | asset | The stored asset |
save_error | message | Generated and billed, but not stored |
photo | image | Zero data retention only: the PNG copy as a data: URL, not stored |
done | retention?, note? | Stream complete; retention: "none" when the workspace keeps nothing (no saved event), note: "not_retained" on a replay there |
error | code, message | Generation failed; nothing was charged. Codes are listed in Streaming |
400/401/402/409/422/429/503 shapes.
The asset object
Delivered on thesaved frame.
Hosted URL of the SVG. Empty string if the upload failed (the markup from
the
delta frames is still complete).Hosted URL of a PNG copy of the image, when the workspace’s model returns
one alongside the SVG.
null otherwise, including when the PNG could not
be stored (the SVG and the charge are unaffected).Opaque identifier of the model build that produced the asset. Informational
only: the value changes as the model is updated and is not meant to be
parsed or compared.
The diagram object
Delivered on thediagram frame, after the last delta, by models that
describe their drawing. Every field is optional, and the model adds fields
over time: ignore the ones you do not know.
| Field | Holds |
|---|---|
kind, title, description | What was drawn (such as illustration, chart or map), its title, and a sentence or two for alt text |
width, height | The SVG’s size in pixels |
made | How the figure came about: hand-built, computed or generated |
views | question, answer and explain as asked with options.views, each a complete SVG document. The SVG of the delta frames is the first view asked for |
parts | The diagram’s parts, each with the id it carries in the SVG and its name |
question | The type asked for and its status: made, or unsupported with a reason when the diagram cannot pose that question. That is not an error: the diagram comes back complete |
key | The answer key, shaped by the question’s type |
applied | The presentation the diagram was made with |
given | The quantities a computed figure was given, each with of, text, value and unit |
{
"prompt": "Animal cell",
"options": {
"question": { "type": "label", "blanks": 1 },
"views": ["question", "answer"]
}
}
delta frames carry the question view: the cell with one name replaced
by the marker 1. The diagram frame follows, with both views, the parts
and the key:
{
"type": "diagram",
"diagram": {
"kind": "illustration",
"title": "Animal cell",
"made": "hand-built",
"views": {
"question": "<svg xmlns=\"http://www.w3.org/2000/svg\" …>…</svg>",
"answer": "<svg xmlns=\"http://www.w3.org/2000/svg\" …>…</svg>"
},
"parts": [
{ "id": "p1", "name": "Nucleus" },
{ "id": "p2", "name": "Mitochondrion" },
{ "id": "p3", "name": "Cell membrane" }
],
"question": { "type": "label", "status": "made" },
"key": {
"markers": [{ "marker": "1", "part": "p2", "answer": "Mitochondrion" }],
"word_bank": ["Cell membrane", "Mitochondrion", "Nucleus"]
},
"applied": { "text": "all", "hide": [], "labels": null, "highlight": [], "from": "fields" }
}
}
curl -N https://api.f13.com/v1/generations \
-H "Authorization: Bearer $F13_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: hero-icon-4f9d36c0" \
-d '{
"prompt": "a minimal line-art icon of a paper plane"
}'
const res = await fetch("https://api.f13.com/v1/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.F13_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "hero-icon-4f9d36c0",
},
body: JSON.stringify({
prompt: "a minimal line-art icon of a paper plane",
}),
});
// read res.body as an SSE stream - see the Streaming guide
data: {"type":"delta","text":"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">"}
data: {"type":"delta","text":"<path d=\"M2 21l21-9L2 3v7l15 2-15 2z\"/></svg>"}
data: {"type":"saved","asset":{"id":"9b2f7c1e-8a41-4d6b-9e0f-2c5a7d3b1f42","prompt":"a minimal line-art icon of a paper plane","svgUrl":"https://cdn.f13.com/assets/9b2f7c1e.svg","pngUrl":null,"visibility":"private","source":"playground","modelVersion":"<model id>","parentAssetId":null,"costCents":3,"latencyMs":1840,"createdAt":"2026-07-31T12:04:05.000Z","share":null}}
data: {"type":"done"}