# Analyzes an image to determine its likelihood of being AI-generated
Source: https://docs.freepik.com/api-reference/classifier/post-ai-classifier
post /v1/ai/classifier/image
Accepts an image file as input and analyzes it to determine the probability that the image was generated by artificial intelligence, providing a confidence score.
# AI Icon generation
Source: https://docs.freepik.com/api-reference/icon-generation/post-generate-icon
post /v1/ai/text-to-icon
Create stunning icons in different styles and formats (png, svg) from text prompts using our advanced AI models.
## Description
Generate an icon from a text prompt.
# AI Icon preview generation
Source: https://docs.freepik.com/api-reference/icon-generation/post-preview
post /v1/ai/text-to-icon/preview
Create stunning previews icons in different styles and formats (png, svg) from text prompts using our advanced AI models.
# Download an icon preview
Source: https://docs.freepik.com/api-reference/icon-generation/post-{format}-by-id
post /v1/ai/text-to-icon/{task-id}/render/{format}
Download the generated AI icon in the specified format png or svg.
# Download an icon
Source: https://docs.freepik.com/api-reference/icons/download-an-icon
get /v1/icons/{id}/download
Download the specified icon by its unique ID in the requested format and size.
# Search and filter icons by specified order
Source: https://docs.freepik.com/api-reference/icons/get-all-icons-by-order
get /v1/icons
Get a list of icons based on the provided parameters and ordering criteria.
# Get detailed icon information by ID
Source: https://docs.freepik.com/api-reference/icons/get-one-icon-by-id
get /v1/icons/{id}
Get detailed information about a specific icon identified by its unique ID.
# Get the status of all image expand tasks
Source: https://docs.freepik.com/api-reference/image-expand/get-flux-pro
get /v1/ai/image-expand/flux-pro
# Get the status of one image expand task
Source: https://docs.freepik.com/api-reference/image-expand/get-{task-id}-by-id
get /v1/ai/image-expand/flux-pro/{task-id}
# Image expand using AI Flux Pro
Source: https://docs.freepik.com/api-reference/image-expand/post-flux-pro
post /v1/ai/image-expand/flux-pro
This endpoint allows you to expand an image using the AI Flux Pro model. The image will be expanded based on the provided parameters.
# Get the status of the relight task
Source: https://docs.freepik.com/api-reference/image-relight/get-image-relight
get /v1/ai/image-relight/{task-id}
Get the status of the relight task
# Get the status of all relight tasks
Source: https://docs.freepik.com/api-reference/image-relight/get-image-relight-task
get /v1/ai/image-relight
Get the status of all relight tasks
# Overview
Source: https://docs.freepik.com/api-reference/image-relight/image-relight
Image Relight allows you to change the entire lighting of a scene and, optionally, the background using:
1. A prompt
2. A reference image
3. A light map
This tool can simulate different lighting scenarios, enhance details, and create artistic effects. Our API lets you transform your images with custom prompts and fine-tuned parameters for impressive results.
Image Relight uses Magnific.ai technology, now available as a comprehensive API service.
### Use Cases
The Image Relight can be applied to a wide range of image types and industries, including:
* Portraits: Change lighting to enhance facial features
* Product photography: Adjust lighting for better presentation
* Architectural renderings: Simulate different times of day
* Film stills: Create dramatic lighting effects
* Graphic design: Add creative lighting to designs
* Nature photography: Enhance natural light conditions
### Selecting Light Transfer Method
Choose one of these three ways to transfer light in Image Relight:
1. **Prompt** Describe the desired lighting using text. Specify characteristics like color, time of day, type and shape of light.
Example: "A sunlit forest clearing at golden hour" or "Under the water"
2. **Reference Image** Provide an image to transfer lighting from. Image Relight will replicate the light, colors, and shadows from this reference.
3. **Lightmap** Create custom lighting with your own lightmap image:
* Black represents absence of light
* Lighter colors (including white) indicate presence, color, and shape of light sources
Relight an image using AI
Get the status of a relighting task
Get the status of all relighting tasks
### Frequently Asked Questions
Yes! Magnific.ai is part of Freepik and we are happy to offer the same technology in an API service. If you tried Magnific.ai before, you will get the same technology and its future updates.
The cost per image relight is a fixed cost of €0.10 per operation. This ensures that you have complete transparency and control over your usage.
# Relight an image
Source: https://docs.freepik.com/api-reference/image-relight/post-image-relight
post /v1/ai/image-relight
Relight an image using AI. This endpoint accepts a variety of parameters to customize the generated images.
## Important
Upscaler endpoints are only available for premium API users. You can upgrade your account [here](https://www.freepik.com/developers/dashboard/billing).
## Request
# Get the status of all Style Transfer tasks
Source: https://docs.freepik.com/api-reference/image-style-transfer/get-image-style-transfer
get /v1/ai/image-style-transfer
Get the status of all Style Transfer tasks
# Get the status of the Style Transfer task
Source: https://docs.freepik.com/api-reference/image-style-transfer/get-image-style-transfer-task
get /v1/ai/image-style-transfer/{task-id}
Get the status of the Style Transfer task
# Overview
Source: https://docs.freepik.com/api-reference/image-style-transfer/image-styletransfer
Image Style Transfer is a powerful AI-driven tool that allows you to transform any image by applying various artistic styles. This technology goes beyond simple filters, enabling you to control the amount of style transferred and maintain structural integrity. With our API, you can:
1. Apply predefined artistic styles
2. Use custom images as style references
3. Fine-tune the style transfer process with advanced parameters
4. Transform images while preserving important details
5. Combine style transfer with upscaling for high-resolution results
Whether you're a professional artist, game developer, or just looking to have fun with your photos, Image Style Transfer opens up a world of creative possibilities.
### Use Cases
Image Style Transfer can be applied to various industries and creative projects, some examples are:
* **Video Game Development**: Transform concept art and create stylized game assets
* **Film and VFX**: Create dramatic lighting effects and stylized scenes
* **Interior Design**: Visualize room makeovers with different design styles
* **3D Rendering**: Texturize and light 3D renders using reference images
* **Sketch Transformation**: Convert sketches into detailed, styled artwork
### Key Features
* **Control Over Style Intensity**: Adjust the strength of the style transfer to find the perfect balance between the original image and the new style.
* **Structure Preservation**: Maintain important details and structural elements of the original image while applying new styles.
* **Prompt-Guided Transformations**: Use text prompts to further refine and direct the style transfer process.
* **Multiple Style Engines**: Choose from various AI engines optimized for different types of style transfers.
By leveraging the power of AI, Image Style Transfer enables creators to push the boundaries of visual art and design, saving hours of manual work and opening up new realms of creative possibility.
API Reference: Image Style Transfer
### Frequently Asked Questions
Yes! Magnific.ai is part of Freepik and we are happy to offer the same technology in an API service. If you tried Magnific.ai before, you will get the same technology and its future updates.
The cost per image style transfer is a fixed cost of €0.10 per operation. This ensures that you have complete transparency and control over your usage.
# Style transfer an image using AI
Source: https://docs.freepik.com/api-reference/image-style-transfer/post-image-style-transfer
post /v1/ai/image-style-transfer
# Get the list of the kling-elements-pro tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-elements-pro/get-kling-elements-pro
get /v1/ai/image-to-video/kling-elements-pro
Get the list of the kling-elements-pro tasks
# Get the status of the kling-elements task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-elements-pro/get-kling-elements-pro-task
get /v1/ai/image-to-video/kling-elements/{task-id}
Get the status of the kling-elements task
# Create a video from an image - Kling Elements Pro model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-elements-pro/post-kling-elements-pro
post /v1/ai/image-to-video/kling-elements-pro
Generate a video from an image using the Kling Elements Pro model.
## Important
The service allows up to 3 concurrent requests per user.
# Get the list of the kling-elements-std tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-elements-std/get-kling-elements-std
get /v1/ai/image-to-video/kling-elements-std
Get the list of the kling-elements-std tasks
# Get the status of the kling-elements task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-elements-std/get-kling-elements-std-task
get /v1/ai/image-to-video/kling-elements/{task-id}
Get the status of the kling-elements task
# Create a video from an image - Kling Elements Std model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-elements-std/post-kling-elements-std
post /v1/ai/image-to-video/kling-elements-std
Generate a video from an image using the Kling Elements Std model.
## Important
The service allows up to 3 concurrent requests per user.
# Get the list of the kling-pro tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-pro/get-kling-pro
get /v1/ai/image-to-video/kling-pro
Get the list of the kling-pro tasks
# Get the status of the kling task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-pro/get-kling-pro-task
get /v1/ai/image-to-video/kling/{task-id}
Get the status of the kling task
# Create a video from an image - Kling 1.6 pro model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-pro/post-kling-pro
post /v1/ai/image-to-video/kling-pro
Generate a video from an image using the Kling 1.6 Pro model.
## Important
The service allows up to 3 concurrent requests per user.
# Get the list of the kling-pro tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-std/get-kling-std
get /v1/ai/image-to-video/kling-std
Get the list of the kling-pro tasks
# Get the status of the kling task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-std/get-kling-std-task
get /v1/ai/image-to-video/kling/{task-id}
Get the status of the kling task
# Create a video from an image - Kling 1.6 standard model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-std/post-kling-std
post /v1/ai/image-to-video/kling-std
Generate a video from an image using the Kling 1.6 Std model.
## Important
The service allows up to 3 concurrent requests per user.
# Get the list of the kling-v2-1-std tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-master/get-kling-v2-1-master
get /v1/ai/image-to-video/kling-v2-1-master
Get the list of the kling-v2-1-std tasks
# Get the status of the kling-v2-1-master task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-master/get-kling-v2-1-master-task
get /v1/ai/image-to-video/kling-v2-1-master/{task-id}
Get the status of the kling-v2-1-master task
# Create a video from an image - Kling 2.1 master model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-master/post-kling-v2-1-master
post /v1/ai/image-to-video/kling-v2-1-master
Generate a video from an image using the Kling 2.1 Master model.
# Get the list of the kling-v2-1-pro tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-pro/get-kling-v2-1-pro
get /v1/ai/image-to-video/kling-v2-1-pro
Get the list of the kling-v2-1-pro tasks
# Get the status of the kling-v2-1 task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-pro/get-kling-v2-1-pro-task
get /v1/ai/image-to-video/kling-v2-1/{task-id}
Get the status of the kling-v2-1 task
# Create a video from an image - Kling 2.1 pro model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-pro/post-kling-v2-1-pro
post /v1/ai/image-to-video/kling-v2-1-pro
Generate a video from an image using the Kling 2.1 Pro model.
# Get the list of the kling-v2-1-std tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-std/get-kling-v2-1-std
get /v1/ai/image-to-video/kling-v2-1-std
Get the list of the kling-v2-1-std tasks
# Get the status of the kling-v2-1 task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-std/get-kling-v2-1-std-task
get /v1/ai/image-to-video/kling-v2-1/{task-id}
Get the status of the kling-v2-1 task
# Create a video from an image - Kling 2.1 standard model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2.1-std/post-kling-v2-1-std
post /v1/ai/image-to-video/kling-v2-1-std
Generate a video from an image using the Kling 2.1 Std model.
# Get the list of the kling-v2 tasks
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2/get-kling-v2
get /v1/ai/image-to-video/kling-v2
Get the list of the kling-v2 tasks
# Get the status of the kling-v2 task
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2/get-kling-v2-task
get /v1/ai/image-to-video/kling-v2/{task-id}
Get the status of the kling-v2 task
# Create a video from an image using the Kling v2 model
Source: https://docs.freepik.com/api-reference/image-to-video/kling-v2/post-kling-v2
post /v1/ai/image-to-video/kling-v2
Create a video from an image using the Kling v2 model
## Important
The service allows up to 3 concurrent requests per user.
# Get the status of the upscaling task
Source: https://docs.freepik.com/api-reference/image-upscaler/get-image-upscaler
get /v1/ai/image-upscaler/{task-id}
Get the status of the upscaling task
# Get the status of all upscaling tasks
Source: https://docs.freepik.com/api-reference/image-upscaler/get-image-upscaler-task
get /v1/ai/image-upscaler
Get the status of all upscaling tasks
# Overview
Source: https://docs.freepik.com/api-reference/image-upscaler/image-upscaler
## Overview
The Magnific Upscaler enhances images to higher resolutions. This powerful tool does more than just increase image size - it also improves quality and adds detail. By leveraging advanced upscaling technology, our API allows you to transform your images with custom prompts and fine-tuned parameters, achieving impressive results.
### Use Cases
The Magnific Upscaler can be applied to a wide range of image types and industries, including:
* Portraits: Enhance facial details and skin textures
* Illustrations: Sharpen lines and improve color vibrancy
* Video game assets: Upscale textures and character models
* Landscapes: Bring out intricate details in nature scenes
* Science fiction imagery: Enhance futuristic and space-themed visuals
* Fantasy art: Improve magical and mythical elements
* Film stills: Increase resolution for better visual quality
* Graphic design: Upscale logos and marketing materials
* Architectural renderings: Enhance building details and textures, jumping from quick sketches to high quality renders
* Interior design: Improve quality of room layouts and furniture details
* Food photography: Bring out textures and colors in culinary images
### Upscale an Image with Magnific
Create an upscaling task for an image.
Upscale an image using Magnific
## Frequently Asked Questions
Yes! Magnific.ai is part of Freepik and we are happy to offer the same technology in an API service. If you tried Magnific.ai before, you will get the same technology and its future updates.
The cost per image upscale is based on the output image area in pixels. This depends on two key factors:
* The dimensions of the input image
* The upscale factor applied (e.g.: 2x, 4x, 8x, 16x)
The larger the output image area, the higher the cost per upscale. Our pricing tiers are applied based on the final output size, so you have complete transparency and control over your usage.
Some examples:
| Input Size | Output Size | Upscale Factor | Price |
| ---------- | ----------- | -------------- | ----- |
| 640x480 | 1280x960 | 2x | €0.10 |
| 640x480 | 2560x1920 | 4x | €0.40 |
| 640x480 | 5120x3840 | 8x | €1.60 |
| 1280x720 | 2560x1440 | 2x | €0.10 |
| 1280x720 | 5120x2880 | 4x | €0.40 |
| 1920x1080 | 3840x2160 | 2x | €0.20 |
| 5000x5000 | 10000x10000 | 2x | €1.20 |
The pricing structure ensures that you only pay for the level of upscaling you need.
# Upscale an image with Magnific
Source: https://docs.freepik.com/api-reference/image-upscaler/post-image-upscaler
post /v1/ai/image-upscaler
This asynchronous endpoint enables image upscaling using advanced AI algorithms. Upon submission, it returns a unique `task_id` which can be used to track the progress of the upscaling process. For real-time production use, include the optional `webhook_url` parameter to receive an automated notification once the task has been completed. This allows for seamless integration and efficient task management without the need for continuous polling.
{/*
import { ParamFields } from '@mintlify/components';
*/}
## Important
For a comprehensive guide on this service, including use cases and detailed functionality, check out our [Image Upscaler Guide](/api-reference/image-upscaler/image-upscaler).
## Request
# null
Source: https://docs.freepik.com/api-reference/mystic/get-loras
get /v1/ai/loras
# Get the status of all Mystic tasks
Source: https://docs.freepik.com/api-reference/mystic/get-mystic
get /v1/ai/mystic
Get the status of all Mystic tasks
# Get the status of the Mystic task
Source: https://docs.freepik.com/api-reference/mystic/get-mystic-task
get /v1/ai/mystic/{task-id}
Get the status of the Mystic task
# Overview
Source: https://docs.freepik.com/api-reference/mystic/mystic
Mystic AI image generation is a cutting-edge tool that produces stunningly realistic, high-resolution images. With options for 1K, 2K and 4K resolution, Mystic delivers sharp, detailed visuals that rival professional photography. From intricate facial features to complex textures, every element is rendered with exceptional clarity and precision.
### Stunning 1K, 2K and 4K quality
Enjoy razor-sharp 1K, 2K and 4K resolution with Freepik Mystic. Generate high-definition images with zero effort—no extra steps or upscaling needed. Just describe your vision, and Mystic will create beautifully detailed visuals ready for any project, from web design to large-format printing.
### Effortless creation
Transform your text descriptions into impressive, realistic results with custom parameters. Whether you need faces, hands, or text, everything is pixel-perfect and photo-realistic. Our state-of-the-art AI technology ensures that every generated image meets professional standards without requiring additional editing.
### Versatile applications
Perfect for a wide range of uses, including:
* Marketing materials that demand visual impact
* E-commerce product showcases with lifelike detail
* High-quality illustrations for publications
* Concept art for film and game development
* And much more!
With Mystic AI, you're equipped to create visuals that captivate and convince, all at the click of a button.
Generate an image using Mystic
Get the status of a Mystic image generation task
Get a list of all Mystic image generation tasks, including their statuses and details.
Returns a curated list of available LoRAs (Low-Rank Adaptation) for Mystic image generation.
### Frequently Asked Questions
Yes! Also Relight and Style transfer. We plan to keep adding all of our AI tools as APIs you can enjoy and build amazing products with.
No, these are separate products with different subscriptions.
Yes. There might be slight delays in pushing Magnific or Freepik web tools updates to the API though. We'll keep the team updated on all changes through [Discord](https://discord.com/invite/yruyXsvy) and the [Changelog](https://docs.freepik.com/changelog/2024).
# LoRAs training for custom characters
Source: https://docs.freepik.com/api-reference/mystic/post-loras-characters
post /v1/ai/loras/characters
Create you own custom character using LoRAs training
For now you can check the status of the training calling `v1/ai/loras`. We are working on it
# LoRAs training for custom styles
Source: https://docs.freepik.com/api-reference/mystic/post-loras-styles
post /v1/ai/loras/styles
Create you own custom style using LoRAs training
For now you can check the status of the training calling `v1/ai/loras`. We are working on it
# Create image from text - Mystic
Source: https://docs.freepik.com/api-reference/mystic/post-mystic
post /v1/ai/mystic
Convert descriptive text input into images using AI. This endpoint accepts a variety of parameters to customize the generated images.
## 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.
# Remove the background of an image
Source: https://docs.freepik.com/api-reference/remove-background/post-beta-remove-background
post /v1/ai/beta/remove-background
This endpoint removes the background from an image provided via a URL. The URLs in the response are temporary and valid for **5 minutes** only.
# Download an resource
Source: https://docs.freepik.com/api-reference/resources/download-a-resource
get /v1/resources/{resource-id}/download
Download a specific resource by providing the resource ID. This endpoint supports downloading various types of resources including vectors, PSDs, photos, and AI-generated content.
# Get available download formats for resource
Source: https://docs.freepik.com/api-reference/resources/download-resource-by-id-and-format
get /v1/resources/{resource-id}/download/{resource-format}
Retrieve a resource by specifying both the resource ID and the format. This endpoint allows for precise downloading of resources in the desired format.
# Search and filter resources with advanced options
Source: https://docs.freepik.com/api-reference/resources/get-all-resources
get /v1/resources
Retrieve a list of resources based on various filter criteria such as orientation, content type, license, and more.
# Get detailed resource information by ID
Source: https://docs.freepik.com/api-reference/resources/get-the-detail-of-a-resource-psd-vector-or-photo
get /v1/resources/{resource-id}
Retrieve the detailed information of a specific resource by its ID. This endpoint supports multiple resource types including PSD, vector, photo, and AI-generated content.
# Overview
Source: https://docs.freepik.com/api-reference/resources/stock-content
The Stock Content API provides access to Freepik's vast library of high-quality images, vectors, and other design resources. This tool allows you to seamlessly integrate Freepik's content into your applications, websites, or creative projects.
API Reference: Stock Content
# Get the status of the flux-dev task
Source: https://docs.freepik.com/api-reference/text-to-image/flux-dev/get-flux-dev
get /v1/ai/text-to-image/flux-dev
Get the status of the flux-dev task
# Get the status of the flux-dev task
Source: https://docs.freepik.com/api-reference/text-to-image/flux-dev/get-flux-dev-task
get /v1/ai/text-to-image/flux-dev/{task-id}
Get the status of the flux-dev task
# Create image from text - Flux dev
Source: https://docs.freepik.com/api-reference/text-to-image/flux-dev/post-flux-dev
post /v1/ai/text-to-image/flux-dev
Convert descriptive text input into images using AI. This endpoint accepts a variety of parameters to customize the generated images.
# Create image from text - Classic fast
Source: https://docs.freepik.com/api-reference/text-to-image/get-image-from-text
post /v1/ai/text-to-image
Convert descriptive text input into images using AI. This endpoint accepts a variety of parameters to customize the generated images.
# Get the status of all Imagen3 tasks
Source: https://docs.freepik.com/api-reference/text-to-image/imagen3/get-imagen3
get /v1/ai/text-to-image/imagen3
Get the status of all Imagen3 tasks
# Get the status of the Imagen3 task
Source: https://docs.freepik.com/api-reference/text-to-image/imagen3/get-imagen3-task
get /v1/ai/text-to-image/imagen3/{task-id}
Get the status of the Imagen3 task
# Create image from text - Imagen3
Source: https://docs.freepik.com/api-reference/text-to-image/imagen3/post-imagen3
post /v1/ai/text-to-image/imagen3
Convert descriptive text input into images using AI. This endpoint accepts a variety of parameters to customize the generated images.
# (Beta) Reimagine Flux
Source: https://docs.freepik.com/api-reference/text-to-image/reimagine-flux/post-reimagine-flux
post /v1/ai/beta/text-to-image/reimagine-flux
(Beta, synchronous) Reimagine Flux is a new AI model that allows you to generate images from text prompts.
# Authentication
Source: https://docs.freepik.com/authentication
Learn how to authenticate your requests to the Freepik API
## API Key Authentication
Freepik API uses API keys to authenticate requests. You need to include your API key in the header of every API request to access the Freepik resources.
Currently, private API keys are the only way to authenticate with the Freepik API. This means that only server-to-server calls can be made to the API
All API endpoints are authenticated using API keys and picked up from the specification file.
Download the OpenAPI specification file
## Obtaining an API Key
To get an API key:
1. Sign up for a Freepik account at [freepik.com/api](https://www.freepik.com/api)
2. If you are already registered, visit the API dashboard at [freepik.com/developers/dashboard](https://www.freepik.com/developers/dashboard)
3. Look for the API key section and generate a new API key
If you believe your key has been compromised, please contact us and we will generate a new one for you.
## Using the API Key
Include your API key in the `x-freepik-api-key` header of your HTTP requests:
```bash
curl -H "x-freepik-api-key: YOUR_API_KEY" https://api.freepik.com/v1/resources
```
```javascript JavaScript
const axios = require('axios');
const response = await axios.get('https://api.freepik.com/v1/resources', {
headers: {
'x-freepik-api-key': 'YOUR_API_KEY'
}
});
```
```python Python
import requests
headers = {
'x-freepik-api-key': 'YOUR_API_KEY'
}
response = requests.get('https://api.freepik.com/v1/resources', headers=headers)
```
```ruby Ruby
require 'net/http'
require 'uri'
uri = URI.parse('https://api.freepik.com/v1/resources')
request = Net::HTTP::Get.new(uri)
request['x-freepik-api-key'] = 'YOUR_API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(request)
end
```
## Rate limiting
Be aware that API requests are subject to [rate limiting](/ratelimits). The specific limits may vary based on your account type and agreement with Freepik. Always check the API response headers for rate limit information.
# Welcome to Freepik API
Source: https://docs.freepik.com/introduction
Start Building Today
Get your API key now and receive 5 USD in free credits
Create custom visuals from text prompts using our state-of-the-art AI models.
Enhance, upscale, relight, and transform images with powerful AI-driven tools.
Convert static images into dynamic videos with customizable motion effects.
Create stunning icons in different styles from text prompts using our advanced AI models.
Automatically detect AI-generated content with our advanced classification system.
Access millions of vectors, photos, icons, and templates to enhance your applications.
## Why developers choose Freepik API
Comprehensive documentation and dedicated support for seamless integration.
From startups to enterprises, our API grows with your needs. Pay only for what you use with transparent, usage-based pricing and no hidden fees.
Dependable infrastructure designed for high performance and scalability.
## LLM-Friendly Documentation
Our documentation is also available in an LLM-friendly format, making it easy to integrate with large language models and AI tools.
You can access it in two ways:
* [llms.txt](https://docs.freepik.com/llms.txt) – A lightweight sitemap that lists all documentation pages.
* [llms-full.txt](https://docs.freepik.com/llms-full.txt) – The full documentation in markdown format. (Note: This may exceed your model’s context window.)
Additionally, any page can be accessed as Markdown by appending .md to the URL.
For example:
[https://docs.freepik.com/introduction](https://docs.freepik.com/introduction) →
[https://docs.freepik.com/introduction.md](https://docs.freepik.com/introduction.md)
## Freepik MCP Open Source
Want to easily integrate Freepik API into your AI workflows? Discover the open source project [Freepik MCP](https://github.com/freepik-company/freepik-mcp):
* MCP server to connect AI assistants (like Claude, Cursor, etc.) with the Freepik API.
* Enables search, download, and generation of images and icons, resource management, and AI-powered image classification.
* Open source and easy to install. Start building your own custom solutions today!
[View on GitHub](https://github.com/freepik-company/freepik-mcp)
# Quickstart
Source: https://docs.freepik.com/quickstart
Ready to harness the power of Freepik API?
## Get Started
Follow these steps to begin:
Visit our [API landing page](https://www.freepik.com/developers/dashboard/api-key) to sign up and get a free API key, plus a 5 USD credit to get started!!
Dive into our comprehensive [API Reference](/api-reference/mystic/post-mystic/) to learn how to integrate our API into your projects effectively.
Start experimenting with our API to access and utilize the vast collection of resources available.
To enjoy all our services and greater rate limits, upgrade your plan in the [developers dashboard](https://www.freepik.com/developers/dashboard/billing).
Need assistance or have questions? Contact our dedicated support team via our [support page](https://www.freepik.com/api#contact) for prompt assistance.
# Rate limiting
Source: https://docs.freepik.com/ratelimits
To ensure the stability and performance of our API, we have implemented rate limiting based on IP address and API key.
This is a crucial security measure to prevent abuse and overuse of the API. Here’s how our rate limiting works:
Under your contracted `API KEY`, you have the following **daily rate limit** or Requests Per Day (RPD):
| Service | Free RPD | Premium RPD |
| :------------------------------ | :------: | :---------: |
| ai-powered-search | 300 | - |
| images-templates | 50 | 1000 |
| icons | 100 | 2,500 |
| ai-image-generator classic fast | 100 | 10,000 |
| image-upscaler | N/A | 1250 |
| style-transfer | N/A | 1250 |
| image-relight | N/A | 1250 |
| mystic | N/A | 6,000 |
| kling-pro | 11 | 288 |
| kling-std | 20 | 288 |
| kling-v2 | 5 | 288 |
| kling-elements-pro | 11 | 288 |
| kling-elements-std | 20 | 288 |
### General rate limit
Our general rate limit policy applies based on `IP address` and allows:
* **50 hits per second** over a **5-second period**.
This means that requests originating from the same IP address can make up to 50 API requests per second.
If you exceed this limit, your requests may be throttled or temporarily blocked. The limit resets every 5 seconds.
### Average rate limit
Additionally, we enforce an average rate limit policy based on IP address:
* **10 hits per second** averaged over a **2-minute period**.
This means that over a 2-minute window, the average number of requests from the same IP address should not exceed 10 per second. If you surpass this average rate, your API access might be restricted until your request rate falls back within acceptable limits.
{/* ### Temporary restrictions
Exceeding these rate limits may result in being blocked from making requests for a short period of time (10 minutes).
*/}
{/* ###
### Concurrent limits
Some services have specific limits on the number of concurrent requests that an `API KEY` can make:
| Service | Concurrent limit |
| :------ | :---------------: |
| Kling Pro 1.6 | 3 requests per `API KEY` |
This means that a user cannot have more than 3 requests in progress at the same time for these specific services.
*/}
If your application requires a higher rate limit than what's currently provided, we're here to help!
Please [reach out to our sales](https://www.freepik.com/api#contact) team with details about your use case and expected traffic. We will set you up with a custom plan in no time.
# Webhooks
Source: https://docs.freepik.com/webhooks
Webhooks are a powerful way to connect different systems and services. Learn about webhooks and how to integrate them securely.
### What are webhooks?
Webhooks are a way for one system to send real-time data to another system. They are a powerful tool for integrating different services and automating workflows. With webhooks, you can receive notifications, updates, and data from external systems without having to poll for changes.
### How do webhooks work?
Webhooks work by allowing you to register a URL with a service that supports them. When an event occurs in the service, it sends an HTTP POST request to the registered URL with relevant data. The receiving system can then process the data and take appropriate actions based on the event.
### Why use webhooks?
Webhooks offer several advantages over traditional polling-based methods:
* **Real-time updates**: Webhooks provide instant notifications, allowing you to react to events as they happen.
* **Efficiency**: They reduce the overhead of constant requests by delivering data only when an event occurs.
* **Automation**: Webhooks trigger automatic workflows, reducing manual processes and streamlining tasks.
* **Seamless integration**: They facilitate easy data exchange between systems, enabling efficient communication between different platforms.
### Common use cases for webhooks
Webhooks are widely used in the following scenarios:
* **Notifications**: Sending real-time alerts and updates to users or systems.
* **Data synchronization**: Ensuring that data remains consistent across multiple platforms.
* **Workflow automation**: Initiating tasks like sending emails, updating databases, or processing transactions based on specific events.
By using webhooks, you can streamline your workflows, improve efficiency, and create seamless integrations between different systems.
## Webhook security
### Why webhook security is important?
Webhooks are a powerful way to connect different systems and services. They allow you to send real-time data from one system to another. However, with great power comes great responsibility. Webhooks can be a security risk if not implemented correctly, as they can be exploited by attackers to send malicious data to your system.
### Webhook security headers
To ensure the integrity and authenticity of incoming webhook requests, we deliver three headers with each request:
* `webhook-id`: A unique identifier for the webhook request. This helps to detect and prevent replay attacks.
* `webhook-timestamp`: A timestamp indicating when the webhook request was sent. This is used to ensure that the request is recent and prevents replay attacks within a specific time window.
* `webhook-signature`: A signature generated using a secret key. This is used to verify the authenticity of the request, ensuring that it was sent by a trusted source.
### Generating the string to sign for verification
You must generate a content string that will be signed and verified. This content is created by concatenating the `webhook-id`, `webhook-timestamp`, and the request body with a period (`.`) separator. You can do this by following these steps:
1. **Retrieve the headers**: Extract the `webhook-id` and `webhook-timestamp` from the request headers.
2. **Access the request body**: Obtain the raw body of the webhook request.
3. **Concatenate the values**: Combine the `webhook-id`, `webhook-timestamp`, and body into a single string using the format mentioned earlier.
Here is an example of how you can generate the content to sign in Python:
```python python.py
content_to_sign = f"{webhook_id}.{webhook_timestamp}.{body}"
```
```javascript javascript.js
const contentToSign = `${webhookId}.${webhookTimestamp}.${body}`;
```
```php php.php
$content_to_sign = "$webhook_id.$webhook_timestamp.$body";
```
```java java.java
String contentToSign = webhookId + "." + webhookTimestamp + "." + body;
```
### Obtaining the secret key
The secret key is a shared secret between your system and the webhook provider. It is used to generate the signature and verify the authenticity of the request. Make sure to keep the secret key secure and never expose it in your code or configuration files.
To obtain the secret key, you can go to the [User Dashboard](https://www.freepik.com/developers/dashboard/api-key) and generate a new secret key. Copy the secret key and store it securely in your system.
### Generating the signature
For the webhook signature, we use HMAC-SHA256 as the hashing algorithm. You can generate the signature by following these steps:
1. Encode the secret key as bytes.
2. Obtain the HMAC-SHA256 hash as bytes of the content to sign using the secret key.
3. Encode the hash in base64 to get the signature.
Here is an example of how you can generate the signature in Python:
```python python.py
import hmac
import hashlib
import base64
def generate_signature(secret_key, content_to_sign):
secret_key_bytes = secret_key.encode()
hmac_bytes = hmac.new(secret_key_bytes, content_to_sign.encode(), hashlib.sha256).digest()
signature = base64.b64encode(hmac_bytes).decode()
return signature
```
```javascript javascript.js
const crypto = require('crypto');
function generateSignature(secretKey, contentToSign) {
const secretKeyBytes = Buffer.from(secretKey, 'utf-8');
const hmac = crypto.createHmac('sha256', secretKeyBytes);
hmac.update(contentToSign);
const signature = hmac.digest('base64');
return signature;
}
```
```php php.php
function generateSignature($secretKey, $contentToSign) {
$secretKey = base64_decode($secretKey);
$hmac = hash_hmac(
'sha256',
$contentToSign,
$secretKey,
true
);
$signature = base64_encode($hmac);
return $signature;
}
```
```java java.java
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
public static String generateSignature(String secretKey, String contentToSign) throws Exception {
byte[] secretKeyBytes = secretKey.getBytes("UTF-8");
Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKeyBytes, "HmacSHA256");
mac.init(secretKeySpec);
byte[] hmacBytes = mac.doFinal(contentToSign.getBytes("UTF-8"));
String signature = Base64.getEncoder().encodeToString(hmacBytes);
return signature;
}
```
The obtained signature must be compared with the `webhook-signature` header in the incoming request to verify the authenticity of the request. If the signatures match, the request is considered valid, and you can process it further.
The `webhook-signature` header is composed of a list of space-delimited signatures and their corresponding version identifiers. This allows you to rotate the secret key without breaking existing webhook integrations. For example, the header might look like this:
```
v1,signature1 v2,signature2
```
You should iterate over the list of signatures and verify each one using the corresponding secret key version. If any of the signatures match, the request is considered valid. For example, you can implement this logic in Python as follows:
```python python.py
def verify_signature(generated_signature, header_signatures):
for signature in header_signatures.split():
version, expected_signature = signature.split(',')
if expected_signature == generated_signature:
return True
return False
```
```javascript javascript.js
function verifySignature(generatedSignature, headerSignatures) {
const signatures = headerSignatures.split(' ');
for (const signature of signatures) {
const [version, expectedSignature] = signature.split(',');
if (expectedSignature === generatedSignature) {
return true;
}
}
return false;
}
```
```php php.php
function verifySignature($generatedSignature, $headerSignatures) {
$signatures = explode(' ', $headerSignatures);
foreach ($signatures as $signature) {
list($version, $expectedSignature) = explode(',', $signature);
if ($expectedSignature === $generatedSignature) {
return true;
}
}
return false;
}
```
```java java.java
public static boolean verifySignature(String generatedSignature, String headerSignatures) {
String[] signatures = headerSignatures.split(" ");
for (String signature : signatures) {
String[] parts = signature.split(",");
String version = parts[0];
String expectedSignature = parts[1];
if (expectedSignature.equals(generatedSignature)) {
return true;
}
}
return false;
}
```
By following these steps, you can ensure the security of your webhook implementation and protect your system from unauthorized access and data tampering.