Skip to content

freepik-company/ai-agents-hackathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Freepik API

Hi!

We've created this repo with a lot of examples of how to use the different tools available in the Freepik API. As there are many different tools it could be hard to find the one you need, so in this README you'll find a summary of the tools available organized by use case and and highlighting how different each of the tools is.

Installation

Python

Create a virtual environment and install the dependencies:

python -m venv <path-to-your-virtual-environment>
source <path-to-your-virtual-environment>/bin/activate
pip install -r requirements.txt

To run the examples you need to have the API key set up. To do that you have to create a .env file in the root of the project and add the API key to it with this format:

FREEPIK_API_KEY=<your_api_key>

Curl

To run the curl examples you will need to export the API key to the environment variable by running this command in the terminal:

export FREEPIK_API_KEY=<your_api_key>

Image tools

Stock resources

Freepik offers a wide range of stock resources, including images, icons and templates. Using the API you can search for resources and download them.

Search resources tools
Tool Description Links
Images and templates Search for images and templates Docs - Python examples - Curl examples
Download resources tools
Tool Description Links
Download image and template Download an image or a template by its id Docs - Python examples - Curl examples
Download icon Download an icon by its id Docs - Python examples - Curl examples

Text to image generation

Freepik offers a wide range of text to image tools, including classic fast, flux dev, and more. Using the API you can generate images from text. In the table below you'll find a summary of the tools available and how they differ from each other.

Text to image generation tools
Tool Description Important differences Links
Classic fast Generates images from text using the classic fast model. It is synchronous and returns the image very fast. It also allows you to add style, effects and colors to the image. Docs - Python examples - Curl examples
Flux dev Generates images from text using the flux dev model. It allows you to add style, effects and colors to the image. It has good prompt adherence. It is asynchronous. Docs - Python examples
Flux pro v1.1 Generates images from text using the flux pro v1.1 model. Pure precision. It is asynchronous. Docs - Python example
Hyperflux Another flavour of flux model that generates only in 8 steps. It allows you to add style, effects and colors to the image. It is asynchronous. Docs - Python examples
Mystic Generates 2K images from text. Add style and colors to the image. Add a style reference image and a structure reference image. Generate directly in 1K, 2K or 4K resolution. Select output aspect ratio. It is asynchronous. Docs - Python examples
Google Imagen 3 High quality images from text. It allows you to add style and colors to the image. It has many moderation options. It is asynchronous. Docs - Python examples
Seedream Generates more creative and aesthetics images Select output aspect ratio. It is asynchronous. Docs - Python example
Seedream 4 Generates more creative and aesthetics images Select output aspect ratio. It is asynchronous. Docs - Python example
Text to image generation and editing tools

You can use reference images to edit them or to generate new images from them.

Tool Description Important differences Links
Seedream 4 edit Edit an image using a reference image or generate a new image from a reference images Select output aspect ratio. Can use multiple reference images. Can edit a given image based on another reference image. It is asynchronous. Docs - Python example
Google Nano Banana Edit an image using a reference image or generate a new image from a reference images Can use multiple reference images. Can edit a given image based on another reference image. It is asynchronous. Docs - Python example

Image Editing

There are many tools to edit images, including style transfer, reimagine, and more. Using the API you can edit images.

Image editing tools
Tool Description Important differences Links
Magnific creative Upscale an image using a reference image in a creative way Upscale an image to 4x, 8x or 16x resolution. It is creative what means it can change the image in a creative way by adding details and improving the image. It is asynchronous. Docs - Python example
Magnific precision Upscale an image using a reference image in a non creative way It doesn't make up anything, pure precision. You can add grain to make the result more realistic. Can modify the sharpening. It is asynchronous. Docs - Python example
Remove Background Remove the background of an image It is synchronous. Docs - Python example
Image expand Expand an image from the current size to a bigger size It is asynchronous. Docs - Python example
Style transfer Transfer the style of a reference image to an image Use an image as style reference. Control the influence of the style adn the influence of the structure. It is asynchronous. Docs - Python example
Relight Relighing an image using a reference image and a prompt Use an image or/and a prompt as light reference. Control the influence of the light. Control many other parameters of the generation. Apply some predefinied styles. It is asynchronous. Docs - Python example
Reimagine Create variations of a reference image Control the variatioon level. Control the aspect ratio. It is synchronous. Docs - Python example

