Generate AI images using cURL or Python and create your own styles programmatically.

Generate a digital illustration using RecraftV3 model

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"
    }'

Generate a digital illustration with specific substyle

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"
    }'

Image to image with digital illustration style

curl -X POST https://external.api.recraft.ai/v1/images/imageToImage \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
    -F "image=@image.png" \
    -F "prompt=winter" \
    -F "strength=0.2" \
    -F "style=digital_illustration"

Inpaint an image with digital illustration style

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 "image=@image.png" -F "mask=@mask.png"
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 -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 "file=@image.png"

# 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"
    }'

Vectorize an image in PNG format

curl -X POST https://external.api.recraft.ai/v1/images/vectorize \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
    -F "file=@image.png"

Remove background from a PNG image, get the result in B64 JSON

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 "file=@image.png"

Run crisp upscale tool for a PNG image, get the result in B64 JSON

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 "file=@image.png"

Run creative upscale tool for a PNG image

curl -X POST https://external.api.recraft.ai/v1/images/creativeUpscale \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: Bearer $RECRAFT_API_TOKEN" \
    -F "file=@image.png"