Text to SVG
https://api.imagemcpserver.com/playground/text-to-svgReturns 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
| Field | Type | Description |
|---|---|---|
Authorizationrequired | string | Bearer <IMAGEMCP_API_KEY>. The header x-api-key: <key> is accepted as an alternative. |
Content-Typerequired | string | application/json |
Body parameters
| Field | Type | Description |
|---|---|---|
promptrequired | string | Describe the mark. Naming the shape language — flat, line art, geometric, single colour — helps considerably. |
style | string | Defaults 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.
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"
}'imagemcp.js text_to_svg --prompt "Minimalist rocket logo mark, flat vector" --out ./rocket.svgconst res = await fetch("https://api.imagemcpserver.com/playground/text-to-svg", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMAGEMCP_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"prompt": "Minimalist rocket logo mark, flat vector, two colours, geometric",
"style": "logo"
}),
});
const data = await res.json();
console.log(data.result.svgCode);import os
import requests
res = requests.post(
"https://api.imagemcpserver.com/playground/text-to-svg",
headers={"Authorization": f"Bearer {os.environ['IMAGEMCP_API_KEY']}"},
json={
"prompt": "Minimalist rocket logo mark, flat vector, two colours, geometric",
"style": "logo"
},
timeout=120,
)
print(res.json()){
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "text_to_svg",
"arguments": {
"prompt": "Minimalist rocket logo mark, flat vector, two colours, geometric",
"style": "logo"
}
}
}Response
Response fields
| Field | Type | Description |
|---|---|---|
result.svgCode | string | The SVG markup, ready to write to a file or inline in JSX. |
result.dataUrl | string | The same graphic as a data URI, usable directly in src. |
result.imageUrl | string | Alias of dataUrl, so shared image-handling code keeps working. |
deductedCredits | number | Always 5. |
userCredits | number | Balance remaining after the call. |
{
"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
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.