How to Generate SVGs with AI Through One API
Generate SVG icons, logos, stickers, and illustrations with AI using OpenAI's GPT Image 2.6 through LLM Gateway. One request with output_format: svg returns an editable vector file, billed from reported usage on your existing gateway key.
By LLM Gateway

Image models have produced pixels for years. That works for photos and fails for the graphics product teams ship most: icons, logos, stickers, and spot illustrations. Those need to scale from a favicon to a billboard, change color with the theme, and live in a repository as code. Until now, the path was a PNG from a model followed by a tracing tool, which loses detail and leaves messy paths.
You can now generate SVGs with AI in one request. OpenAI's GPT Image 2.6
returns vector output natively, and LLM Gateway exposes it on the same
/v1/images/generations endpoint and API key you already use. DevPass
coding plans cover text models only, so image requests from them return a
403.
Generate an SVG with AI in one request
Set output_format to svg. Accounts with OpenAI SVG model selection enabled
require svg.model; accounts without it must omit svg. The optional reasoning
effort controls the author independently of image quality:
1curl https://api.llmgateway.io/v1/images/generations \2 -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "openai/gpt-image-2.6-flare",6 "prompt": "A minimal line icon of a paper airplane, single stroke color, no background",7 "output_format": "svg",8 "svg": { "model": "gpt-5.4-mini", "reasoning": { "effort": "low" } },9 "quality": "medium"10 }' | jq -r '.data[0].b64_json' | base64 --decode > paper-airplane.svg1curl https://api.llmgateway.io/v1/images/generations \2 -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "openai/gpt-image-2.6-flare",6 "prompt": "A minimal line icon of a paper airplane, single stroke color, no background",7 "output_format": "svg",8 "svg": { "model": "gpt-5.4-mini", "reasoning": { "effort": "low" } },9 "quality": "medium"10 }' | jq -r '.data[0].b64_json' | base64 --decode > paper-airplane.svgThe response has the usual images shape. data[0].b64_json is the base64 of a
UTF-8 SVG document, and output_format echoes "svg":
1{2 "created": 1762344000,3 "data": [4 {5 "b64_json": "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIC4uLg=="6 }7 ],8 "output_format": "svg"9}1{2 "created": 1762344000,3 "data": [4 {5 "b64_json": "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIC4uLg=="6 }7 ],8 "output_format": "svg"9}The response also carries usage with the token counts and usage.cost, the
billed cost of the request in USD.
The same request works from the OpenAI SDK by pointing baseURL at the
gateway:
1import OpenAI from "openai";2import { writeFile } from "node:fs/promises";3
4const client = new OpenAI({5 apiKey: process.env.LLM_GATEWAY_API_KEY,6 baseURL: "https://api.llmgateway.io/v1",7});8
9const result = await client.images.generate({10 model: "openai/gpt-image-2.6-sunburst",11 prompt: "A flat bakery logo: a golden loaf above the words Field & Flour",12 output_format: "svg",13 svg: { model: "gpt-5.4-mini", reasoning: { effort: "low" } },14});15
16const svg = result.data?.[0]?.b64_json;17if (!svg) {18 throw new Error("No SVG returned");19}20await writeFile("logo.svg", Buffer.from(svg, "base64"));1import OpenAI from "openai";2import { writeFile } from "node:fs/promises";3
4const client = new OpenAI({5 apiKey: process.env.LLM_GATEWAY_API_KEY,6 baseURL: "https://api.llmgateway.io/v1",7});8
9const result = await client.images.generate({10 model: "openai/gpt-image-2.6-sunburst",11 prompt: "A flat bakery logo: a golden loaf above the words Field & Flour",12 output_format: "svg",13 svg: { model: "gpt-5.4-mini", reasoning: { effort: "low" } },14});15
16const svg = result.data?.[0]?.b64_json;17if (!svg) {18 throw new Error("No SVG returned");19}20await writeFile("logo.svg", Buffer.from(svg, "base64"));Sunburst or Flare
| Model | Pick it for |
|---|---|
openai/gpt-image-2.6-flare | Fast iteration: icon sets, sticker drafts, exploring styles |
openai/gpt-image-2.6-sunburst | Detailed work: logos with lettering, illustrations with depth |
Start with Flare to find a direction, then run the final prompt on Sunburst.
quality controls the reference image the SVG is drawn from, so low or
medium is usually enough for flat icons.
Prompts that produce clean vectors
SVG output rewards prompts that describe a graphic, not a photo:
- Name the style. "Flat", "line icon", "two-color", "geometric", and "sticker with a white outline" lead to fewer, cleaner paths.
- Limit the palette. "Three colors: navy, coral, cream" keeps the file small and easy to retheme.
- Say what to leave out. "No background, no shadows, no gradients" avoids shapes you would delete by hand.
- Spell out the text. Logos with lettering come out best when the exact words are in quotes in the prompt.
What you get back, and the limits
The SVG is static vector content: paths, shapes, and colors, with no scripts, external resources, or embedded raster images. That makes it safe to inline in HTML or commit to a design system after your usual review.
A few rules come from the upstream API. The gateway rejects an SVG request
with n above 1, with output_compression, or for a model without SVG output
with a 400 before any provider is called:
nmust be1.output_compressionand streaming are not available for SVG.- SVG is a generation format.
/v1/images/editsreturns raster images, and an SVG is not accepted as an edit input. - Only GPT Image 2.6 models return SVG.
model: "auto"routes to a raster model, so name the model explicitly.
In chat completions, set image_config.output_format to "svg", and the image
arrives as a data:image/svg+xml;base64,... URL in message.images.
What AI SVG generation costs
An SVG request does two pieces of work. OpenAI renders a reference image with GPT Image 2.6, then an authoring model writes the SVG. LLM Gateway bills both from the usage OpenAI reports:
- the reference image at GPT Image 2.6 rates: $5 per million text input tokens and $30 per million image output tokens;
- the authoring model's input and output tokens at that model's catalogue rates. When those rates are unknown, authoring cost is omitted and logged for reconciliation; the reference image is still billed.
Both are included in usage.cost on the response and in the request log, so
you can see what each icon cost. The
models page lists
current prices, and per-key usage limits stop new requests once a batch job has
spent more than planned. Requests already in flight can still finish past the
limit.
Why run it through LLM Gateway
- One key for every image model. Use GPT Image 2.6 for vectors, Gemini or
Seedream for photos, and switch with the
modelfield. - Cost on every response.
usage.costand the request log show what each generation billed, including the SVG authoring tokens. Usage limits. Limits per organization, project, and API key stop sending new requests from a runaway loop.
- Try LLM Gateway free
- Read the SVG output docs
- See the GPT Image 2.6 changelog
Frequently asked questions
- Can AI generate SVG files directly?
- Yes. OpenAI's GPT Image 2.6 Sunburst and Flare return SVG when you set output_format to svg on /v1/images/generations. The model renders a reference image and an authoring model writes the vector document, so you get real paths and shapes, not a traced bitmap.
- Which models can generate SVG on LLM Gateway?
- openai/gpt-image-2.6-sunburst for detailed work and openai/gpt-image-2.6-flare for fast iteration. Requesting svg from another model returns a 400 before any provider is called.
- How much does AI SVG generation cost?
- Each SVG request bills the image tokens of the reference image at GPT Image 2.6 rates ($5 per million text input tokens and $30 per million image output tokens) plus the authoring model's tokens at that model's catalogue rates (unpriced authoring tokens are omitted and logged for reconciliation). The response's usage.cost shows the total for every request.
- Can I edit an existing SVG with AI?
- Not through the image edit endpoint: OpenAI does not accept SVG as an edit input or return SVG from edits. Generate a new SVG with a revised prompt, or edit the returned file by hand, since it is plain XML.