Skip to main content
POST
/
v1
/
ai
/
mystic
Create image from text - Mystic
curl --request POST \
  --url https://api.freepik.com/v1/ai/mystic \
  --header 'Content-Type: application/json' \
  --header 'x-freepik-api-key: <api-key>' \
  --data '{
  "prompt": "<string>",
  "webhook_url": "https://www.example.com/webhook",
  "structure_reference": "aSDinaTvuI8gbWludGxpZnk=",
  "structure_strength": 50,
  "style_reference": "aSDinaTvuI8gbWludGxpZnk=",
  "adherence": 50,
  "hdr": 50,
  "resolution": "2k",
  "aspect_ratio": "square_1_1",
  "model": "realism",
  "creative_detailing": 33,
  "engine": "automatic",
  "fixed_generation": false,
  "filter_nsfw": true,
  "styling": {
    "styles": [
      {
        "name": "<string>",
        "strength": 100
      }
    ],
    "characters": [
      {
        "id": "<string>",
        "strength": 100
      }
    ],
    "colors": [
      {
        "color": "#FF0000",
        "weight": 0.5
      }
    ]
  }
}'
{
"data": {
"generated": [],
"task_id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"status": "IN_PROGRESS"
}
}

Important

Mystic image generation mode is Freepik’s exclusive advanced AI workflow for ultra-realistic, high-resolution images. Make sure you get your webhook set up on every request in order to retrieve your generations.

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

Model Compatibility and LoRA Usage

The Mystic API supports different model configurations with varying LoRA compatibility:

LoRA-Compatible Configuration:

  • Use the default model (no model field specified)
  • No structure_reference or style_reference provided
  • LoRAs can be used via:
    • Character syntax in prompt: @character_name or @character_name::strength
    • styling.characters array
    • styling.styles array

LoRA-Incompatible Configurations:

  • Specific Models: fluid, flexible , super_real and editorial_portraits models ignore all LoRAs
  • Structure Reference: When structure_reference is provided, LoRAs are ignored
  • Style Reference: When style_reference is provided, LoRAs are ignored
  • Combined References: When both structure_reference and style_reference are provided, LoRAs are ignored

Important: The API will not return errors for incompatible combinations. Instead, LoRAs will be silently ignored, and the request will proceed with the selected model configuration.

prompt
string

AI Model Prompt Description

The prompt is a short text that describes the image you want to generate. It can range from simple descriptions, like "a cat", to detailed scenarios, such as "a cat with wings, playing the guitar, and wearing a hat". If no prompt is provided, the AI will generate a random image.

Adding Characters to the Prompt

You can introduce characters into the prompt using the following syntax:

  • @character_name: Represents the character you want to include. Example: My friend @john is a great artist.

Modifying Character Strength

To adjust the influence or "strength" of a character in the image, use the following syntax:

  • @character_name::strength: Specify the character's strength by appending ::strength to their name, where strength is a numerical value. Example: My friend @john::200 is a great artist.

Higher strength values will make the character more prominent in the generated image.

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"

structure_reference
string<byte>

Structure Reference

Base64 image to use as structure reference. Using images as structure references allows you to influence the shape of your final image. This feature enables various creative applications such as coloring sketches, transforming cartoons into realistic images, texturing basic 3D models, or converting real images into cartoons. The outcome is entirely controlled by your prompt, offering limitless creative possibilities.

structure_strength
integer
default:50

Note: This parameter only takes effect when a "structure_reference" image is provided. Allows to maintain the structure of the original image.

Required range: 0 <= x <= 100
style_reference
string<byte>

Style Reference

Base64 image to use as style reference. Using images as style references allows you to influence the aesthetic of your creation. This is possibly the most powerful tool of Mystic, as it truly lets you create incredibly unique images.

adherence
integer
default:50

Note: This parameter only takes effect when a "style_reference" image is provided. Increasing this value will make your generation more faithful to the prompt, but it may transfer the style a bit less accurately. Higher values can help fix small artifacts, anatomical errors and text readability. Lower values will give you more creative images and closer to the style reference.

Required range: 0 <= x <= 100
hdr
integer
default:50

Note: This parameter only takes effect when a "style_reference" image is provided. Increasing this value can give you a more detailed image, at the cost of a more 'AI look' and slightly worse style transfer. Lower values have a more natural and artistic look but may increase artifacts.

