Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Zoen-DEV/repurpose-youtube-video/llms.txt

Use this file to discover all available pages before exploring further.

freepik_client.py wraps the Freepik Mystic text-to-image API. It handles task creation, polling until completion, and URL extraction from the response payload. Like blotato_client.py, it uses only Python stdlib — no third-party HTTP client required.

Setup

import freepik_client as fp
Requires FREEPIK_API_KEY in your .env file. The value is loaded via bc.load_config() and passed as the api_key keyword argument to every function.

fp.generate_image(prompt, *, api_key, aspect_ratio="square_1_1", model="realism")

Generates a single image with Freepik Mystic and returns the resulting image URL(s). The function posts to POST /v1/ai/mystic, receives a task_id, then polls GET /v1/ai/mystic/{task_id} at 4-second intervals until the status is COMPLETED.
prompt
string
required
Visual description in English, max 1000 characters. Always include "no text, no typography, no logos, no watermarks" to prevent Mystic from attempting to render copy. For images that will receive a text overlay, include "composition with negative space for overlay text".
api_key
string
required
Freepik API key from cfg["freepik_api_key"].
aspect_ratio
string
default:"square_1_1"
Canvas aspect ratio. Use "square_1_1" for Instagram (1080×1080) and "social_post_4_5" for LinkedIn (1080×1350).
model
string
default:"realism"
Mystic model variant. Options: "realism" (default, photographic quality), "fluid" (painterly/creative), "zen" (calm, minimal).
Raises RuntimeError if the task fails or completes without image URLs. Raises TimeoutError after 240 seconds (60 polls × 4s). Returns a list of image URL strings. Typically contains one URL — use [0] for the first image.
Generates multiple images sequentially, one per prompt, for an Instagram carousel. Failed slides are skipped rather than raising an exception, so a single bad generation does not abort the whole carousel.
prompts
string[]
required
List of prompt strings, one per carousel slide. Each is passed individually to fp.generate_image.
api_key
string
required
Freepik API key.
aspect_ratio
string
default:"square_1_1"
Canvas aspect ratio applied to all slides.
Returns a flat list of URL strings in input order. Slides that failed to generate are omitted from the list (the list may be shorter than prompts).

Prompt guidelines

  • Write prompts in English — Mystic performs significantly better in English.
  • Never ask for text in the image. Always append "no text, no typography, no logos, no watermarks". The text overlay is added separately by image_overlay.py.
  • Specify "composition with negative space for overlay text" so the renderer preserves a clean area for the overlay. For LinkedIn 4:5, negative space should be at the bottom; for Instagram single, at the bottom half; for carousel slide 1, centered.
  • Include style, lighting, composition, and palette. Example: "editorial photography, soft natural lighting, shallow depth of field, muted warm palette".
  • Keep each prompt under 300 characters to stay well within the 1000-character limit and maintain focus.

Aspect ratios

ValueDimensionsPlatform
square_1_11080×1080Instagram (single image and carousel slides)
social_post_4_51080×1350LinkedIn (optimal for feed rendering)

Build docs developers (and LLMs) love