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",
  "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

Accept-Language
string

Specifies the search query language using the ISO 639-1 (2-letter language code) and the ISO 3166-1 (2-letter country code) for language variants. The API will use "en-US" as a default language for processing if a code is not provided, or does not exist.

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