Required range: 0 <= x <= 100
resolution
enum<string>
default:2k

Resolution of the image

Available options:
1k,
2k,
4k
aspect_ratio
enum<string>
default:square_1_1

Image size with the aspect ratio. The aspect ratio is the proportional relationship between an image's width and height, expressed as *_width_height (e.g., square_1_1, widescreen_16_9). It is calculated by dividing the width by the height.
If not present, the default is square_1_1. Note: For the fluid model, only this values are valid:

  • square_1_1
  • social_story_9_16
  • widescreen_16_9
  • traditional_3_4
  • classic_4_3
Available options:
square_1_1,
classic_4_3,
traditional_3_4,
widescreen_16_9,
social_story_9_16,
smartphone_horizontal_20_9,
smartphone_vertical_9_20,
standard_3_2,
portrait_2_3,
horizontal_2_1,
vertical_1_2,
social_5_4,
social_post_4_5'
Example:

"square_1_1"

model
enum<string>
default:realism
  • zen - for smoother, basic, and cleaner results. Fewer objects in the scene and less intricate details. The softer looking one.

  • flexible - good prompt adherence. However, it has results that are a bit more HDR and saturated than Realism or Fluid. It's especially good with illustrations, fantastical prompts, and for diving into the latent space in search of very specific visual styles.

  • fluid - the model that adheres best to prompts with great average quality for all kind of images. It can generate really creative images! It will always follow your input no matter what. However, since it is using Google's Imagen 3, it is a bit over-moderated, and some simple prompts containing words like "war" may be flagged and not generated (sorry about that! But there's nothing we can do!).

  • realism - with a more realistic color palette. It tries to give an extra boost of reality to your images, a kind of "less AI look". Works especially well with photographs but also magically works with illustrations too. IMPORTANT: you should use Zen, Flexible or Fluid if you are trying to generate something that is really fantastic or a known character, Realism may not follow your prompt well.

  • super_real - if reality is your priority, this is your model. Nearly as versatile as Flexible, it excels in realism outperforming Editorial Portraits in medium shots, though not as strong for close-ups.

  • editorial_portraits - the most amazing state-of-the-art generator for editorial portraits. You have never seen a level of realism like this before. Perfect for hyperrealistic close-up or medium shots. Unfortunately, in wide or distant shots, it generates anatomical problems and artifacts... but for close-ups, it is simply the best on the market. Tip: use the longest and most explanatory prompts possible, they really suit it well!

Available options:
realism,
fluid,
zen,
flexible,
super_real,
editorial_portraits
creative_detailing
integer
default:33

Higher values can achieve greater detail per pixel at higher resolutions at the cost of giving a somewhat more "HDR" or artificial look. Very high values can generate quite crazy things like eyes where they shouldn't appear, etc.

Valid values range [0, 100], default 33

Required range: 0 <= x <= 100
engine
enum<string>
default:automatic

Select the engine for the AI model. Available options:

  • automatic - default choice
  • Illusio - for smoother illustrations, landscapes, and nature. The softer looking one.
  • Sharpy - better for realistic images like photographs and for a more grainy look. It provides the sharpest and most detailed images. If you use it for illustrations it will give them more texture and a less softer look.
  • Sparkle - also good for realistic images. It's a middle ground between Illusio and Sharpy.
Available options:
automatic,
magnific_illusio,
magnific_sharpy,
magnific_sparkle
fixed_generation
boolean
default:false

When this option is enabled, using the same settings will consistently produce the same image. Fixed generations are ideal for fine-tuning, as it allows for incremental changes to parameters (such as the prompt) to see subtle variations in the output. When disabled, expect each generation to introduce a degree of randomness, leading to more diverse outcomes.

filter_nsfw
boolean
default:true

Controls NSFW (Not Safe For Work) content filtering during generation.

This parameter is always set to true by default and NSFW filtering cannot be disabled for standard API usage. Only authorized clients with special permissions can disable this filter.

Important: If your use case requires disabling NSFW filtering, please contact our support team to discuss your requirements and potential authorization.

styling
object

Styling options for the image

Response

OK - The request has succeeded and the Mystic process has started.

data
object
required
Example:
{
"generated": [
"https://openapi-generator.tech",
"https://openapi-generator.tech"
],
"task_id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"status": "CREATED"
}
I