Curious how Recraft API can transform your design flow? Powered by Recraft V3 – the #1 model on Hugging Face’s industry-leading benchmark for text-to-image generation – it helps businesses and developers create visuals perfectly tailored to their brand.
The API lets you:
- Generate images with text of any size – perfect for posters, ads, or branded visuals.
- Create fully scalable vector art for logos, icons, and precise designs.
- Design custom styles, controlling every detail from colors to textures.
- Generate images in exact brand colors for perfect visual alignment.
- Vectorize PNGs/JPGs into scalable graphics.
Recraft V3 is a state-of-the-art innovation and the only API in the world offering text generation of any size and scalable vector art. Beyond its core functions, Recraft’s API includes tools like background removal, generative and clarity upscaling, style customization, and the ability to generate images in various aspect ratios.
With a simple pricing model ($0.04 per raster image, $0.08 per vector image), Recraft API is accessible for businesses of all sizes.
API Unit charges for API services
The following are the Service charges (in API Units) for use of the API Services. API Units will be automatically deducted from Member’s pre-purchased API Unit package upon use of the described Service by the Member. The Recraft Service is the system of record for determining API Unit usage. Please note, Services charges do not depend on model.
Service Description | Cost (USD) | API Units Charged |
---|---|---|
Raster Image Generation Per One Image | $0.04 | 40 |
Vector Image Generation Per One Image | $0.08 | 80 |
Image Style Creation | $0.04 | 40 |
Image Vectorization | $0.04 | 40 |
Image Background Removal | $0.04 | 40 |
Clarity Upscale | $0.04 | 40 |
Generative Upscale | $0.8 | 800 |
Exploring the Unique Features of Recraft’s API
Recraft’s API stands out with its innovative features, making it a versatile tool for a variety of creative needs.
1. Accurate Text Integration
Recraft V3 is the first model that allows users to generate images with text in any size—large, medium, or small. This functionality is ideal for creating posters, advertisements, and visuals requiring precise text integration.
2. Fully Scalable Vector Art
Recraft is the pioneer API for producing fully scalable vector images, which are perfect for designs such as logos, icons, and graphics that demand precision and flexibility across different sizes.
3. Customizable Brand Styles
With Recraft’s API, users can develop custom brand styles by uploading a set of brand images. Every visual detail—textures, colors, and composition—can be customized to align with unique brand aesthetics.
4. Brand-Consistent Colors
The API ensures that images adhere to exact brand colors, making it easier to create visuals that are perfectly aligned with branding guidelines.
5. Image Vectorization
Recraft’s state-of-the-art image vectorizer converts pixel-heavy PNG and JPG files into clean, scalable vector graphics, ensuring flawless designs at any resolution.
6. Advanced AI Tools for Visual Manipulation
Recraft also offers a suite of AI-powered tools to enhance visuals:
- Background Removal: Effortlessly isolate subjects from backgrounds.
- Creative Upscaling: Increase resolution while adding creative details for enhanced quality.
- Clarity Upscaling: Transform blurry images into sharp, high-quality visuals, perfect for larger formats.
7. Broad Style Options and Aspect Ratios
Recraft’s API allows users to generate images in a variety of styles, including photorealism, clay, retro-pop, hand-drawn, 80s aesthetics, hard flash, and plastic. Alternatively, users can rely on detailed text prompts to achieve the desired results without specifying a style. Additionally, the API supports various aspect ratios, ensuring visuals fit seamlessly into any layout or design.
With these advanced features, Recraft’s API empowers creators to bring their ideas to life with precision, flexibility, and creative freedom.
Getting Started with Recraft API
Begin working with the Recraft API quickly and efficiently by following these steps.
Authentication
Recraft uses Bearer API tokens for secure authentication. To generate your API key, log in to your Recraft account, navigate to your profile, and click ‘Generate’ (note: this option is available only if you have a positive API unit balance). All API requests must include your API key in the Authorization HTTP header, formatted as follows:
makefileCopy codeAuthorization: Bearer RECRAFT_API_TOKEN
REST and Python Library Support
The Recraft API is built on REST principles, allowing seamless interaction through various tools (e.g., curl), programming languages, or libraries of your choice.
For ease of use, the OpenAI Python library is also compatible with Recraft’s API. However, keep in mind that not all parameters and options are fully supported or implemented. Some parameters may have different meanings or may be silently ignored if they do not apply to the Recraft API.
Authentication Example Using the OpenAI Library
Below is an example of authenticating with Recraft’s API using the OpenAI Python library:
pythonCopy codefrom openai import OpenAI
client = OpenAI(
base_url='https://external.api.recraft.ai/v1',
api_key=<TOKEN>,
)
Future examples will use this library for clarity and simplicity.
Usage
Dig into the details of using the Recraft API.
Generate Image
Creates an image given a prompt.
POST https://external.api.recraft.ai/v1/images/generations
Example
response = client.images.generate(
prompt='race car on a track',
style='digital_illustration',
)
print(response.data[0].url)
Output
URL: https://img.recraft.ai/TH4CG_8z2Ql8G1B_mx9tkVQk67i6TmdM9Av13L2-ERE
/rs:fit:1024:1024:0/raw:1/plain/abs:/
/prod/images/a9f881cb-7638-4fa8-88d2-cc65dbfd0375
Parameters
Parameter | Type | Description |
---|---|---|
prompt (required) | string | A text description of the desired image(s). The maximum length is 1000 characters |
n | integer or null, default is 1 | Currently, only n=1 and n=2 are supported at the momen |
style_id | UUID or null | Use a previously uploaded style as a reference, this topic is covered above and below |
style | string or null, default is realistic_image | The style of the generated images, this topic is covered above |
substyle | string or null | This topic is covered above |
model | string or null, default is recraftv3 | The model to use for image generation. Must be one of recraftv3 or recraft20b |
response_format | string or null, default is url | The format in which the generated images are returned. Must be one of url or b64_json |
size | string or null, default is 1024x1024 | The size of the generated images in WxH format, supported values are published below |
controls | object or null | A set of custom parameters to tweak generation process, this topic is covered below |
Note: style_id
and style
parameters are mutually exclusive. If neither of the two parameters is specified, the default style of realistic_image
will be used
Hint: if OpenAI Python Library is used, non-standard parameters can be passed using the extra_body
argument. For example:
response = client.images.generate(
prompt='race car on a track',
extra_body={
'style_id': style_id,
'controls': {
...
}
}
)
print(response.data[0].url)
Vectorize Image
Converts a given raster image to SVG format.
POST https://external.api.recraft.ai/v1/images/vectorize
Example
response = client.post(
path='/images/vectorize',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
Output
https://img.recraft.ai/fZm6nwEjI9Qy94LukIKbxRm4w2i5crwqu459qKg7ZWY
/rs:fit:1341:1341:0/raw:1/plain/abs://external/images/2835e19f-282b-419b-b80c-9231a3d51517
Parameters
Body of a request should be a file in PNG format and parameters passed as content type 'multipart/form-data'
.
Parameter | Type | Description |
---|---|---|
response_format | string or null, default is url | The format in which the generated images are returned. Must be one of ‘url’ or ‘b64_json’. |
Remove Background
Removes background of a given raster image.
POST https://external.api.recraft.ai/v1/images/removeBackground
Example
response = client.post(
path='/images/removeBackground',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
Output
https://img.recraft.ai/EYOLjpky-2-uClelfP61kzK-SEpIhKgLfjLFFGxmM_U
/rs:fit:0:0:0/raw:1/plain/abs://external/images/e2d0cba6-12df-4141-aa21-43bfd5889990
Parameters
Body of a request should be a file in PNG format and parameters passed as content type 'multipart/form-data'
.
Parameter | Type | Description |
---|---|---|
response_format | string or null, default is url | The format in which the generated images are returned. Must be one of ‘url’ or ‘b64_json’. |
Clarity Upscale
Enhances a given raster image using ‘clarity upscale’ tool, increasing image resolution, making the image sharper and cleaner.
POST https://external.api.recraft.ai/v1/images/clarityUpscale
Example
response = client.post(
path='/images/clarityUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
Output
https://img.recraft.ai/LtCo_bs3chC8zhrku0CWLpCBKv4iOODprEdeD_MY1dw
/rs:fit:1760:2348:0/raw:1/plain/abs://external/images/f7d01b15-0eba-4439-a5fb-38af38fb524e
Request Body
Body of a request should be a file in PNG format and parameters passed as content type multipart/form-data
.
Parameter | Type | Description |
---|---|---|
response_format | string or null, default is url | The format in which the generated images are returned. Must be one of `url` or `b64_json`. |
Generative Upscale
Enhances a given raster image using ‘generative upscale’ tool, boosting resolution with a focus on refining small details and faces.
POST https://external.api.recraft.ai/v1/images/generativeUpscale
Example
response = client.post(
path='/images/generativeUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
Output
https://img.recraft.ai/DV4d9pMeq5lIluqS7m8qHyg-mb6hf5uCqEPPC8t8wy4
/rs:fit:4740:3536:0/raw:1/plain/abs://external/images/fb576169-8a66-4270-a566-35713ad72020
Request Body
Body of a request should be a file in PNG format and parameters passed as content type multipart/form-data
.
Parameter | Type | Description |
---|---|---|
response_format | string or null, default is url | The format in which the generated images are returned. Must be one of `url` or `b64_json`. |
Create style
Upload a set of images to create a style reference.
POST https://external.api.recraft.ai/v1/styles
Example
response = client.post(
path='/styles',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'style': 'digital_illustration'},
files={'file1': open('image.png', 'rb')},
)
print(response['id'])
Output
{"id": "229b2a75-05e4-4580-85f9-b47ee521a00d"}
Request Body
Upload a set of images to create a style reference.
Parameter | Type | Description |
---|---|---|
style (required) | string | The base style of the generated images, this topic is covered above. |
files (required) | files | Images in PNG format for using as style references. The max number of the images is 5. |
Auxiliary
Controls
The generation process can be adjusted with a number of tweaks.
colors (required) | An array of preferable colors |
background_color | Use given color as a desired background color |
Colors
Color type is defined as an object with the following fields
rgb (required) | An array of 3 integer values in range of 0…255 defining RGB Color Model |
Example
response = client.images.generate(
prompt='race car on a track',
style='realistic_image',
extra_body={
'controls': {
'image_type': 'realistic_image',
'colors': [
{'rgb': [0, 255, 0]}
]
}
}
)
print(response.data[0].url)
Appendix
List of styles
Style | RecraftV3 Substyles (NEW MODEL) | Recraft20B Substyles |
---|---|---|
any | (not applicable) | (not available) |
realistic_image | – b_and_w – enterprise – evening_light – faded_nostalgia – forest_life – hard_flash – hdr – motion_blur – mystic_naturalism – natural_light – natural_tones – organic_calm – real_life_glow – retro_realism – retro_snapshot – studio_portrait – urban_drama – village_realism – warm_folk | – b_and_w – enterprise – hard_flash – hdr – motion_blur – natural_light – studio_portrait |
digital_illustration | – 2d_art_poster – 2d_art_poster_2 – engraving_color – grain – hand_drawn – hand_drawn_outline – handmade_3d – infantile_sketch – pixel_art – antiquarian – bold_fantasy – child_book – child_books – cover – crosshatch – digital_engraving – expressionism – freehand_details – grain_20 – graphic_intensity – hard_comics – long_shadow – modern_folk – multicolor – neon_calm – noir – nostalgic_pastel – outline_details – pastel_gradient – pastel_sketch – pop_art – pop_renaissance – street_art – tablet_sketch – urban_glow – urban_sketching – vanilla_dreams – young_adult_book – young_adult_book_2 | – 2d_art_poster – 2d_art_poster_2 – 3d – 80s – engraving_color – glow – grain – hand_drawn – hand_drawn_outline – handmade_3d – infantile_sketch – kawaii – pixel_art – psychedelic – seamless – voxel – watercolor |
vector_illustration | – bold_stroke – chemistry – colored_stencil – contour_pop_art – cosmics – cutout – depressive – editorial – emotional_flat – engraving – infographical – line_art – line_circuit – linocut – marker_outline – mosaic – naivector – roundish_flat – segmented_colors – sharp_contrast – thin – vector_photo – vivid_shapes | – cartoon – doodle_line_art – engraving – flat_2 – kawaii – line_art – line_circuit – linocut – seamless |
icon | (not available) | – broken_line – colored_outline – colored_shapes – colored_shapes_gradient – doodle_fill – doodle_offset_fill – offset_fill – outline – outline_gradient – uneven_fill |
List of image sizes
- – 1024×1024
- – 1365×1024
- – 1024×1365
- – 1536×1024
- – 1024×1536
- – 1820×1024
- – 1024×1820
- – 1024×2048
- – 2048×1024
- – 1434×1024
- – 1024×1434
- – 1024×1280
- – 1280×1024
- – 1024×1707
- – 1707×1024
Policies
- All generated images are currently stored indefinitely. However, this policy may change in the future, and you should not rely on it remaining constant.
- Images are publicly accessible via direct links without authentication. However, since the URLs include unique image identifiers and are cryptographically signed, restoring lost links is nearly impossible.
- Currently, image generation rates are defined on a per-user basis and set at 100 images per minute. These rates may be adjusted in the future.