API reference · Vector

Text to SVG

POSThttps://api.imagemcpserver.com/playground/text-to-svg
💳 5 credits🛠️ MCP tool: text_to_svgimagemcp.js text_to_svg

Returns SVG source code rather than a raster image, so the result scales cleanly, recolours with CSS and drops straight into a component. Best suited to icons, logotypes, badges and simple illustrations; complex photographic scenes belong in generate_image.

Overview

Generate real vector SVG markup — icons, logos and marks — from a prompt.

Flat 5 credits per call.

Request

Headers

FieldTypeDescription
AuthorizationrequiredstringBearer <IMAGEMCP_API_KEY>. The header x-api-key: <key> is accepted as an alternative.
Content-Typerequiredstringapplication/json

Body parameters

FieldTypeDescription
promptrequiredstringDescribe the mark. Naming the shape language — flat, line art, geometric, single colour — helps considerably.
stylestringDefaults to "icon". Recorded and echoed back; put style direction in the prompt.

Examples

The same call in five forms. The MCP tab is what an MCP client sends under the hood; the CLI tab is what an agent with the agent skill runs.

text_to_svg
curl -X POST "https://api.imagemcpserver.com/playground/text-to-svg" \
  -H "Authorization: Bearer $IMAGEMCP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "prompt": "Minimalist rocket logo mark, flat vector, two colours, geometric",
  "style": "logo"
}'

Response

Response fields

FieldTypeDescription
result.svgCodestringThe SVG markup, ready to write to a file or inline in JSX.
result.dataUrlstringThe same graphic as a data URI, usable directly in src.
result.imageUrlstringAlias of dataUrl, so shared image-handling code keeps working.
deductedCreditsnumberAlways 5.
userCreditsnumberBalance remaining after the call.
200 OK
{
  "success": true,
  "message": "SVG vector generated successfully via Fal.ai",
  "deductedCredits": 5,
  "userCredits": 2419,
  "result": {
    "svgCode": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">…</svg>",
    "dataUrl": "https://cdn.imagemcpserver.com/svg/rocket_logo.svg",
    "imageUrl": "https://cdn.imagemcpserver.com/svg/rocket_logo.svg",
    "prompt": "Minimalist rocket logo mark, flat vector",
    "style": "logo",
    "model": "fal-ai/recraft/v4.1/text-to-vector",
    "seed": 904412,
    "latency": "3.36s",
    "cost": "$0.0250",
    "deductedCredits": 5,
    "userCredits": 2419
  }
}

When it fails

Errors return success: false with a message. See errors & troubleshooting for the status codes and whether a retry is worth it.

FAQ

Do I get SVG source or an image of a vector?

Source. result.svgCode contains the markup, so you can edit paths, recolour with CSS and inline it in a component.

What kind of prompts work best for vectors?

Simple, bounded subjects: icons, logotypes, badges, mascots. Photographic scenes and heavy gradients do not vectorise well — use generate_image for those.