Skip to main content
POST
/
v1
/
ai
/
text-to-image
/
flux-2-klein
curl --request POST \
  --url https://api.freepik.com/v1/ai/text-to-image/flux-2-klein \
  --header 'Content-Type: application/json' \
  --header 'x-freepik-api-key: <api-key>' \
  --data '
{
  "prompt": "a beautiful sunset over the ocean with dramatic clouds"
}
'
{
  "data": {
    "task_id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
    "status": "CREATED"
  }
}

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 description of the image you want to generate.

FLUX.2 [klein] is the fastest model in the FLUX.2 family, optimized for sub-second generation while maintaining high quality. It supports up to 4 reference images for style and subject transfer.

Tips for better results:

  • Be specific about subjects, scenes, and visual details
  • Use reference images to guide style and composition
  • Combine prompt with reference images for best results

Examples:

  • Simple: "a mountain landscape at sunset"
  • Detailed: "portrait of a person in natural lighting, soft focus background"
  • With style: "abstract art in the style of watercolor painting"
Example:

"a beautiful sunset over the ocean with dramatic clouds"

aspect_ratio
enum<string>
default:square_1_1

Aspect ratio of the generated image. Determines the proportional relationship between width and height.

Aspect RatioBase Dimensions (1k)
square_1_11024 × 1024
widescreen_16_91344 × 768
social_story_9_16768 × 1344
portrait_2_3832 × 1216
traditional_3_4960 × 1280
vertical_1_2704 × 1408
horizontal_2_11408 × 704
social_post_4_5896 × 1152
standard_3_21216 × 832
classic_4_31280 × 960
Available options:
square_1_1,
classic_4_3,
traditional_3_4,
widescreen_16_9,
social_story_9_16,
standard_3_2,
portrait_2_3,
horizontal_2_1,
vertical_1_2,
social_post_4_5
Example:

"square_1_1"

resolution
enum<string>
default:1k

Resolution multiplier for the generated image.

  • 1k: Uses base dimensions (default)
  • 2k: Doubles the base dimensions (capped at 2048px per side)

Final dimensions are calculated by multiplying base dimensions by the resolution factor, then scaling proportionally if either dimension exceeds 2048px, and aligning to multiples of 16.

Available options:
1k,
2k
Example:

"1k"

seed
integer | null

Random seed for reproducible results.

Use case: Generate variations of the same image by using the same seed with modified prompts.

Valid range: 0 to 4,294,967,295 Default: Random seed (if not provided)

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

42

input_image
string | null

Base64-encoded reference image for style/subject transfer.

Supported formats: JPEG, PNG Use cases:

  • Style transfer from reference images
  • Subject preservation
  • Composition guidance

Note: Supports up to 4 reference images using input_image, input_image_2, input_image_3, and input_image_4.

input_image_2
string | null

Second base64-encoded reference image for multi-image generation.

input_image_3
string | null

Third base64-encoded reference image for multi-image generation.

input_image_4
string | null

Fourth base64-encoded reference image for multi-image generation.

safety_tolerance
integer
default:2

Content moderation tolerance level.

Range: 0 to 5

  • 0: Most strict filtering
  • 5: Least strict filtering Default: 2

Note: Lower values filter more content. Choose based on your application requirements.

Required range: 0 <= x <= 5
output_format
enum<string> | null

Output image format.

PNG: Lossless, supports transparency, larger file JPEG: Lossy, smaller file, no transparency

Available options:
jpeg,
png
webhook_url
string<uri>

Optional callback URL that will receive asynchronous notifications whenever the task changes status. The payload sent to this URL is the same as the corresponding GET endpoint response, but without the data field.

Example:

"https://www.example.com/webhook"

Response

OK - Task created successfully

data
object
required
Example:
{
"task_id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"status": "CREATED"
}