text_to_svg · POST /v1/text-to-svg · flat 5 credits

AI SVG generator API: real vector paths from a prompt.

An AI SVG generator API turns a written description into genuine vector artwork — path data you can recolour, rescale and edit — rather than a raster image that happens to be saved with an .svg extension.

The markup itself comes back in the response, so the icon your agent just made can be read, judged and written straight into a component file without a download step.

By the imagemcpserver.com teamUpdated

every shape above is path data — resize it, recolour it, animate it

What comes back

Every response carries result.svgCode — the full markup, as a string, on every call. There is no flag to set and no file to fetch first. That is a small detail with a large consequence: an agent can inspect the paths before it commits them, and write the result into a .jsx file as markup rather than downloading a binary and remembering to add it to the repo.

You also get result.dataUrl for dropping straight into an src. Treat that one as a convenience rather than permanent storage — it is either a data URI or a link on the model provider’s CDN, not a file on ours, and a provider link should not be assumed to live forever. If the asset matters, write svgCode to your own repo or storage.

Two different things are called “text to SVG”

Worth clearing up before you integrate the wrong one, because the phrase is genuinely overloaded and the two jobs have nothing in common.

Not this

Lettering to path outlines

Turning typed words into vector outlines so a headline renders identically without the font installed. That is font outlining, it is deterministic, and a local library does it better and for free.

This endpoint

Description to original artwork

You write “a rounded shield with a checkmark” and a model draws one as vector paths. Generative, non-deterministic, and the thing you want when the artwork does not exist yet.

Four things a raster icon can never do

Scale without limit

The same file serves a 16px favicon and a 4-metre trade-show banner. No 1x/2x/3x export matrix.

Recolour in CSS

Set fill to currentColor and the icon follows your theme, dark mode included, with no second asset.

Stay editable forever

Paths remain paths. Nudge a shape, swap a fill, drop a layer — months later, without the original prompt or a source file.

Animate per shape

Individual paths can be transformed, drawn on, or staggered. A PNG can only fade.

The prompt is the only control

There is no style preset to pick. Everything about how the mark looks — its complexity, its palette, its stroke weight — has to be said in the sentence. That sounds like a limitation and mostly is not: naming the shape language explicitly gives more control than a five-value dropdown ever would, and it is the only thing that keeps a set of icons looking like a set.

The one habit worth forming

Write the shape language once — “two colours, thick uniform strokes, flat, no gradients” — and reuse it verbatim in every prompt, varying only the subject. Leave it out and twenty icons come back looking like twenty different libraries.

UI icon

Single-concept marks that stay legible at 16 and 24 pixels. Say so explicitly — “reads clearly at 24px” does real work.

"A rounded shield with a checkmark, two colours, thick uniform strokes, reads clearly at 24px"

Logo mark

A balanced mark with room for a wordmark beside it. Good for placeholder branding while a project finds its feet.

"Minimal wordless logomark for a coffee subscription, warm palette, geometric, flat"

Mascot

A character with a face and a pose, for empty states, onboarding and 404 pages.

"Friendly paper-plane mascot waving, flat vector, soft cream palette, no gradients"

Spot illustration

A small scene with depth, when a section header needs art rather than a symbol.

"Isometric scene of a small server room with plants, flat vector, four colours"

Repeating motif

Backgrounds and dividers, where a raster tile would show its seams.

"Seamless pattern of tiny geometric mountains, two colours, even spacing"

One required field

The whole surface is prompt. Prompts are screened before they reach the model, so a request that trips the safety check comes back as a 400 rather than a charge.

Request
curl -X POST "https://api.imagemcpserver.com/v1/text-to-svg" \
  -H "Authorization: Bearer $IMAGEMCP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A rounded shield with a checkmark,
               two colours, thick uniform strokes"
  }'

And what comes back

The field to build on is svgCode. It is present on every successful call, whatever you asked for.

Response
{
  "success": true,
  "deductedCredits": 5,
  "userCredits": 2419,
  "result": {
    "svgCode": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">…</svg>",
    "dataUrl": "data:image/svg+xml;utf8,%3Csvg…%3C/svg%3E",
    "imageUrl": "data:image/svg+xml;utf8,%3Csvg…%3C/svg%3E",
    "prompt": "A rounded shield with a checkmark, two colours",
    "model": "fal-ai/recraft/v4.1/text-to-vector",
    "seed": 904412,
    "latency": "3.36s"
  }
}

Python and Node

Because the markup is in the response, writing an SVG to disk is two lines after the call — no download step, no temporary file.

Python
import os, pathlib, requests

r = requests.post(
    "https://api.imagemcpserver.com/v1/text-to-svg",
    headers={"Authorization": f"Bearer {os.environ['IMAGEMCP_API_KEY']}"},
    json={"prompt": "A rounded shield with a checkmark, two colours"},
    timeout=90,
)
svg = r.json()["result"]["svgCode"]
pathlib.Path("shield.svg").write_text(svg)
Node
const res = await fetch("https://api.imagemcpserver.com/v1/text-to-svg", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMAGEMCP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "A rounded shield with a checkmark, two colours",
  }),
});
const { result } = await res.json();
await fs.writeFile("shield.svg", result.svgCode);

Every field

