Skip to main content
This page is written to be pasted into an AI agent (Claude, Cursor, ChatGPT, Copilot) as context. The Markdown version is at https://www.recraft.ai/docs/api-reference/agents.md. Everything needed to write working code against the Recraft API is here.

Rules for writing code

  1. Use plain HTTP: curl, Python requests, or JavaScript fetch. Do not use the OpenAI SDK unless asked; if you do, every non-OpenAI parameter must go in extra_body.
  2. Read the token from the RECRAFT_API_TOKEN environment variable. Never hard-code it.
  3. Always pass model explicitly. Pick it from the model table below.
  4. Only send parameters the chosen model supports (see the model table). Unsupported parameters are rejected or ignored.
  5. On a non-2xx response, print the status code and the response body (it explains the error), then stop. Errors keep a JSON body and a non-2xx status with every response_format.
  6. Image URLs in responses are temporary (about 24 hours). Download the files if they must be kept.
  7. Send JSON (Content-Type: application/json). Pass input images as URLs, or local files as data URLs (data:image/png;base64,...), so nested fields like controls keep working. Use multipart/form-data only for simple uploads with flat fields.

Basics

  • Base URL: https://external.api.recraft.ai/v1
  • Auth header: Authorization: Bearer $RECRAFT_API_TOKEN
  • Token: created at https://app.recraft.ai/profile/api (needs a positive API units balance). 1 USD = 1,000 API units.
  • Rate limits: 100 images per minute and 5 requests per second per user.

Minimal request

Response of generation, image to image, remix, and the V3 edit endpoints:
  • data: one item per image. url is present with response_format: url (default); b64_json with response_format: b64_json.
  • credits: API units charged.
  • style_id: present when a style was created from attached references.
  • response_format: multipart returns multipart/form-data: a response part with the JSON above, then one part per image, named by its image_id (also in the Content-ID header). Lowest latency.
  • image_format: webp (default, lossless) or png for raster output. Vector output is always SVG.

Models

model value, output, price per image, and what each accepts on POST /v1/images/generations. Which to pick:
  • Default, best quality: recraftv4_1. Print-ready 2K: _pro. SVG: _vector.
  • Product shots, mockups, flat predictable images: recraftv4_1_utility*.
  • Fastest and cheapest (about 1.3 s), raster only, no styles: recraftv4_1_flash.
  • Must match a given visual style from reference images: recraftv4_styles* (a style is required).
  • Curated named styles, negative_prompt, exact text placement, inpainting, outpainting, background operations: recraftv3 / recraftv3_vector.
  • Cheapest vector, icons: recraftv2_vector.
Parameter support by model family:

Generate image

POST /v1/images/generations. Variants that enforce the output type: POST /v1/images/generations/raster and POST /v1/images/generations/vector. Exact sizes by model (same order as the w:h list above):

Styles

POST /v1/styles creates a reusable style (0.005 USD). Returns {"id": "<style_id>", ...}. Two ways to apply a style: create it once and pass style_id (cheaper for repeated use), or attach style_reference_urls to each generation.

Edit an image

All take the input as image_url (JSON: URL or data URL) or image (multipart file). Masks: mask_url / mask, grayscale, same size as the image, white = area to change, black = keep. Input limits: under 10 MB, up to 16 MP, max side 4096 px, min side 256 px. Mask pixels must be pure black (0) or pure white (255). All accept response_format and image_format. To avoid unwanted content (“no people, no text”) with V2 / V3 models, use negative_prompt, not controls.

Process an image

Input as image_url (JSON) or file (multipart). No model field. Min side 256 px (32 px for crisp upscale). These endpoints, and erase region, return a single image instead of a data array:
Read response.json()['image']['url'], not ['data'][0].

Other endpoints

  • POST /v1/prompts/enhance with {"prompt": "..."} (up to 2,000 characters) returns {"enhanced_prompt": "..."}. 0.01 USD.
  • GET /v1/users/me returns {"id", "email", "name", "credits"}: the remaining API units balance.

Examples

Vector logo in brand colors:
Generate in a style from reference images, then reuse it:
Inpaint local files, sent as data URLs:
Lowest latency: image bytes in the response (response_format: multipart):
Full human-readable docs: https://www.recraft.ai/docs/api-reference/introduction. Index of all pages: https://www.recraft.ai/docs/llms.txt.