POST
/
v1
/
ai
/
text-to-image
curl --request POST \
  --url https://api.freepik.com/v1/ai/text-to-image \
  --header 'Accept: <accept>' \
  --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",
  "num_inference_steps": 8,
  "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",
      "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

Headers

Content-Type
string
required

The Content-Type header is used to indicate the media type of the resource. The media type is a string sent along with the file indicating the format of the file.

Accept
string
required

The Accept header is used to inform the server by the client that which content type is understandable by the client expressed as MIME-types.

Body

application/json
prompt
string
required

Text to generate image from

negative_prompt
string

Attributes to avoid in the generated image

styling
object
guidance_scale
number
default: 1

Defines the level of fidelity to the prompt we give to the image, the lower the level, the greater the creativity of the AI. Defaults to 1.0

image
object
num_inference_steps
integer
default: 8

Number of inference steps, higher values will generate more realistic images but will take longer to generate. Defaults to 8

num_images
integer
default: 1

Number of images to generate

seed
integer
default: 42

Seed to generate the image. Using the same seed will produce the same image, if not present, a random seed will be used.

Response

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