# recraft/recraft-v4-1-vector

Source: https://docs.sociaro.com/models/recraft-recraft-v4-1-vector/

Recraft V4.1 Vector, served direct from Recraft.

SVG artwork from a prompt, up to six per request, with a color palette, a background color, a saved style and style reference images.

Billed per SVG delivered, with one additional charge per request that sends style references.

Submit and poll on `POST /v1/recraft/generations`, or send it to the Jobs API (`POST /v2/jobs`, one SVG per job).

Recraft on this gateway: [`recraft/recraft-creative-upscale`](https://docs.sociaro.com/models/recraft-recraft-creative-upscale/index.md) · [`recraft/recraft-crisp-upscale`](https://docs.sociaro.com/models/recraft-recraft-crisp-upscale/index.md) · [`recraft/recraft-remove-background`](https://docs.sociaro.com/models/recraft-recraft-remove-background/index.md) · [`recraft/recraft-v4-1`](https://docs.sociaro.com/models/recraft-recraft-v4-1/index.md) · [`recraft/recraft-v4-1-flash-v2`](https://docs.sociaro.com/models/recraft-recraft-v4-1-flash-v2/index.md) · [`recraft/recraft-v4-1-pro`](https://docs.sociaro.com/models/recraft-recraft-v4-1-pro/index.md) · [`recraft/recraft-v4-1-pro-vector`](https://docs.sociaro.com/models/recraft-recraft-v4-1-pro-vector/index.md) · `recraft/recraft-v4-1-vector` (this page) · [`recraft/recraft-vectorize`](https://docs.sociaro.com/models/recraft-recraft-vectorize/index.md).

|  |  |
| --- | --- |
| Slug | `recraft/recraft-v4-1-vector` |
| Kind | image |
| Vendor | recraft |
| Endpoint | `POST /v1/recraft/generations` |

[View pricing and billing conditions](https://docs.sociaro.com/models/recraft-recraft-v4-1-vector/#pricing)

## Example request

cURL

```bash
curl https://api.sociaro.com/v1/recraft/generations \
  -H "Authorization: Bearer $SOCIARO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "recraft/recraft-v4-1-vector",
        "input": {"prompt": "a paper boat on a rain-soaked street"}
      }'

# then poll the job id it returns:
curl https://api.sociaro.com/v1/recraft/generations/JOB_ID \
  -H "Authorization: Bearer $SOCIARO_API_KEY"
```

Python

```python
# Requires Python 3 and requests (pip install requests).
import os
import time
import requests

payload = {'model': 'recraft/recraft-v4-1-vector',
 'input': {'prompt': 'a paper boat on a rain-soaked street'}}

response = requests.post(
    'https://api.sociaro.com/v1/recraft/generations',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        'Content-Type': 'application/json',
    },
    json=payload,
    timeout=120,
)
response.raise_for_status()
submitted = response.json()
job_id = submitted['job_id']
print(submitted)

# then poll the job id it returns:
while True:
    response = requests.get(
        'https://api.sociaro.com/v1/recraft/generations/' + job_id,
        headers={
            'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        },
        timeout=120,
    )
    response.raise_for_status()
    result = response.json()
    status = result['status']
    if status == 'completed':
        break
    if status not in ('submitted', 'processing'):
        raise RuntimeError(result)
    time.sleep(5)
print(result)
```

JavaScript

```javascript
// Run as an .mjs file with Node.js 22 or later.
let jobId;
let result;

{
  const payload = {
    "model": "recraft/recraft-v4-1-vector",
    "input": {
      "prompt": "a paper boat on a rain-soaked street"
    }
  };
  
  const response = await fetch("https://api.sociaro.com/v1/recraft/generations", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  const submitted = await response.json();
  jobId = submitted.job_id;
  console.log(submitted);
}

// then poll the job id it returns:
{
  while (true) {
    const response = await fetch("https://api.sociaro.com/v1/recraft/generations/" + jobId, {
      headers: {
        "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      },
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    result = await response.json();
    const status = result.status;
    if (status === "completed") break;
    if (!["submitted", "processing"].includes(status)) throw new Error(JSON.stringify(result));
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
  console.log(result);
}
```

## Parameters

Recraft V4.1 Vector — SVG artwork from a prompt

| Field | Type | Required | Default | Values | What it does |
| --- | --- | --- | --- | --- | --- |
| `input.prompt` | string | yes | — | text, 1–10,000 characters | What to generate. |
| `input.n` | integer | no | 1 | 1–6 | Images generated per request, each billed. Fixed at 1 on `/v2/jobs`. |
| `input.size` | string | no | from the prompt | an aspect ratio | One of 1:1 · 2:1 · 1:2 · 3:2 · 2:3 · 4:3 · 3:4 · 5:4 · 4:5 · 6:10 · 14:10 · 10:14 · 16:9 · 9:16. Left out, the generator picks one from the prompt. Does not change the price. |
| `input.image_format` | string | no | webp | webp · png | The raster format of the result: `webp` (lossless) or `png`. A vector result is always SVG. |
| `input.random_seed` | integer | no | random | 0–4294967295 | The same seed and request reproduce the same picture. |
| `input.controls` | object | no | — | colors · background_color | Color preferences. `colors`: up to 10 objects `{rgb: [red, green, blue], weight}`, each of the three numbers 0–255, an optional `std` (numbers, one per channel) and `weight` 0–1, given on every color or on none, the weights summing to at most 1. `background_color`: one `{rgb, weight}` object. Does not change the price. |
| `input.style_id` | string | no | — | a style UUID | Generates in a saved style: a public or shared style of the same model, or a `style_id` you got from the /v1 poll answer (`GET /v1/recraft/generations/{job_id}`) of an earlier request that sent `style_reference_urls`; /v2 jobs do not return it. Cannot be combined with `style_reference_urls`. |
| `input.style_reference_urls` | string[] | no | — | 1–10 public https urls | Images whose style the result borrows: PNG, JPEG or WEBP, 64 MB in total. The style they make is returned as a `style_id` in the /v1 poll answer, not by /v2 jobs; reuse it on either door. Style references are billed once per request. |
| `input.style_match` | string | no | the style's own | flexible · precise | How closely the result follows the style. Left out, the style's own setting applies. |
| `input.zdr` | boolean | no | false | true · false | Zero data retention: Recraft neither stores nor logs the prompt or any input image. It does not cover the result: the gateway always asks for it as a link, which Recraft stores to serve it. Does not change the price. |

The endpoint rejects unknown request fields.

### Worked example

cURL

```bash
curl https://api.sociaro.com/v1/recraft/generations \
  -H "Authorization: Bearer $SOCIARO_API_KEY" -H "Content-Type: application/json" \
  -d '{"model": "recraft/recraft-v4-1-vector", "input": {"prompt": "a paper boat on wet asphalt, rain, late light"}}'

curl https://api.sociaro.com/v1/recraft/generations/{job_id} -H "Authorization: Bearer $SOCIARO_API_KEY"

# the same on the Jobs API
curl https://api.sociaro.com/v2/jobs \
  -H "Authorization: Bearer $SOCIARO_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: my-request-0005" \
  -d '{"model": "recraft/recraft-v4-1-vector", "input": {"prompt": "a paper boat on wet asphalt, rain, late light"}}'
```

Python

```python
# Requires Python 3 and requests (pip install requests).
import os
import time
import requests

payload = {'model': 'recraft/recraft-v4-1-vector',
 'input': {'prompt': 'a paper boat on wet asphalt, rain, late light'}}

response = requests.post(
    'https://api.sociaro.com/v1/recraft/generations',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        'Content-Type': 'application/json',
    },
    json=payload,
    timeout=120,
)
response.raise_for_status()
submitted = response.json()
job_id = submitted['job_id']
print(submitted)

while True:
    response = requests.get(
        'https://api.sociaro.com/v1/recraft/generations/' + job_id,
        headers={
            'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        },
        timeout=120,
    )
    response.raise_for_status()
    result = response.json()
    status = result['status']
    if status == 'completed':
        break
    if status not in ('submitted', 'processing'):
        raise RuntimeError(result)
    time.sleep(5)
print(result)

# the same on the Jobs API
payload = {'model': 'recraft/recraft-v4-1-vector',
 'input': {'prompt': 'a paper boat on wet asphalt, rain, late light'}}

response = requests.post(
    'https://api.sociaro.com/v2/jobs',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        'Content-Type': 'application/json',
        'Idempotency-Key': 'my-request-0005',
    },
    json=payload,
    timeout=120,
)
response.raise_for_status()
print(response.text)
```

JavaScript

```javascript
// Run as an .mjs file with Node.js 22 or later.
let jobId;
let result;

{
  const payload = {
    "model": "recraft/recraft-v4-1-vector",
    "input": {
      "prompt": "a paper boat on wet asphalt, rain, late light"
    }
  };
  
  const response = await fetch("https://api.sociaro.com/v1/recraft/generations", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  const submitted = await response.json();
  jobId = submitted.job_id;
  console.log(submitted);
}

{
  while (true) {
    const response = await fetch("https://api.sociaro.com/v1/recraft/generations/" + jobId, {
      headers: {
        "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      },
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    result = await response.json();
    const status = result.status;
    if (status === "completed") break;
    if (!["submitted", "processing"].includes(status)) throw new Error(JSON.stringify(result));
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
  console.log(result);
}

// the same on the Jobs API
{
  const payload = {
    "model": "recraft/recraft-v4-1-vector",
    "input": {
      "prompt": "a paper boat on wet asphalt, rain, late light"
    }
  };
  
  const response = await fetch("https://api.sociaro.com/v2/jobs", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      "Content-Type": "application/json",
      "Idempotency-Key": "my-request-0005",
    },
    body: JSON.stringify(payload),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  console.log(await response.text());
}
```

**Submit and poll.** Send `recraft/recraft-v4-1-vector` to `POST /v1/recraft/generations` and poll
`GET /v1/recraft/generations/{job_id}` until `status` is `completed`. The results are in `media_urls`
(`media_url` is the first). On `/v1` the links are on our domain and valid for one hour. On the
[Jobs API](https://docs.sociaro.com/jobs/index.md) (`POST /v2/jobs`, poll `GET /v2/jobs/{id}`) the result is `outputs[0].url`, a permanent link on
our CDN, and `n` is fixed at 1.

**The result is an SVG file** (`image/svg+xml`), not a raster picture.

**Files are urls.** `style_reference_urls` take public https urls; the gateway sends them on as they are. A url the generator cannot fetch or a file it cannot read is refused by the generator with its own words.

**Unknown fields are refused.** The input is a closed schema: a field not in the table above is a `400` naming it,
because Recraft would silently ignore it and still charge the request.

**A refusal arrives on the poll.** A prompt or an image the generator refuses ends the job `failed`, with the generator's
own reason in `error.message`, when you poll; it is not a `400` at submit, and a failed job is not billed.

**How it is billed.** Each delivered SVG is billed. A request for three SVGs with
`style_reference_urls` incurs three SVG charges and one style-reference charge. See [Pricing](https://docs.sociaro.com/models/recraft-recraft-v4-1-vector/#pricing).

## How a job runs

Generation takes longer than a request should wait, so it goes in three moves: **submit**, then
**poll**, then **collect**.

cURL

```bash
# 1. submit — the model id plus the fields above
curl -sS https://api.sociaro.com/v1/alibaba/generations \
  -H "Authorization: Bearer $SOCIARO_API_KEY" -H "Content-Type: application/json" \
  -d '{ "model": "…", "prompt": "…" }'
# -> { "job_id": "<id>", "status": "submitted" }

# 2. poll every 3-5 s for images, 5-10 s for video
curl -sS https://api.sociaro.com/v1/alibaba/generations/<id> \
  -H "Authorization: Bearer $SOCIARO_API_KEY"
# -> { "job_id": "…", "status": "processing" }
# -> { "job_id": "…", "status": "completed", "model": "…",
#      "media_url": "https://api.sociaro.com/v1/media/<media_id>" }
# -> { "job_id": "…", "status": "failed", "model": "…", "error": { "code": …, "message": … } }

# 3. collect within the hour — the opaque id IS the credential, no header needed
curl -sSL "https://api.sociaro.com/v1/media/<media_id>" -o out.mp4
```

Python

```python
# Requires Python 3 and requests (pip install requests).
from pathlib import Path
import os
import time
import requests

# 1. submit — the model id plus the fields above
# Save the complete request body in request.json.
response = requests.post(
    'https://api.sociaro.com/v1/alibaba/generations',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        'Content-Type': 'application/json',
    },
    data=Path('request.json').read_bytes(),
    timeout=120,
)
response.raise_for_status()
submitted = response.json()
job_id = submitted['job_id']
print(submitted)

# 2. poll every 3-5 s for images, 5-10 s for video
while True:
    response = requests.get(
        'https://api.sociaro.com/v1/alibaba/generations/' + job_id,
        headers={
            'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        },
        timeout=120,
    )
    response.raise_for_status()
    result = response.json()
    status = result['status']
    if status == 'completed':
        break
    if status not in ('submitted', 'processing'):
        raise RuntimeError(result)
    time.sleep(5)
print(result)

# 3. collect within the hour — the opaque id IS the credential, no header needed
response = requests.get(
    result['media_url'],
    timeout=120,
)
response.raise_for_status()
Path('out.mp4').write_bytes(response.content)
```

JavaScript

```javascript
// Run as an .mjs file with Node.js 22 or later.
import { readFile, writeFile } from "node:fs/promises";
let jobId;
let result;

// 1. submit — the model id plus the fields above
{
  // Save the complete request body in request.json.
  const response = await fetch("https://api.sociaro.com/v1/alibaba/generations", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      "Content-Type": "application/json",
    },
    body: await readFile("request.json"),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  const submitted = await response.json();
  jobId = submitted.job_id;
  console.log(submitted);
}

// 2. poll every 3-5 s for images, 5-10 s for video
{
  while (true) {
    const response = await fetch("https://api.sociaro.com/v1/alibaba/generations/" + jobId, {
      headers: {
        "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      },
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    result = await response.json();
    const status = result.status;
    if (status === "completed") break;
    if (!["submitted", "processing"].includes(status)) throw new Error(JSON.stringify(result));
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
  console.log(result);
}

// 3. collect within the hour — the opaque id IS the credential, no header needed
{
  const response = await fetch(result.media_url);
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  await writeFile("out.mp4", new Uint8Array(await response.arrayBuffer()));
}
```

Use the `job_id` verbatim as the path segment when polling: the two names are the same value.
Which submit and poll URL this model uses is at the top of this page, under **Calling it**.

## Reading the poll

`status` is one of `processing` · `completed` · `failed`. Only `completed` carries `media_url`,
only `failed` carries `error`.

**Gate on `status`, never on the poll's HTTP code.** A poll-time failure is `HTTP 200` with
`status: "failed"` and an `error` object of `{ "code", "message" }`, plus `provider_code` when the
generator supplied one — on every failure branch, including one where the result could not be
delivered. A submit-time rejection is different: it comes back as its own HTTP status with the
reason in the body.

**`code` is ours and stable; `message` is the generator's.** Match on `code`: it comes from a small
fixed set, and `provider_failed` still means what it always meant. A rejection of **what you sent** —
a size out of range, an unusable input — additionally sets `code: "invalid_request"`, because that is
a different thing for your code to do. `message` now carries the generator's own sentence, and
`provider_code` its own code (`OutputVideoSensitiveContentDetected.PolicyViolation`,
`IPInfringementSuspect`), so a moderated generation, a copyright refusal and a broken renderer are
finally distinguishable. Treat `provider_code` as informational: the vendors change these strings
without telling us, so branch on ours.

**`message` is variable text, capped at 400 characters.** It used to be a single fixed
43-character sentence, so if you compare it by equality or keep it in a narrower column, that needs
changing — match on `code`, and on `provider_code` when you need the finer distinction.

**Two things that text is not.** It does not name the generator behind the model: the names of the
services and hosts that actually run your job are substituted out before you see it, so do not parse
it for one. What it does **not** hide is a name you already have — the halves of the model id you
called (`alibaba`, `bytedance`, `wan`, `qwen`, `seedance`, `seedream`, `happyhorse`) stay as written,
because blanking those would garble the message exactly where it is useful: `Model
alibaba/wan-2-7-image not found` has to survive intact. And the text can **quote your own request
back**: a moderation message often contains the fragment it objected to. That is why we do not write
it into our own logs, and why forwarding or storing a failed poll's `message` is your decision to
make rather than something to do by default.

## Collecting the result

`media_url` points at our host, not the generator's. It is a **capability**: the opaque id is the
credential, so no `Authorization` header is needed and anyone holding the link can fetch it. It
**expires within the hour** — download rather than store the link.

**Several images are not optional extras.** An Alibaba image model asked for more than one picture
(`n` above 1) is charged for the number of pictures the generator reports making, and every link it
returns is delivered, never fewer than that number: `media_urls` lists
all of them in the generator's order (present on every image result, even a single one) and
`media_url` is the first. Each has its own link and its own expiry. If any one of them cannot be
delivered the job is reported `failed` and **nothing is charged** — unlike a still or a layer, an
image you paid for is never left out.

## Rules the gateway adds

Two fields are ours and never reach the generator:

| Field | Notes |
| --- | --- |
| `model` | which model to run |
| `user` | your own end-user id. Recorded against this job's spend so you can attribute cost per end user, and stripped before the request leaves us, so the generator never sees it. Validated BEFORE the job is created, so a rejection is free: a string of at most 128 characters, no control characters, valid UTF-8. Omitting it, or sending `null`, is fine and simply records no end user |

**An unknown field is always a `400`.** Most generators reject one themselves; some accept it,
ignore it, render something other than what you asked for and bill you — so we refuse it for you.
Either way you get `400 unknown field(s): [...]` naming the offender, never a surprise render.

Ranges and enums are the generator's own and we do not re-validate most of them, so an
out-of-range value comes back as its rejection, in its wording and with its numbers. The one thing
we DO check ourselves is `resolution`, because an unsupported tier is silently ignored rather than
refused: you would ask for the higher tier, be handed a lower one, and be charged. The tiers on
this page are read from what the vendor prices, so they change when the vendor publishes one.

## Authentication

`Authorization: Bearer <your-api-key>` on submit and on poll. The key must be valid AND granted
this model — `403` otherwise.

One deliberate exception on **poll**: a key that is over budget may still poll and collect a job it
already submitted, so work you have already paid for is never stranded by a budget that ran out
mid-generation. While the key is over budget the gateway cannot read its model list at all, so the
per-model grant is not re-checked on those polls — a grant revoked after submit still collects that
job. Ownership is always enforced: a job can only be polled by the key that created it, and submit
is always refused in that state.

## Pricing

| Billable unit and options | Rate (USD) |
| --- | --- |
| per image | $0.08 |
| style references, once per request added to the per-image price of the request | $0.005 |

- Billed per image delivered; n multiplies the price.

[View this model in the pricing catalogue](https://sociaro.com/pricing?model=recraft%2Frecraft-v4-1-vector). Your [billing logs](https://docs.sociaro.com/billing/index.md) show the actual charge for each request.
