POST
/
v1
/
ai
/
text-to-image
curl --request POST \
--url https://api.freepik.com/v1/ai/text-to-image \
--header 'Content-Type: application/json' \
--header 'x-freepik-api-key: <api-key>' \
--data '{
"prompt": "Crazy dog in the space",
"negative_prompt": "b&w, earth, cartoon, ugly",
"guidance_scale": 2,
"seed": 42,
"num_images": 1,
"image": {
"size": "square_1_1"
},
"styling": {
"style": "anime",
"effects": {
"color": "pastel",
"lightning": "warm",
"framing": "portrait"
},
"colors": [
{
"color": "#FF5733",
"weight": 1
},
{
"color": "#33FF57",
"weight": 1
}
]
},
"filter_nsfw": true
}'
{
"data": [
{
"base64": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAQAAAABRBrPYAAABrElEQVR4nO3BMQEAAADCoPVPbQ0Po...",
"has_nsfw": false
},
{
"base64": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAQAAAABRBrPYAAABrElEQVR4nO3BMQEAAADCoPVPbQ0Po...",
"has_nsfw": false
}
],
"meta": {
"image": {
"size": "square_1_1",
"width": 1024,
"height": 1024
},
"seed": 42,
"guidance_scale": 2,
"prompt": "Crazy dog flying over the space",
"num_inference_steps": 8
}
}

Authorizations

x-freepik-api-key
string
header
required

Your Freepik API key. Required for authentication. Learn how to obtain an API key

Body

application/json
prompt
string
required

Text to generate image from Minimum length: 3 characters

Minimum length: 3
Example:

"Crazy dog flying over the space"

negative_prompt
string

Attributes to avoid in the generated image Minimum length: 3 characters

Minimum length: 3
Example:

"b&w, grayscale, disfigured, bad quality"

styling
object
guidance_scale
number
default:1

Defines the level of fidelity to the prompt when generating the image. A lower value allows for more creativity from the AI, while a higher value ensures closer adherence to the prompt. Valid values range [0.0, 2.0], default 1.0.

Required range: 0 <= x <= 2
Example:

2

image
object
num_images
integer
default:1

Specifies the number of images to generate in a single request. Valid values range [1, 4], default 1.

Required range: 1 <= x <= 4
Example:

1

seed
integer

Seed value for image generation. Using the same seed will produce the same image. If omitted, random seed will be applied, resulting in a different image each time. Valid values range [0, 1000000].

Required range: 0 <= x <= 1000000
Example:

123

filter_nsfw
boolean

If true, the generated image will be filtered for NSFW content. If false, the image may contain NSFW content. Default value is true.

Example:

true

Response

OK - The request has succeeded, and the images generated from the text are returned.

data
object[]
required
meta
object
required
Example:
{
"image": {
"size": "square_1_1",
"width": 1024,
"height": 1024
},
"seed": 42,
"guidance_scale": 2,
"prompt": "Crazy dog flying over the space",
"num_inference_steps": 8
}