Skip to content

Instantly share code, notes, and snippets.

@sandalsoft
Created May 20, 2025 10:16
Show Gist options
  • Save sandalsoft/a6e7a483935626a1f2c4f2ebdd13ef03 to your computer and use it in GitHub Desktop.
Save sandalsoft/a6e7a483935626a1f2c4f2ebdd13ef03 to your computer and use it in GitHub Desktop.
# https://www.recraft.ai/docs#vectorize-image llms-full.txt
## Vectorize Image Guide
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66f2c145708321e532690bc1_%5BLogo%20sign%5D.png)](https://www.recraft.ai/)
Features
Use Cases
[Gallery](https://app.recraft.ai/community)
Resources
[API](https://www.recraft.ai/docs)
[Pricing](https://app.recraft.ai/pricing)
[Log in](https://app.recraft.ai/auth/login) [Get Recraft free](https://app.recraft.ai/auth/login)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66f2c145708321e532690bc1_%5BLogo%20sign%5D.png)](https://www.recraft.ai/)
Features
Use Cases
[Gallery](https://app.recraft.ai/community)
Resources
[API](https://www.recraft.ai/docs)
[Pricing](https://app.recraft.ai/pricing)
[Log in](https://app.recraft.ai/auth/login) [Get Recraft free](https://app.recraft.ai/auth/login)
[Gallery](https://app.recraft.ai/community) [Log in](https://app.recraft.ai/projects) [Get Recraft Free](https://app.recraft.ai/projects)
[Gallery](https://app.recraft.ai/community) [Log in](https://app.recraft.ai/projects) [Get Recraft Free](https://app.recraft.ai/projects)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37cf85ecdf3b051e9c854_icon__start.svg)\\
\\
Overview](https://www.recraft.ai/docs#features) [Features](https://www.recraft.ai/docs#features) [Model](https://www.recraft.ai/docs#models) [Pricing](https://www.recraft.ai/docs#pricing)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66c4759526deb3ec0504ac21_power-off-solid.svg)\\
\\
Getting Started](https://www.recraft.ai/docs#authentication) [Authentication](https://www.recraft.ai/docs#authentication)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a39851bb5245a123e6fc56_code-solid.svg)\\
\\
Usage](https://www.recraft.ai/docs#generate-image) [Generate Image](https://www.recraft.ai/docs#generate-image) [Image To Image](https://www.recraft.ai/docs#image-to-image) [Image Inpainting](https://www.recraft.ai/docs#inpaint-image) [Replace Background](https://www.recraft.ai/docs#replace-bg) [Vectorize Image](https://www.recraft.ai/docs#vectorize-image) [Remove Background](https://www.recraft.ai/docs#remove-background) [Crisp Upscale](https://www.recraft.ai/docs#clarity-upscale) [Creative Upscale](https://www.recraft.ai/docs#creative-upscale) [Create Style](https://www.recraft.ai/docs#create-style) [Get User Information](https://www.recraft.ai/docs#get-user-info) [Auxiliary](https://www.recraft.ai/docs#auxiliary)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3988d826d78276aae2703_book-open-solid.svg)\\
\\
Guides](https://www.recraft.ai/docs#generate-a-digital-illustration) [Generate a digital illustration](https://www.recraft.ai/docs#generate-a-digital-illustration) [Generate a realistic image with specific size](https://www.recraft.ai/docs#generate-a-realistic-image-with-specific-size) [Generate a digital illustration with specific substyle](https://www.recraft.ai/docs#generate-a-digital-illustration-with-specific-substyle) [Image To Image with digital illustration style](https://www.recraft.ai/docs#image-to-image-example) [Inpaint an image with digital illustration style](https://www.recraft.ai/docs#inpaint-digital-illustration) [Create own style by uploading reference images and use them for generation](https://www.recraft.ai/docs#create-own-style-by-uploading-reference-images-and-use-them-for-generation) [Vectorize an Image in PNG format](https://www.recraft.ai/docs#vectorize-an-image-in-png-format) [Remove Background From a PNG Image, Get the Result in B64 JSON](https://www.recraft.ai/docs#remove-background-from-a-png-image-get-the-result-in-b64-json) [Run Crisp Upscale Tool for a PNG Image, Get the Result in B64 JSON](https://www.recraft.ai/docs#Run-Clarity-Upscale-Tool-for-a-PNG-Image-Get-the-Result-in-B64-JSON) [Run Creative Upscale Tool for a PNG Image](https://www.recraft.ai/docs#Run-Creative-Upscale-Tool-for-a-PNG-Image)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66b22c85a4aa331645817b45_asterisk-solid.svg)\\
\\
Appendix](https://www.recraft.ai/docs#list-of-styles) [List of styles](https://www.recraft.ai/docs#list-of-styles) [List of image sizes](https://www.recraft.ai/docs#list-of-image-sizes) [Policies](https://www.recraft.ai/docs#policies)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66b22dd25521ce373e9d38ef_info-solid.svg)\\
\\
Terms](https://app.recraft.ai/terms) [![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66b22ddfb21f2fc6d9324ca7_swagger-svgrepo-com.svg)\\
\\
Swagger](https://external.api.recraft.ai/doc/) [![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a39716f38dac4cf015607c_discord-brands-solid.svg)\\
\\
Discord](https://discord.gg/recraft) [![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a8f0bbd5c4ceac63f68983_x-twitter-brands-solid.svg)\\
\\
X](https://x.com/recraftai)
# Recraft Image Generation and Editing API
Learn the basics of the Recraft API, including raster and vector image generation, style creation, image generation in your brand style and colors, image vectorization and background removal.
[Log in](https://app.recraft.ai/auth/login) [Contact us](mailto:[email protected])
[![Getting Started](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3976f8c91a648bf89408c_play-solid.svg)\\
\\
Getting Started\\
\\
Authenticate and interact with our API in a matter of minutes.](https://www.recraft.ai/docs#authentication) [![Pricing](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3af2ef47308819f8f99f6_wallet-solid.svg)\\
\\
Pricing\\
\\
Understand our flexible API pricing plans.](https://www.recraft.ai/docs#pricing) [![Usage](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a39851bb5245a123e6fc56_code-solid.svg)\\
\\
Usage\\
\\
Dig into the details of using the Recraft API.](https://www.recraft.ai/docs#generate-image) [![Guides](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3988d826d78276aae2703_book-open-solid.svg)\\
\\
Guides\\
\\
Practical guides for both CLI and Python usage.](https://www.recraft.ai/docs#generate-a-digital-illustration)
## Features
### Styles
A _style_ is a descriptor that defines the visual appearance and feel of generated images. This includes a wide array of elements such as textures and visual effects, shapes and colors, composition and lines, etc. There are four classes of base styles: realistic image, digital illustration, vector illustration and icon.
Realistic
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _realistic_” are expected to look like just ordinary photographs made with a digital camera or a smartphone or a film camera.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b8295b59b980127d7e306_cute-girl-portrait%20(1)%201.png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b828dff13038000193303_a-good-aluminium-suitcase-on-the-floor%201.png)
Digital illustration
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _digital illustration_” are pictures drawn by hand or using computers - virtually everything except photos and vector illustrations. The most crucial difference from “ _realistic images_” is that illustrations possess simplified textures (like in 3D-rendered or manually drawn images) - or they are stylized in a certain creative way. The difference from “ _vector illustration_” is that “ _digital illustrations_” allow for more complex color transitions, shades, fine textures.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b8318c6f6ecaf608531da_unicorn%20(8).png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b82f54ef9617939df9d8e_motorcycle--going-fast.png)
Vector illustration
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _vector illustration”_ are expected to look like those drawn using vector graphics (see [Wikipedia](https://en.wikipedia.org/wiki/Vector_graphics)). Usually, they use only a few different colors at once, shapes are filled with flat colors or simple color gradients. Shapes of objects can be arbitrarily complex.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b82fb365f45ed1a743d43_a-man-working-in-his-workshop--standing-straight-a%20(1)%202.png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b830165533469004467d9_create-a-minimal-character-illustration-of-a-resea.png)
Icon
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _icon_” are small digital images or symbols used in the graphical user interface. They are designed to be simple and recognizable at small sizes, often visually summarizing the action or object they stand for, or they can act as the visual identity for an app or a website and are crucial in branding.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b830d1720fd793595cf40_Group%204291.png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b831e6ee14a2f933f112c_Group%204254.png)
A _style_ can be refined by adding a _substyle_ for more precise definition. [Below](https://www.recraft.ai/docs#nav-list-of-styles), you will find a list of supported _styles_ and corresponding _substyles._ Please note that the available _styles_ and _substyles_ may vary depending on the _model_. Additionally, you have an option to create [your own style](https://www.recraft.ai/docs#vectorize-image) by combining a base _style_ (e.g. realistic image, digital illustration, vector illustration or icon) with a collection of reference images.
### Model
Recraft developed two powerful models: Recraft V2 (also known as Recraft 20B) and Recraft V3.
The Recraft V2 model was released in February 2024 and was the first AI model built specifically for designers. It allowed them to create both vector and raster images that are anatomically perfect, maintain consistent brand style and also iterate with ultimate control and precision.
In October 2024 the new model was introduced - Recraft V3. Our team trained a new SOTA model from scratch and set a new standard for excellence in image generation. Recraft V3 participated in the Hugging Face’s industry-leading Text-to-Image Model Leaderboard by Artificial Analysis. It secured #1 place with ELO rating of 1172.
Now both models are available through the Recraft API.
## Pricing
### API Unit package pricing
The following are the API Unit packages available from Recraft for the use of the Recraft API Service. API Unit packages must be purchased in advance and all API Unit packages are non-cancellable and non-refundable. Any number of unit packages can be bought.
| Price | API Units |
| --- | --- |
| US $1.00 | 1,000 |
### 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.
| Service Description | Cost (USD) | API Units Charged |
| --- | --- | --- |
| Raster Image Generation Per One Image | Recraft V3 - $0.04<br> Recraft V2 - $0.022 | Recraft V3 - 40<br> Recraft V2 - 22 |
| Vector Image Generation Per One Image | Recraft V3 - $0.08<br> Recraft V2 - $0.044 | Recraft V3 - 80<br> Recraft V2 - 44 |
| Raster Image To Image Per One Image | $0.04 | 40 |
| Vector Image To Image Per One Image | $0.08 | 80 |
| Raster Image Inpainting Per One Image | $0.04 | 40 |
| Vector Image Inpainting Per One Image | $0.08 | 80 |
| Replace Raster Background Per One Image | $0.04 | 40 |
| Replace Vector Background Per One Image | $0.08 | 80 |
| Image Style Creation | $0.04 | 40 |
| Image Vectorization | $0.01 | 10 |
| Image Background Removal | $0.01 | 10 |
| Crisp Upscale | $0.004 | 4 |
| Creative Upscale | $0.25 | 250 |
| Erase Region | $0.002 | 2 |
# Getting Started
Authenticate and interact with our API in a matter of minutes.
## Authentication
We use [Bearer](https://swagger.io/docs/specification/authentication/bearer-authentication/) API tokens for authentication. To access your API key, log in to Recraft, [enter your profile](https://app.recraft.ai/profile/api) and hit 'Generate' (available only if your API units balance is above zero). All requests should include your API key in an Authorization HTTP header as follows:
‍ `Authorization: Bearer RECRAFT_API_TOKEN`
### REST / Python Library
The Recraft API adheres to REST principles, allowing you to interact using any utilities (e.g., curl), programming languages, or libraries of your choice.
One of the easiest of available alternatives is [OpenAI Python library](https://github.com/openai/openai-python) which is also compatible with Recraft API, but it’s important to remember that not all parameters/options are supported or implemented. Additionally, some parameters may have different meanings, or they may be quietly ignored if they are not applicable to the Recraft API.
Future examples will be shown using that library, for example, once installed, you can use the following code to be authenticated:
```python
from openai import OpenAI
client = OpenAI(
base_url='https://external.api.recraft.ai/v1',
api_key=<TOKEN>,
)
```
# Usage
Dig into the details of using the Recraft API.
### Generate Image
Creates an image given a prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/generations
```
#### Example
```python
response = client.images.generate(
prompt='race car on a track',
style='digital_illustration',
)
print(response.data[0].url)
```
#### Output
```bash
https://img.recraft.ai/-dSeKnnWTUbG9wnzpV6OjN7I7PlFxAFmg6nyhvd3qSE/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/cbb1770e-3e7e-49fd-bf17-7c689f6906c1
```
#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| prompt (required) | string | A text description of the desired image(s). The maximum length is 1000 bytes |
| text\_layout | Array of objects or null | Available in `recraftv3` model only. This topic is covered below |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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 `recraftv2` |
| 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 |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
| 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:
```python
response = client.images.generate(
prompt='race car on a track',
extra_body={
'style_id': style_id,
'controls': {
...
}
}
)
print(response.data[0].url)
```
### Image To Image
Image-to-image operation transforms an input image into an output image, preserving certain aspects while altering others based on the prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/imageToImage
```
#### Example
```python
response = client.post(
path='/images/imageToImage',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
},
body={
'prompt': 'winter',
'strength': 0.2,
},
)
print(response['data'][0]['url'])
```
#### Output
```python
https://img.recraft.ai/f1LAVICjQjTDUbVlwlA4AbE_JBjEQU2t6ho6YhI0J8M/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/6d85db5d-912f-4711-957c-15cbebc8cb24
```
#### Parameters
Body of a request should contains an image file in PNG, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| Parameter | Type | Description |
| --- | --- | --- |
| image (required) | file | An image to modify, must be less than 5 MB in size, have resolution less than 16 MP and max dimension less than 4096 pixels. |
| prompt (required) | string | A text description of areas to change. The maximum length is 1000 bytes |
| strength (required) | float | Defines the difference with the original image, should lie in \[0, 1\], where 0 means almost identical, and 1 means miserable similarity |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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. Only `recraftv3` is supported at the moment |
| 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` |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
| 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 " `any"` will be used
### Image Inpainting
Inpainting replaces or modifies specific parts of an image. It uses a mask to identify the areas to be filled in, where white pixels represent the regions to inpaint, and black pixels indicate the areas to keep intact, i.e. the white pixels are filled based on the input provided in the prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/inpaint
```
#### Example
```python
response = client.post(
path='/images/inpaint',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
'mask': open('mask.png', 'rb'),
},
body={
'prompt': 'winter',
},
)
print(response['data'][0]['url'])
```
#### Output
```bash
https://img.recraft.ai/HMd15RTSXeRfEluSPq828pZ7DW9NaI4oR2adSVk_wXc/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/a97b9cc2-4498-41d8-9904-1d58e04b239b
```
#### Parameters
Body of a request should contains an image file and a mask in PNG, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| Parameter | Type | Description |
| --- | --- | --- |
| image (required) | file | An image to modify, must be less than 5 MB in size, have resolution less than 16 MP and max dimension less than 4096 pixels. |
| mask (required) | file | An image encoded in **grayscale color mode**, used to define the specific regions of an image that need modification. The white pixels represent the parts of the image that will be inpainted while black pixels indicate the parts of the image that will remain unchanged. Should have exactly the same size as the image. Each pixel of the image should be either pure black (value 0) or pure white (value 255). |
| prompt (required) | string | A text description of areas to change. The maximum length is 1000 bytes |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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. Only `recraftv3` is supported at the moment |
| 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` |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
**Note**: `style_id` and `style` parameters are mutually exclusive. If neither of the two parameters is specified, the default style of " `any"` will be used
### Replace Background
Replace Background operation detects background of an image and modifies it according to given prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/replaceBackground
```
#### Example
```python
response = client.post(
path='/images/replaceBackground',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
},
body={
'prompt': 'winter',
},
)
print(response['data'][0]['url'])
```
#### Output
```python
https://img.recraft.ai/59eRxsKN87Tr-LLFleTm01RZSsSTuoZcHTzT9b1r_XM/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/234453e8-6abf-472f-9ac7-9b8c7eca2f80
```
#### Parameters
Body of a request should contains an image file in PNG, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| Parameter | Type | Description |
| --- | --- | --- |
| image (required) | file | An image to modify, must be less than 5 MB in size, have resolution less than 16 MP and max dimension less than 4096 pixels. |
| prompt (required) | string | A text description of areas to change. The maximum length is 1000 bytes |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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. Only `recraftv3` is supported at the moment |
| 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` |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
**Note**: `style_id` and `style` parameters are mutually exclusive. If neither of the two parameters is specified, the default style of " `any"` will be used
### Vectorize Image
Converts a given raster image to SVG format.
```javascript
POST https://external.api.recraft.ai/v1/images/vectorize
```
#### Example
```javascript
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
```bash
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, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| 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.
```javascript
POST https://external.api.recraft.ai/v1/images/removeBackground
```
#### Example
```javascript
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
```bash
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, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| 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'. |
### Crisp Upscale
Enhances a given raster image using ‘crisp upscale’ tool, increasing image resolution, making the image sharper and cleaner.
```javascript
POST https://external.api.recraft.ai/v1/images/crispUpscale
```
#### Example
```javascript
response = client.post(
path='/images/crispUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
#### Output
```bash
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, JPG or WEBP format and parameters passed as content type `multipart/form-data`. The image must be no more than 5 MB in size, have resolution no more than 4 MP, max dimension no more than 4096 pixels and min dimension no less than 32 pixels.
| 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\`. |
### Creative Upscale
Enhances a given raster image using ‘creative upscale’ tool, boosting resolution with a focus on refining small details and faces.
```javascript
POST https://external.api.recraft.ai/v1/images/creativeUpscale
```
#### Example
```javascript
response = client.post(
path='/images/creativeUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
#### Output
```bash
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, JPG or WEBP format and parameters passed as content type `multipart/form-data`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| 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.
```javascript
POST https://external.api.recraft.ai/v1/styles
```
#### Example
```python
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
```javascript
{"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, JPG or WEBP format for using as style references. The max number of the images is 5. Total size of all images is limited to 5MB. |
### Get User Information
Returns information of the current user including credits balance.
```javascript
GET https://external.api.recraft.ai/v1/users/me
```
#### Example
```python
response = client.get(path='/users/me', cast_to=object)
print(response)
```
#### Output
```javascript
{
"credits": 1000,
"email": "[email protected]",
"id": "c18a1988-45e7-4c00-82c4-4ad7d3dbce3a",
"name": "Recraft Test"
}
```
### Auxiliary
#### Controls
The generation process can be adjusted with a number of tweaks.
| | | |
| --- | --- | --- |
| artistic\_level | integer or null | Defines artistic tone of your image. At a simple level, the person looks straight at the camera in a static and clean style. Dynamic and eccentric levels introduce movement and creativity.<br> The value should be in range \[0..5\]. |
| colors | array of color definitions | An array of preferable colors |
| background\_color | color definition | Use given color as a desired background color |
| no\_text | bool | Do not embed text layouts |
#### **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**
```python
response = client.images.generate(
prompt='race car on a track',
style='realistic_image',
extra_body={
'controls': {
'colors': [\
{'rgb': [0, 255, 0]}\
]
}
}
)
print(response.data[0].url)
```
#### Text Layout
Text layout is used to define spatial and textual attributes for individual text elements. Each text element consists of an individual word and its bounding box (bbox).
| | |
| --- | --- |
| text (required) | A single word containing only supported characters. |
| bbox (required) | A bounding box representing a 4-angled polygon. Each point in the polygon is defined by relative coordinates. |
**Bounding Box**:The bounding box (bbox) is a list of 4 points representing a 4-angled figure (not necessarily a rectangle). Each point specifies its coordinates relative to the layout dimensions, where (0, 0) is the top-left corner, (1, 1) is the bottom-right corner. **Coordinates**: Coordinates are **relative** to the layout dimensions. Coordinates can extend beyond the \[0, 1\] range, such values indicate that the shape will be cropped.
‍ **Points**: The bounding box must always have **exactly 4 points**. Each point is an array of two floats \[x, y\] representing the relative position.
**Supported Characters:** The text field must contain an individual word composed of the following supported characters: '!', '"', '#', '$', '%', '&', '\\'', '(', ')', '\*', '+', ',', '-', '.', '/','0', '1', '2', '3', '4', '5', '6', '7', '8', '9',':', '<', '>', '?', '@','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','\_', '{', '}', 'Ø', 'Đ', 'Ħ', 'Ł', 'Ŋ', 'Ŧ', 'Α', 'Β', 'Ε', 'Ζ', 'Η', 'Ι', 'Κ', 'Μ', 'Ν', 'Ο', 'Ρ', 'Τ','Υ', 'Χ', 'І', 'А', 'В', 'Е', 'К', 'М', 'Н', 'О', 'Р', 'С', 'Т', 'У', 'Х','ß', 'ẞ'.
Any character not listed above will result in validation errors.
##### **Example**
```python
response = client.images.generate(
prompt="cute red panda with a sign",
style="digital_illustration",
extra_body={
"text_layout": [\
{\
"text": "Recraft",\
"bbox": [[0.3, 0.45], [0.6, 0.45], [0.6, 0.55], [0.3, 0.55]],\
},\
{\
"text": "AI",\
"bbox": [[0.62, 0.45], [0.70, 0.45], [0.70, 0.55], [0.62, 0.55]],\
},\
]
},
)
print(response.data[0].url)
```
# Guides
Generate AI images using cURL or Python and create your own styles programmatically.
### Generate a Digital Illustration Using RecraftV3 Model
[Curl](https://www.recraft.ai/docs#w-tabs-0-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-0-data-w-pane-1)
```bash
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "two race cars on a track",
"style": "digital_illustration",
"model": "recraftv3"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.images.generate(
prompt='two race cars on a track',
style='digital_illustration',
model='recraftv3',
)
print(response.data[0].url)
```
### Generate a Realistic Image with Specific Size
[Curl](https://www.recraft.ai/docs#w-tabs-1-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-1-data-w-pane-1)
```bash
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "red point siamese cat",
"style": "realistic_image",
"size": "1280x1024"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.images.generate(
prompt='red point siamese cat',
style='realistic_image',
size='1280x1024',
)
print(response.data[0].url)
```
### Generate a Digital Illustration with Specific Substyle
[Curl](https://www.recraft.ai/docs#w-tabs-2-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-2-data-w-pane-1)
```bash
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "a monster with lots of hands",
"style": "digital_illustration",
"substyle": "hand_drawn"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.images.generate(
prompt='a monster with lots of hands',
style='digital_illustration',
extra_body={'substyle': 'hand_drawn'},
)
print(response.data[0].url)
```
### Image To Image With Digital Illustration Style
[Curl](https://www.recraft.ai/docs#w-tabs-3-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-3-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/imageToImage \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "[email protected]" \
-F "prompt=winter" \
-F "strength=0.2" \
-F "style=digital_illustration"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.post(
path='/images/imageToImage',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
},
body={
'prompt': 'winter',
'strength': 0.2,
'style': 'digital_illustration',
},
)
print(response['data'][0]['url'])
```
### Inpaint an Image with Digital Illustration Style
[Curl](https://www.recraft.ai/docs#w-tabs-4-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-4-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/inpaint \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "prompt=moon" \
-F "style=digital_illustration" \
-F "[email protected]" -F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.post(
path='/images/inpaint',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
'mask': open('mask.png', 'rb'),
},
body={
'style': 'digital_illustration',
'prompt': 'moon',
},
)
print(response['data'][0]['url'])
```
### Create Own Style by Uploading Reference Images and Use Them for Generation
[Curl](https://www.recraft.ai/docs#w-tabs-5-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-5-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/styles \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "style=digital_illustration" \
-F "[email protected]"
# response: {"id":"095b9f9d-f06f-4b4e-9bb2-d4f823203427"}
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "wood potato masher",
"style_id": "095b9f9d-f06f-4b4e-9bb2-d4f823203427"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/styles',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'style': 'digital_illustration'},
files={'file': open('image.png', 'rb')},
)
print(style['id'])
response = client.images.generate(
prompt='wood potato masher',
extra_body={'style_id': style['id']},
)
print(response.data[0].url)
```
### Vectorize an Image in PNG format
[Curl](https://www.recraft.ai/docs#w-tabs-6-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-6-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/vectorize \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
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'])
```
### Remove Background From a PNG Image, Get the Result in B64 JSON
[Curl](https://www.recraft.ai/docs#w-tabs-7-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-7-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/removeBackground \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "response_format=b64_json" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/images/removeBackground',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'response_format': 'b64_json'},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
### Run Crisp Upscale Tool for a PNG Image, Get the Result in B64 JSON
[Curl](https://www.recraft.ai/docs#w-tabs-8-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-8-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/crispUpscale \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "response_format=b64_json" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/images/crispUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'response_format': 'b64_json'},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
### Run Creative Upscale Tool for a PNG Image
[Curl](https://www.recraft.ai/docs#w-tabs-9-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-9-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/creativeUpscale \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/images/creativeUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
## Appendix
### List of styles
| Style | Recraft V3 Substyles | Recraft V2 Substyles |
| --- | --- | --- |
| any | (not applicable) | (not available) |
| realistic\_image | \- b\_and\_w<br> \- enterprise<br> \- evening\_light<br> \- faded\_nostalgia<br> \- forest\_life<br> \- hard\_flash<br> \- hdr<br> \- motion\_blur<br> \- mystic\_naturalism<br> \- natural\_light<br> \- natural\_tones<br> \- organic\_calm<br> \- real\_life\_glow<br> \- retro\_realism<br> \- retro\_snapshot<br> \- studio\_portrait<br> \- urban\_drama<br> \- village\_realism<br> \- warm\_folk | \- b\_and\_w<br> \- enterprise<br> \- hard\_flash<br> \- hdr<br> \- motion\_blur<br> \- natural\_light<br> \- studio\_portrait |
| digital\_illustration | \- 2d\_art\_poster<br> \- 2d\_art\_poster\_2<br> \- antiquarian<br> \- bold\_fantasy<br> \- child\_book<br> \- child\_books<br> \- cover<br> \- crosshatch<br> \- digital\_engraving<br> \- engraving\_color<br> \- expressionism<br> \- freehand\_details<br> \- grain<br> \- grain\_20<br> \- graphic\_intensity<br> \- hand\_drawn<br> \- hand\_drawn\_outline<br> \- handmade\_3d<br> \- hard\_comics<br> \- infantile\_sketch<br> \- long\_shadow<br> \- modern\_folk<br> \- multicolor<br> \- neon\_calm<br> \- noir<br> \- nostalgic\_pastel<br> \- outline\_details<br> \- pastel\_gradient<br> \- pastel\_sketch<br> \- pixel\_art<br> \- plastic<br> \- pop\_art<br> \- pop\_renaissance<br> \- seamless<br> \- street\_art<br> \- tablet\_sketch<br> \- urban\_glow<br> \- urban\_sketching<br> \- vanilla\_dreams<br> \- young\_adult\_book<br> \- young\_adult\_book\_2 | \- 2d\_art\_poster<br> \- 2d\_art\_poster\_2<br> \- 3d<br> \- 80s<br> \- engraving\_color<br> \- glow<br> \- grain<br> \- hand\_drawn<br> \- hand\_drawn\_outline<br> \- handmade\_3d<br> \- infantile\_sketch<br> \- kawaii<br> \- pixel\_art<br> \- plastic<br> \- psychedelic<br> \- seamless<br> \- voxel<br> \- watercolor |
| vector\_illustration | \- bold\_stroke<br> \- chemistry<br> \- colored\_stencil<br> \- contour\_pop\_art<br> \- cosmics<br> \- cutout<br> \- depressive<br> \- editorial<br> \- emotional\_flat<br> \- engraving<br> \- infographical<br> \- line\_art<br> \- line\_circuit<br> \- linocut<br> \- marker\_outline<br> \- mosaic<br> \- naivector<br> \- roundish\_flat<br> \- seamless<br> \- segmented\_colors<br> \- sharp\_contrast<br> \- thin<br> \- vector\_photo<br> \- vivid\_shapes | \- cartoon<br> \- doodle\_line\_art<br> \- engraving<br> \- flat\_2<br> \- kawaii<br> \- line\_art<br> \- line\_circuit<br> \- linocut<br> \- seamless |
| icon | (not available) | \- broken\_line<br> \- colored\_outline<br> \- colored\_shapes<br> \- colored\_shapes\_gradient<br> \- doodle\_fill<br> \- doodle\_offset\_fill<br> \- offset\_fill<br> \- outline<br> \- outline\_gradient<br> \- uneven\_fill |
| logo\_raster | \- emblem\_graffiti<br> \- emblem\_pop\_art<br> \- emblem\_punk<br> \- emblem\_stamp<br> \- emblem\_vintage | (not available) |
### List of image sizes
\- 1024x1024
\- 1365x1024
\- 1024x1365
\- 1536x1024
\- 1024x1536
\- 1820x1024
\- 1024x1820
\- 1024x2048
\- 2048x1024
\- 1434x1024
\- 1024x1434
\- 1024x1280
\- 1280x1024
\- 1024x1707
\- 1707x1024
### Policies
- All generated images are currently stored for approx. 24 hours, 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.
![Close Modal](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37f9778f431a823bfc15b_icon__x.svg)
## Recraft Image API
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66f2c145708321e532690bc1_%5BLogo%20sign%5D.png)](https://www.recraft.ai/)
Features
Use Cases
[Gallery](https://app.recraft.ai/community)
Resources
[API](https://www.recraft.ai/docs)
[Pricing](https://app.recraft.ai/pricing)
[Log in](https://app.recraft.ai/auth/login) [Get Recraft free](https://app.recraft.ai/auth/login)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66f2c145708321e532690bc1_%5BLogo%20sign%5D.png)](https://www.recraft.ai/)
Features
Use Cases
[Gallery](https://app.recraft.ai/community)
Resources
[API](https://www.recraft.ai/docs)
[Pricing](https://app.recraft.ai/pricing)
[Log in](https://app.recraft.ai/auth/login) [Get Recraft free](https://app.recraft.ai/auth/login)
[Gallery](https://app.recraft.ai/community) [Log in](https://app.recraft.ai/projects) [Get Recraft Free](https://app.recraft.ai/projects)
[Gallery](https://app.recraft.ai/community) [Log in](https://app.recraft.ai/projects) [Get Recraft Free](https://app.recraft.ai/projects)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37cf85ecdf3b051e9c854_icon__start.svg)\\
\\
Overview](https://www.recraft.ai/docs#features) [Features](https://www.recraft.ai/docs#features) [Model](https://www.recraft.ai/docs#models) [Pricing](https://www.recraft.ai/docs#pricing)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66c4759526deb3ec0504ac21_power-off-solid.svg)\\
\\
Getting Started](https://www.recraft.ai/docs#authentication) [Authentication](https://www.recraft.ai/docs#authentication)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a39851bb5245a123e6fc56_code-solid.svg)\\
\\
Usage](https://www.recraft.ai/docs#generate-image) [Generate Image](https://www.recraft.ai/docs#generate-image) [Image To Image](https://www.recraft.ai/docs#image-to-image) [Image Inpainting](https://www.recraft.ai/docs#inpaint-image) [Replace Background](https://www.recraft.ai/docs#replace-bg) [Vectorize Image](https://www.recraft.ai/docs#vectorize-image) [Remove Background](https://www.recraft.ai/docs#remove-background) [Crisp Upscale](https://www.recraft.ai/docs#clarity-upscale) [Creative Upscale](https://www.recraft.ai/docs#creative-upscale) [Create Style](https://www.recraft.ai/docs#create-style) [Get User Information](https://www.recraft.ai/docs#get-user-info) [Auxiliary](https://www.recraft.ai/docs#auxiliary)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3988d826d78276aae2703_book-open-solid.svg)\\
\\
Guides](https://www.recraft.ai/docs#generate-a-digital-illustration) [Generate a digital illustration](https://www.recraft.ai/docs#generate-a-digital-illustration) [Generate a realistic image with specific size](https://www.recraft.ai/docs#generate-a-realistic-image-with-specific-size) [Generate a digital illustration with specific substyle](https://www.recraft.ai/docs#generate-a-digital-illustration-with-specific-substyle) [Image To Image with digital illustration style](https://www.recraft.ai/docs#image-to-image-example) [Inpaint an image with digital illustration style](https://www.recraft.ai/docs#inpaint-digital-illustration) [Create own style by uploading reference images and use them for generation](https://www.recraft.ai/docs#create-own-style-by-uploading-reference-images-and-use-them-for-generation) [Vectorize an Image in PNG format](https://www.recraft.ai/docs#vectorize-an-image-in-png-format) [Remove Background From a PNG Image, Get the Result in B64 JSON](https://www.recraft.ai/docs#remove-background-from-a-png-image-get-the-result-in-b64-json) [Run Crisp Upscale Tool for a PNG Image, Get the Result in B64 JSON](https://www.recraft.ai/docs#Run-Clarity-Upscale-Tool-for-a-PNG-Image-Get-the-Result-in-B64-JSON) [Run Creative Upscale Tool for a PNG Image](https://www.recraft.ai/docs#Run-Creative-Upscale-Tool-for-a-PNG-Image)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66b22c85a4aa331645817b45_asterisk-solid.svg)\\
\\
Appendix](https://www.recraft.ai/docs#list-of-styles) [List of styles](https://www.recraft.ai/docs#list-of-styles) [List of image sizes](https://www.recraft.ai/docs#list-of-image-sizes) [Policies](https://www.recraft.ai/docs#policies)
[![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66b22dd25521ce373e9d38ef_info-solid.svg)\\
\\
Terms](https://app.recraft.ai/terms) [![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66b22ddfb21f2fc6d9324ca7_swagger-svgrepo-com.svg)\\
\\
Swagger](https://external.api.recraft.ai/doc/) [![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a39716f38dac4cf015607c_discord-brands-solid.svg)\\
\\
Discord](https://discord.gg/recraft) [![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a8f0bbd5c4ceac63f68983_x-twitter-brands-solid.svg)\\
\\
X](https://x.com/recraftai)
# Recraft Image Generation and Editing API
Learn the basics of the Recraft API, including raster and vector image generation, style creation, image generation in your brand style and colors, image vectorization and background removal.
[Log in](https://app.recraft.ai/auth/login) [Contact us](mailto:[email protected])
[![Getting Started](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3976f8c91a648bf89408c_play-solid.svg)\\
\\
Getting Started\\
\\
Authenticate and interact with our API in a matter of minutes.](https://www.recraft.ai/docs#authentication) [![Pricing](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3af2ef47308819f8f99f6_wallet-solid.svg)\\
\\
Pricing\\
\\
Understand our flexible API pricing plans.](https://www.recraft.ai/docs#pricing) [![Usage](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a39851bb5245a123e6fc56_code-solid.svg)\\
\\
Usage\\
\\
Dig into the details of using the Recraft API.](https://www.recraft.ai/docs#generate-image) [![Guides](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a3988d826d78276aae2703_book-open-solid.svg)\\
\\
Guides\\
\\
Practical guides for both CLI and Python usage.](https://www.recraft.ai/docs#generate-a-digital-illustration)
## Features
### Styles
A _style_ is a descriptor that defines the visual appearance and feel of generated images. This includes a wide array of elements such as textures and visual effects, shapes and colors, composition and lines, etc. There are four classes of base styles: realistic image, digital illustration, vector illustration and icon.
Realistic
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _realistic_” are expected to look like just ordinary photographs made with a digital camera or a smartphone or a film camera.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b8295b59b980127d7e306_cute-girl-portrait%20(1)%201.png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b828dff13038000193303_a-good-aluminium-suitcase-on-the-floor%201.png)
Digital illustration
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _digital illustration_” are pictures drawn by hand or using computers - virtually everything except photos and vector illustrations. The most crucial difference from “ _realistic images_” is that illustrations possess simplified textures (like in 3D-rendered or manually drawn images) - or they are stylized in a certain creative way. The difference from “ _vector illustration_” is that “ _digital illustrations_” allow for more complex color transitions, shades, fine textures.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b8318c6f6ecaf608531da_unicorn%20(8).png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b82f54ef9617939df9d8e_motorcycle--going-fast.png)
Vector illustration
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _vector illustration”_ are expected to look like those drawn using vector graphics (see [Wikipedia](https://en.wikipedia.org/wiki/Vector_graphics)). Usually, they use only a few different colors at once, shapes are filled with flat colors or simple color gradients. Shapes of objects can be arbitrarily complex.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b82fb365f45ed1a743d43_a-man-working-in-his-workshop--standing-straight-a%20(1)%202.png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b830165533469004467d9_create-a-minimal-character-illustration-of-a-resea.png)
Icon
![Show More](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37d257a396c8d235ce016_icon__plus.svg)
Images of style “ _icon_” are small digital images or symbols used in the graphical user interface. They are designed to be simple and recognizable at small sizes, often visually summarizing the action or object they stand for, or they can act as the visual identity for an app or a website and are crucial in branding.
![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b830d1720fd793595cf40_Group%204291.png)![](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/679b831e6ee14a2f933f112c_Group%204254.png)
A _style_ can be refined by adding a _substyle_ for more precise definition. [Below](https://www.recraft.ai/docs#nav-list-of-styles), you will find a list of supported _styles_ and corresponding _substyles._ Please note that the available _styles_ and _substyles_ may vary depending on the _model_. Additionally, you have an option to create [your own style](https://www.recraft.ai/docs#vectorize-image) by combining a base _style_ (e.g. realistic image, digital illustration, vector illustration or icon) with a collection of reference images.
### Model
Recraft developed two powerful models: Recraft V2 (also known as Recraft 20B) and Recraft V3.
The Recraft V2 model was released in February 2024 and was the first AI model built specifically for designers. It allowed them to create both vector and raster images that are anatomically perfect, maintain consistent brand style and also iterate with ultimate control and precision.
In October 2024 the new model was introduced - Recraft V3. Our team trained a new SOTA model from scratch and set a new standard for excellence in image generation. Recraft V3 participated in the Hugging Face’s industry-leading Text-to-Image Model Leaderboard by Artificial Analysis. It secured #1 place with ELO rating of 1172.
Now both models are available through the Recraft API.
## Pricing
### API Unit package pricing
The following are the API Unit packages available from Recraft for the use of the Recraft API Service. API Unit packages must be purchased in advance and all API Unit packages are non-cancellable and non-refundable. Any number of unit packages can be bought.
| Price | API Units |
| --- | --- |
| US $1.00 | 1,000 |
### 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.
| Service Description | Cost (USD) | API Units Charged |
| --- | --- | --- |
| Raster Image Generation Per One Image | Recraft V3 - $0.04<br> Recraft V2 - $0.022 | Recraft V3 - 40<br> Recraft V2 - 22 |
| Vector Image Generation Per One Image | Recraft V3 - $0.08<br> Recraft V2 - $0.044 | Recraft V3 - 80<br> Recraft V2 - 44 |
| Raster Image To Image Per One Image | $0.04 | 40 |
| Vector Image To Image Per One Image | $0.08 | 80 |
| Raster Image Inpainting Per One Image | $0.04 | 40 |
| Vector Image Inpainting Per One Image | $0.08 | 80 |
| Replace Raster Background Per One Image | $0.04 | 40 |
| Replace Vector Background Per One Image | $0.08 | 80 |
| Image Style Creation | $0.04 | 40 |
| Image Vectorization | $0.01 | 10 |
| Image Background Removal | $0.01 | 10 |
| Crisp Upscale | $0.004 | 4 |
| Creative Upscale | $0.25 | 250 |
| Erase Region | $0.002 | 2 |
# Getting Started
Authenticate and interact with our API in a matter of minutes.
## Authentication
We use [Bearer](https://swagger.io/docs/specification/authentication/bearer-authentication/) API tokens for authentication. To access your API key, log in to Recraft, [enter your profile](https://app.recraft.ai/profile/api) and hit 'Generate' (available only if your API units balance is above zero). All requests should include your API key in an Authorization HTTP header as follows:
‍ `Authorization: Bearer RECRAFT_API_TOKEN`
### REST / Python Library
The Recraft API adheres to REST principles, allowing you to interact using any utilities (e.g., curl), programming languages, or libraries of your choice.
One of the easiest of available alternatives is [OpenAI Python library](https://github.com/openai/openai-python) which is also compatible with Recraft API, but it’s important to remember that not all parameters/options are supported or implemented. Additionally, some parameters may have different meanings, or they may be quietly ignored if they are not applicable to the Recraft API.
Future examples will be shown using that library, for example, once installed, you can use the following code to be authenticated:
```python
from openai import OpenAI
client = OpenAI(
base_url='https://external.api.recraft.ai/v1',
api_key=<TOKEN>,
)
```
# Usage
Dig into the details of using the Recraft API.
### Generate Image
Creates an image given a prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/generations
```
#### Example
```python
response = client.images.generate(
prompt='race car on a track',
style='digital_illustration',
)
print(response.data[0].url)
```
#### Output
```bash
https://img.recraft.ai/-dSeKnnWTUbG9wnzpV6OjN7I7PlFxAFmg6nyhvd3qSE/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/cbb1770e-3e7e-49fd-bf17-7c689f6906c1
```
#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| prompt (required) | string | A text description of the desired image(s). The maximum length is 1000 bytes |
| text\_layout | Array of objects or null | Available in `recraftv3` model only. This topic is covered below |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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 `recraftv2` |
| 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 |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
| 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:
```python
response = client.images.generate(
prompt='race car on a track',
extra_body={
'style_id': style_id,
'controls': {
...
}
}
)
print(response.data[0].url)
```
### Image To Image
Image-to-image operation transforms an input image into an output image, preserving certain aspects while altering others based on the prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/imageToImage
```
#### Example
```python
response = client.post(
path='/images/imageToImage',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
},
body={
'prompt': 'winter',
'strength': 0.2,
},
)
print(response['data'][0]['url'])
```
#### Output
```python
https://img.recraft.ai/f1LAVICjQjTDUbVlwlA4AbE_JBjEQU2t6ho6YhI0J8M/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/6d85db5d-912f-4711-957c-15cbebc8cb24
```
#### Parameters
Body of a request should contains an image file in PNG, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| Parameter | Type | Description |
| --- | --- | --- |
| image (required) | file | An image to modify, must be less than 5 MB in size, have resolution less than 16 MP and max dimension less than 4096 pixels. |
| prompt (required) | string | A text description of areas to change. The maximum length is 1000 bytes |
| strength (required) | float | Defines the difference with the original image, should lie in \[0, 1\], where 0 means almost identical, and 1 means miserable similarity |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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. Only `recraftv3` is supported at the moment |
| 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` |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
| 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 " `any"` will be used
### Image Inpainting
Inpainting replaces or modifies specific parts of an image. It uses a mask to identify the areas to be filled in, where white pixels represent the regions to inpaint, and black pixels indicate the areas to keep intact, i.e. the white pixels are filled based on the input provided in the prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/inpaint
```
#### Example
```python
response = client.post(
path='/images/inpaint',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
'mask': open('mask.png', 'rb'),
},
body={
'prompt': 'winter',
},
)
print(response['data'][0]['url'])
```
#### Output
```bash
https://img.recraft.ai/HMd15RTSXeRfEluSPq828pZ7DW9NaI4oR2adSVk_wXc/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/a97b9cc2-4498-41d8-9904-1d58e04b239b
```
#### Parameters
Body of a request should contains an image file and a mask in PNG, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| Parameter | Type | Description |
| --- | --- | --- |
| image (required) | file | An image to modify, must be less than 5 MB in size, have resolution less than 16 MP and max dimension less than 4096 pixels. |
| mask (required) | file | An image encoded in **grayscale color mode**, used to define the specific regions of an image that need modification. The white pixels represent the parts of the image that will be inpainted while black pixels indicate the parts of the image that will remain unchanged. Should have exactly the same size as the image. Each pixel of the image should be either pure black (value 0) or pure white (value 255). |
| prompt (required) | string | A text description of areas to change. The maximum length is 1000 bytes |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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. Only `recraftv3` is supported at the moment |
| 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` |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
**Note**: `style_id` and `style` parameters are mutually exclusive. If neither of the two parameters is specified, the default style of " `any"` will be used
### Replace Background
Replace Background operation detects background of an image and modifies it according to given prompt.
```javascript
POST https://external.api.recraft.ai/v1/images/replaceBackground
```
#### Example
```python
response = client.post(
path='/images/replaceBackground',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
},
body={
'prompt': 'winter',
},
)
print(response['data'][0]['url'])
```
#### Output
```python
https://img.recraft.ai/59eRxsKN87Tr-LLFleTm01RZSsSTuoZcHTzT9b1r_XM/rs:fit:1024:1024:0/raw:1/plain/abs://external/images/234453e8-6abf-472f-9ac7-9b8c7eca2f80
```
#### Parameters
Body of a request should contains an image file in PNG, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| Parameter | Type | Description |
| --- | --- | --- |
| image (required) | file | An image to modify, must be less than 5 MB in size, have resolution less than 16 MP and max dimension less than 4096 pixels. |
| prompt (required) | string | A text description of areas to change. The maximum length is 1000 bytes |
| n | integer or null, default is 1 | The number of images to generate, must be between 1 and 6. |
| 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. Only `recraftv3` is supported at the moment |
| 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` |
| negative\_prompt | string or null | A text description of undesired elements on an image. |
**Note**: `style_id` and `style` parameters are mutually exclusive. If neither of the two parameters is specified, the default style of " `any"` will be used
### Vectorize Image
Converts a given raster image to SVG format.
```javascript
POST https://external.api.recraft.ai/v1/images/vectorize
```
#### Example
```javascript
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
```bash
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, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| 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.
```javascript
POST https://external.api.recraft.ai/v1/images/removeBackground
```
#### Example
```javascript
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
```bash
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, JPG or WEBP format and parameters passed as content type `'multipart/form-data'`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| 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'. |
### Crisp Upscale
Enhances a given raster image using ‘crisp upscale’ tool, increasing image resolution, making the image sharper and cleaner.
```javascript
POST https://external.api.recraft.ai/v1/images/crispUpscale
```
#### Example
```javascript
response = client.post(
path='/images/crispUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
#### Output
```bash
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, JPG or WEBP format and parameters passed as content type `multipart/form-data`. The image must be no more than 5 MB in size, have resolution no more than 4 MP, max dimension no more than 4096 pixels and min dimension no less than 32 pixels.
| 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\`. |
### Creative Upscale
Enhances a given raster image using ‘creative upscale’ tool, boosting resolution with a focus on refining small details and faces.
```javascript
POST https://external.api.recraft.ai/v1/images/creativeUpscale
```
#### Example
```javascript
response = client.post(
path='/images/creativeUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
#### Output
```bash
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, JPG or WEBP format and parameters passed as content type `multipart/form-data`. The image must be no more than 5 MB in size, have resolution no more than 16 MP, max dimension no more than 4096 pixels and min dimension no less than 256 pixels.
| 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.
```javascript
POST https://external.api.recraft.ai/v1/styles
```
#### Example
```python
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
```javascript
{"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, JPG or WEBP format for using as style references. The max number of the images is 5. Total size of all images is limited to 5MB. |
### Get User Information
Returns information of the current user including credits balance.
```javascript
GET https://external.api.recraft.ai/v1/users/me
```
#### Example
```python
response = client.get(path='/users/me', cast_to=object)
print(response)
```
#### Output
```javascript
{
"credits": 1000,
"email": "[email protected]",
"id": "c18a1988-45e7-4c00-82c4-4ad7d3dbce3a",
"name": "Recraft Test"
}
```
### Auxiliary
#### Controls
The generation process can be adjusted with a number of tweaks.
| | | |
| --- | --- | --- |
| artistic\_level | integer or null | Defines artistic tone of your image. At a simple level, the person looks straight at the camera in a static and clean style. Dynamic and eccentric levels introduce movement and creativity.<br> The value should be in range \[0..5\]. |
| colors | array of color definitions | An array of preferable colors |
| background\_color | color definition | Use given color as a desired background color |
| no\_text | bool | Do not embed text layouts |
#### **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**
```python
response = client.images.generate(
prompt='race car on a track',
style='realistic_image',
extra_body={
'controls': {
'colors': [\
{'rgb': [0, 255, 0]}\
]
}
}
)
print(response.data[0].url)
```
#### Text Layout
Text layout is used to define spatial and textual attributes for individual text elements. Each text element consists of an individual word and its bounding box (bbox).
| | |
| --- | --- |
| text (required) | A single word containing only supported characters. |
| bbox (required) | A bounding box representing a 4-angled polygon. Each point in the polygon is defined by relative coordinates. |
**Bounding Box**:The bounding box (bbox) is a list of 4 points representing a 4-angled figure (not necessarily a rectangle). Each point specifies its coordinates relative to the layout dimensions, where (0, 0) is the top-left corner, (1, 1) is the bottom-right corner. **Coordinates**: Coordinates are **relative** to the layout dimensions. Coordinates can extend beyond the \[0, 1\] range, such values indicate that the shape will be cropped.
‍ **Points**: The bounding box must always have **exactly 4 points**. Each point is an array of two floats \[x, y\] representing the relative position.
**Supported Characters:** The text field must contain an individual word composed of the following supported characters: '!', '"', '#', '$', '%', '&', '\\'', '(', ')', '\*', '+', ',', '-', '.', '/','0', '1', '2', '3', '4', '5', '6', '7', '8', '9',':', '<', '>', '?', '@','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','\_', '{', '}', 'Ø', 'Đ', 'Ħ', 'Ł', 'Ŋ', 'Ŧ', 'Α', 'Β', 'Ε', 'Ζ', 'Η', 'Ι', 'Κ', 'Μ', 'Ν', 'Ο', 'Ρ', 'Τ','Υ', 'Χ', 'І', 'А', 'В', 'Е', 'К', 'М', 'Н', 'О', 'Р', 'С', 'Т', 'У', 'Х','ß', 'ẞ'.
Any character not listed above will result in validation errors.
##### **Example**
```python
response = client.images.generate(
prompt="cute red panda with a sign",
style="digital_illustration",
extra_body={
"text_layout": [\
{\
"text": "Recraft",\
"bbox": [[0.3, 0.45], [0.6, 0.45], [0.6, 0.55], [0.3, 0.55]],\
},\
{\
"text": "AI",\
"bbox": [[0.62, 0.45], [0.70, 0.45], [0.70, 0.55], [0.62, 0.55]],\
},\
]
},
)
print(response.data[0].url)
```
# Guides
Generate AI images using cURL or Python and create your own styles programmatically.
### Generate a Digital Illustration Using RecraftV3 Model
[Curl](https://www.recraft.ai/docs#w-tabs-0-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-0-data-w-pane-1)
```bash
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "two race cars on a track",
"style": "digital_illustration",
"model": "recraftv3"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.images.generate(
prompt='two race cars on a track',
style='digital_illustration',
model='recraftv3',
)
print(response.data[0].url)
```
### Generate a Realistic Image with Specific Size
[Curl](https://www.recraft.ai/docs#w-tabs-1-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-1-data-w-pane-1)
```bash
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "red point siamese cat",
"style": "realistic_image",
"size": "1280x1024"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.images.generate(
prompt='red point siamese cat',
style='realistic_image',
size='1280x1024',
)
print(response.data[0].url)
```
### Generate a Digital Illustration with Specific Substyle
[Curl](https://www.recraft.ai/docs#w-tabs-2-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-2-data-w-pane-1)
```bash
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "a monster with lots of hands",
"style": "digital_illustration",
"substyle": "hand_drawn"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.images.generate(
prompt='a monster with lots of hands',
style='digital_illustration',
extra_body={'substyle': 'hand_drawn'},
)
print(response.data[0].url)
```
### Image To Image With Digital Illustration Style
[Curl](https://www.recraft.ai/docs#w-tabs-3-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-3-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/imageToImage \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "[email protected]" \
-F "prompt=winter" \
-F "strength=0.2" \
-F "style=digital_illustration"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.post(
path='/images/imageToImage',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
},
body={
'prompt': 'winter',
'strength': 0.2,
'style': 'digital_illustration',
},
)
print(response['data'][0]['url'])
```
### Inpaint an Image with Digital Illustration Style
[Curl](https://www.recraft.ai/docs#w-tabs-4-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-4-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/inpaint \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "prompt=moon" \
-F "style=digital_illustration" \
-F "[email protected]" -F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
response = client.post(
path='/images/inpaint',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open('image.png', 'rb'),
'mask': open('mask.png', 'rb'),
},
body={
'style': 'digital_illustration',
'prompt': 'moon',
},
)
print(response['data'][0]['url'])
```
### Create Own Style by Uploading Reference Images and Use Them for Generation
[Curl](https://www.recraft.ai/docs#w-tabs-5-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-5-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/styles \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "style=digital_illustration" \
-F "[email protected]"
# response: {"id":"095b9f9d-f06f-4b4e-9bb2-d4f823203427"}
curl https://external.api.recraft.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-d '{
"prompt": "wood potato masher",
"style_id": "095b9f9d-f06f-4b4e-9bb2-d4f823203427"
}'
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/styles',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'style': 'digital_illustration'},
files={'file': open('image.png', 'rb')},
)
print(style['id'])
response = client.images.generate(
prompt='wood potato masher',
extra_body={'style_id': style['id']},
)
print(response.data[0].url)
```
### Vectorize an Image in PNG format
[Curl](https://www.recraft.ai/docs#w-tabs-6-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-6-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/vectorize \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
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'])
```
### Remove Background From a PNG Image, Get the Result in B64 JSON
[Curl](https://www.recraft.ai/docs#w-tabs-7-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-7-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/removeBackground \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "response_format=b64_json" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/images/removeBackground',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'response_format': 'b64_json'},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
### Run Crisp Upscale Tool for a PNG Image, Get the Result in B64 JSON
[Curl](https://www.recraft.ai/docs#w-tabs-8-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-8-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/crispUpscale \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "response_format=b64_json" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/images/crispUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
body={'response_format': 'b64_json'},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
### Run Creative Upscale Tool for a PNG Image
[Curl](https://www.recraft.ai/docs#w-tabs-9-data-w-pane-0) [Python](https://www.recraft.ai/docs#w-tabs-9-data-w-pane-1)
```bash
curl -X POST https://external.api.recraft.ai/v1/images/creativeUpscale \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $RECRAFT_API_TOKEN" \
-F "[email protected]"
```
```python
from openai import OpenAI
client = OpenAI(base_url='https://external.api.recraft.ai/v1', api_key=_RECRAFT_API_TOKEN)
style = client.post(
path='/images/creativeUpscale',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={'file': open('image.png', 'rb')},
)
print(response['image']['url'])
```
## Appendix
### List of styles
| Style | Recraft V3 Substyles | Recraft V2 Substyles |
| --- | --- | --- |
| any | (not applicable) | (not available) |
| realistic\_image | \- b\_and\_w<br> \- enterprise<br> \- evening\_light<br> \- faded\_nostalgia<br> \- forest\_life<br> \- hard\_flash<br> \- hdr<br> \- motion\_blur<br> \- mystic\_naturalism<br> \- natural\_light<br> \- natural\_tones<br> \- organic\_calm<br> \- real\_life\_glow<br> \- retro\_realism<br> \- retro\_snapshot<br> \- studio\_portrait<br> \- urban\_drama<br> \- village\_realism<br> \- warm\_folk | \- b\_and\_w<br> \- enterprise<br> \- hard\_flash<br> \- hdr<br> \- motion\_blur<br> \- natural\_light<br> \- studio\_portrait |
| digital\_illustration | \- 2d\_art\_poster<br> \- 2d\_art\_poster\_2<br> \- antiquarian<br> \- bold\_fantasy<br> \- child\_book<br> \- child\_books<br> \- cover<br> \- crosshatch<br> \- digital\_engraving<br> \- engraving\_color<br> \- expressionism<br> \- freehand\_details<br> \- grain<br> \- grain\_20<br> \- graphic\_intensity<br> \- hand\_drawn<br> \- hand\_drawn\_outline<br> \- handmade\_3d<br> \- hard\_comics<br> \- infantile\_sketch<br> \- long\_shadow<br> \- modern\_folk<br> \- multicolor<br> \- neon\_calm<br> \- noir<br> \- nostalgic\_pastel<br> \- outline\_details<br> \- pastel\_gradient<br> \- pastel\_sketch<br> \- pixel\_art<br> \- plastic<br> \- pop\_art<br> \- pop\_renaissance<br> \- seamless<br> \- street\_art<br> \- tablet\_sketch<br> \- urban\_glow<br> \- urban\_sketching<br> \- vanilla\_dreams<br> \- young\_adult\_book<br> \- young\_adult\_book\_2 | \- 2d\_art\_poster<br> \- 2d\_art\_poster\_2<br> \- 3d<br> \- 80s<br> \- engraving\_color<br> \- glow<br> \- grain<br> \- hand\_drawn<br> \- hand\_drawn\_outline<br> \- handmade\_3d<br> \- infantile\_sketch<br> \- kawaii<br> \- pixel\_art<br> \- plastic<br> \- psychedelic<br> \- seamless<br> \- voxel<br> \- watercolor |
| vector\_illustration | \- bold\_stroke<br> \- chemistry<br> \- colored\_stencil<br> \- contour\_pop\_art<br> \- cosmics<br> \- cutout<br> \- depressive<br> \- editorial<br> \- emotional\_flat<br> \- engraving<br> \- infographical<br> \- line\_art<br> \- line\_circuit<br> \- linocut<br> \- marker\_outline<br> \- mosaic<br> \- naivector<br> \- roundish\_flat<br> \- seamless<br> \- segmented\_colors<br> \- sharp\_contrast<br> \- thin<br> \- vector\_photo<br> \- vivid\_shapes | \- cartoon<br> \- doodle\_line\_art<br> \- engraving<br> \- flat\_2<br> \- kawaii<br> \- line\_art<br> \- line\_circuit<br> \- linocut<br> \- seamless |
| icon | (not available) | \- broken\_line<br> \- colored\_outline<br> \- colored\_shapes<br> \- colored\_shapes\_gradient<br> \- doodle\_fill<br> \- doodle\_offset\_fill<br> \- offset\_fill<br> \- outline<br> \- outline\_gradient<br> \- uneven\_fill |
| logo\_raster | \- emblem\_graffiti<br> \- emblem\_pop\_art<br> \- emblem\_punk<br> \- emblem\_stamp<br> \- emblem\_vintage | (not available) |
### List of image sizes
\- 1024x1024
\- 1365x1024
\- 1024x1365
\- 1536x1024
\- 1024x1536
\- 1820x1024
\- 1024x1820
\- 1024x2048
\- 2048x1024
\- 1434x1024
\- 1024x1434
\- 1024x1280
\- 1280x1024
\- 1024x1707
\- 1707x1024
### Policies
- All generated images are currently stored for approx. 24 hours, 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.
![Close Modal](https://cdn.prod.website-files.com/655727fe69827d9a402de12c/66a37f9778f431a823bfc15b_icon__x.svg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment