POST
/
v1
/
ai
/
text-to-image
curl --request POST \
  --url https://api.freepik.com/v1/ai/text-to-image \
  --header 'Content-Type: <content-type>' \
  --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"
  },
  "styling": {
    "style": "anime",
    "color": "pastel",
    "lightning": "warm",
    "framing": "portrait"
  }
}'
{
  "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
headerrequired

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

Headers

Content-Type
string
required

The Content-Type header must be set to application/json to indicate that the payload is formatted as JSON. If a different Content-Type is provided, the payload will be ignored, and the request will proceed without processing the body.

Body

application/json
prompt
string
required

Text to generate image from Minimum length: 3 characters

negative_prompt
string

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

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.

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.

seed
integer
default: -1

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

Response

200 - application/json
data
object[]
required
meta
object
required