Recraft V4 SVG Serverless API
Text-to-SVG editable vector graphics for logos, icons, illustrations.
POST /v2/recraft-v4-svg · submit + poll 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "recraft-v4-svg",
9 prompt="A tabletop board-game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat vector illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, clean geometry, bold flat shapes.",
10 style_reference_urls=[],
11 size="1:1",
12 style_match="flexible",
13 colors=[],
14 background_color=None,
15 seed=-1,
16)
17print(result["status"]) # COMPLETED
18print(result.get("output")) # model output (e.g. media URL)
19print(result["metrics"]["inference_time"]) # server compute seconds
20
21# --- Or submit + poll manually (track request_id, control the cadence) ---
22from segmind import SegmindClient, InferenceFailed, InferenceTimeout
23
24client = SegmindClient() # reads SEGMIND_API_KEY
25payload = {
26 "prompt": "A tabletop board-game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat vector illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, clean geometry, bold flat shapes.",
27 "style_reference_urls": [],
28 "size": "1:1",
29 "style_match": "flexible",
30 "colors": [],
31 "background_color": None,
32 "seed": -1,
33}
34job = client.submit_async("recraft-v4-svg", **payload)
35print(job.request_id) # available immediately
36try:
37 result = job.wait(timeout=600, interval=1.0)
38except InferenceTimeout as e:
39 print("still running:", e.request_id)
40except InferenceFailed as e:
41 print("failed:", e.detail) 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "recraft-v4-svg",
9 prompt="A tabletop board-game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat vector illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, clean geometry, bold flat shapes.",
10 style_reference_urls=[],
11 size="1:1",
12 style_match="flexible",
13 colors=[],
14 background_color=None,
15 seed=-1,
16)
17print(result["status"]) # COMPLETED
18print(result.get("output")) # model output (e.g. media URL)
19print(result["metrics"]["inference_time"]) # server compute seconds
20
21# --- Or submit + poll manually (track request_id, control the cadence) ---
22from segmind import SegmindClient, InferenceFailed, InferenceTimeout
23
24client = SegmindClient() # reads SEGMIND_API_KEY
25payload = {
26 "prompt": "A tabletop board-game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat vector illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, clean geometry, bold flat shapes.",
27 "style_reference_urls": [],
28 "size": "1:1",
29 "style_match": "flexible",
30 "colors": [],
31 "background_color": None,
32 "seed": -1,
33}
34job = client.submit_async("recraft-v4-svg", **payload)
35print(job.request_id) # available immediately
36try:
37 result = job.wait(timeout=600, interval=1.0)
38except InferenceTimeout as e:
39 print("still running:", e.request_id)
40except InferenceFailed as e:
41 print("failed:", e.detail)API Endpoint
https://api.segmind.com/v1/recraft-v4-svgParameters
promptrequiredstringText describing the image to generate (up to 10,000 characters). Text you want rendered in the image can be quoted directly.
background_coloroptionalstringPreferred background color as a #RRGGBB hex value.
nullcolorsoptionalstring[]Up to 10 preferred colors as #RRGGBB hex values, e.g. #1E90FF.
[]seedoptionalintegerSeed for reproducible generation. -1 picks a random seed.
-1Range: -1 - 2147483647sizeoptionalstringAspect ratio of the generated vector image. Auto lets Recraft pick from the prompt.
"auto""auto""1:1""2:1""1:2""3:2""2:3""4:3""3:4""5:4""4:5"+5 morestyle_matchoptionalstringHow closely to follow the style reference images. Only used when style reference images are attached.
"flexible""flexible""precise"style_reference_urlsoptionalstring[]Optional 1-10 images (PNG, JPG or WEBP) whose look the generation should match: rendering technique, colors, texture and composition. A one-off style-creation fee is added when references are attached.
[]Response Type
Returns: Text/JSON
Asynchronous requests (v2)
Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.
- 1
POST /v2/recraft-v4-svgSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- A FAILED request is served as HTTP 422 — the body still carries the error detail.
- An unknown or expired request_id returns HTTP 404.
- Results are retained for 1 hour, then expire.
- Content / RAI blocks surface as FAILED, not a separate state.
- Track completion by polling the status endpoint.
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out