The same body works for the REST endpoint and the text_to_svg MCP tool. Two of the three fields below exist only for compatibility — the honest surface is one field wide.

Request body fields accepted by POST /v1/text-to-svg and the text_to_svg MCP tool
FieldAcceptsWhat it does
promptstring · requiredDescribe the mark. Naming the shape language — flat, line art, geometric, two colours, thick uniform strokes — does most of the work.
stylestringRecorded on the request and echoed back as result.style. It is not sent to the model and does not change the output — put style direction in the prompt instead.
modelstringAccepted for forward compatibility but currently ignored: every call runs on the same vector model, which the response names back to you.

What it is good and bad at

AI vector generation has a reputation for producing confident nonsense, and it is partly earned. Knowing where the line sits saves you the credits you would otherwise spend finding it.

Reliable

  • Single-concept UI icons
  • Simple logotype marks and badges
  • Flat spot illustrations with a few shapes
  • Repeating geometric motifs

Expect to fight it

  • Legible lettering inside the artwork
  • Fine detail and intricate line work
  • Anything photographic
  • Exact reproduction of an existing brand mark

Generated vectors are not automatically small

A hand-drawn icon is a few hundred bytes. A model-drawn one can be orders of magnitude larger, because nothing stops it emitting far more path data than the shape needs — the vendor’s own sample output runs to well over a megabyte. Vector still wins on scaling and editability, but if you are inlining the markup, run it through an SVG optimiser before it reaches a page, and check the byte count rather than assuming it.

At 5 credits a call, the sane approach is to generate three and keep one rather than trying to perfect a prompt. Read svgCode before you commit it — an SVG that parses is not automatically an SVG you want in your repo.

What it costs

A flat 5 credits per generation, the cheapest creative call on the platform:

Free

6 vectors

30 credits a month, no card required.

Starter · $20

10¢ each

1,000 credits — about 200 vectors a month.

Pro · $50

≈ 8¢ each

3,000 credits — about 600 vectors a month.

Enterprise · $100

≈ 6¢ each

8,000 credits — about 1,600 vectors a month.

Plenty of free web tools will generate a vector for you if you only need one and do not mind doing it by hand. This is worth paying for when the generation has to happen inside something — a build script, an agent mid-task, a batch of forty icons through multicall — and the markup has to come back as data rather than a download. See plans and credit packs.

Text to SVG questions

Is this a real SVG or a PNG with an .svg extension?

A real SVG. The output is vector path data, which is why you can open it, recolour a shape, change a stroke width and scale it to a billboard without a single soft edge. The markup comes back in the response as result.svgCode, so you can read it before you commit it.

Does “text to SVG” mean converting lettering into paths?

Two different jobs share that name, and this is the other one. Converting typed words into path outlines — so a headline renders without the font installed — is a font-outlining operation, and there are dedicated libraries for it. This endpoint generates original vector artwork from a description: you write “a rounded shield with a checkmark” and get a drawing of one.

Can I convert an existing photo into an SVG?

No — and neither can convert_format, which is deliberate. A photograph has no paths to recover; auto-tracing one produces thousands of junk shapes that are worse than the original in every way except the file extension. Describe what you want in words and generate the vector directly instead.

How do I control the style?

Through the prompt, and only through the prompt. There is a style field on the request, but it is recorded and echoed back rather than sent to the model — setting it to "logo" or "pattern" changes nothing about the output. Naming the shape language in the prompt is what actually works: stroke weight, number of colours, flat versus dimensional, geometric versus organic.

How do I get the SVG source code?

You already have it. Every response carries result.svgCode with the full markup — there is no flag to set and no second request to make. That is the difference that matters for an agent: it can read the paths, decide whether they are any good, and write them straight into a component file.

Where is the generated SVG hosted?

result.dataUrl is either a URL on the model provider’s CDN or a data URI containing the markup, depending on which path produced the file. It is not served from our own CDN like the raster tools are, so treat it as convenient rather than permanent: if you need the asset to persist, write result.svgCode to your own repo or storage.

What is it good at, and what is it bad at?

Good at single-concept marks: icons, logotypes, badges, simple spot illustrations, flat scenes with a handful of shapes. Bad at anything needing fine detail, accurate small lettering inside the artwork, or photographic realism — those come back as either mush or an unreasonable number of paths. Generating a mark is cheap, so budget for two or three attempts rather than expecting the first to land.

How big are the generated SVG files?

Bigger than you would expect, and worth checking. A model has no incentive to be economical with path data, so a generated mark can carry far more geometry than the shape requires — the vendor’s own published sample output is over a megabyte. Run the markup through an SVG optimiser before inlining it, and measure rather than assuming that “vector” means “tiny”.

What does it cost?

A flat 5 credits per generation — the cheapest creative call on the platform, roughly 6 to 10 cents depending on your plan. It runs on our own provider account, so connecting your own OpenRouter key does not change the price.

Can I generate a whole icon set in one go?

Yes, through multicall — the calls are dispatched concurrently and billed as one deduction. Put the same shape-language sentence in every prompt and vary only the subject, which is what keeps twenty icons looking like one family instead of twenty libraries.

What happens if generation fails?

The call answers 500 with refundedCredits in the body and the 5 credits are returned automatically.

Reference

Related