Video tools

Stock resources

Freepik offers a wide range of stock video. Using the API you can search for resources and download them.

Search resources tools
Tool Description Links
Videos Search for videos Docs - Python examples - Curl examples
Download resources tools
Tool Description Links
Download video Download a video by its id Docs - Python examples - Curl examples

Video generation

Freepik offers a wide range of video generation tools, including kling, seedance, and more. Using the API you can generate videos from images or text.

Image to video generation tools

All of them are asynchronous.

First and last frame conditioning

Tool Important differences Links
Kling v1.6 pro Negative prompt to improve quality. Docs - Python example
Kling v2.1 pro Negative prompt to improve quality. Better quality than 2 Docs - Python example
Pixverse v5 transition Can generate different resolutions. Can apply some predefinied styles. Negative prompt to improve quality. Docs - Python example
Minimax Hailuo 02 768p It has automatic prompt optimizer. Resolution 768p. Docs - Python example
Minimax Hailuo 02 1080p It has automatic prompt optimizer. Resolution 1080p. Docs - Python example

Only first frame conditioning

Tool Important differences Links
Kling v1.6 std Negative prompt to improve quality. Docs - Python example
Kling v2 Negative prompt to improve quality. Better quality than 1.6 Docs - Python example
Kling v2.1 master Negative prompt to improve quality. Better quality than 2 Docs - Python example
Kling v2.1 std Negative prompt to improve quality. Better quality than 2 Docs - Python example
Kling v2.5 pro Negative prompt to improve quality. Better quality than 2 Docs - Python example
Pixverse v5 Can generate different resolutions. Can apply some predefinied styles. Negative prompt to improve quality. Docs - Python example
Seedance lite Can control de aspect ratio. Can fix the camera during the video. There are 3 different models for each resolution 480p, 720p and 1080p. 480p: Docs - Python example 720p: Docs - Python example 1080p: Docs - Python example
Seedance pro Can control de aspect ratio. Can fix the camera during the video. There are 3 different models for each resolution 480p, 720p and 1080p. Best quality than lite. 480p: Docs - Python example 720p: Docs - Python example 1080p: Docs - Python example
Wan v2.2 Can control de aspect ratio. There are 3 different models for each resolution 480p, 580p and 720p. 480p: Docs - Python example 580p: Docs - Python example 720p: Docs - Python example

Many images with objects to conditioning

Tool Important differences Links
Kling v1.6 pro elements Can use multiple elements on different images to condion the generation. Negative prompt to improve quality. Can control the aspect ratio. Docs - Python example
Kling v1.6 std elements Can use multiple elements on different images to condion the generation. Negative prompt to improve quality. Can control the aspect ratio. Worse quality than pro. Docs - Python example
Text to video generation tools

All of them are asynchronous.

Tool Important differences Links
Minimax Hailuo 02 768p It has automatic prompt optimizer. Resolution 768p. Docs - Python example
Minimax Hailuo 02 1080p It has automatic prompt optimizer. Resolution 1080p. Docs - Python example

Icon tools

Stock resources

Search resources tools
Tool Description Links
Icons Search for icons Docs - Python examples - Curl examples
Download resources tools
Tool Description Links
Download icon Download an icon by its id Docs - Python examples - Curl examples

MCP

Alternatively, you can use the Freepik MCP to use some of the tools directly from the Claude or Cursor chat. You can follow the Freepik MCP documentation to install the MCP depending on the IDE you are using.

As an additional notes:

  • You need to set up the API key in the MCP as well.
  • It is necessary to have node.js installed in your machine to use the MCP.

Tools available in the MCP:

  • create_video_kling_2_1_std
  • create_video_kling_2_1_pro
  • get_kling_2_1_task_status
  • create_image_mystic
  • get_mystic_task_status
  • detect_ai_image
  • search_resources
  • get_resource_detail_by_id
  • download_resource_by_id
  • get_resource_download_formats
  • search_icons
  • get_icon_detail_by_id
  • download_icon_by_id

Extra

To give you some ideas we've prepared a workflow using python to generate a complete advertising campaing from NOTHING! You can see it here

About

Freepik API code examples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published