Skip to main content

Flux Kontext API Quickstart

Get started with the Flux Kontext API in minutes. Learn how to generate images from text and edit existing images using AI.

Welcome to the Flux Kontext API!

This quickstart guide will walk you through the essential steps to start generating and editing images using state-of-the-art AI models.

Overview

Text-to-Image Generation

Create stunning AI images from detailed text descriptions or images

Task Details

Real-time status tracking and webhook callback notifications
Generated images are stored for 14 days and automatically expire after that period.

Authentication

All API requests require authentication via Bearer Token.
1

Get Your API Key

Visit the API Key Management Page to obtain your API key.
2

Add to Request Headers

Include your API key in all requests:
Keep your API key secure and never share it publicly. If compromised, reset it immediately in the management page.

Basic Usage

1. Generate an Image from Text

Start by creating your first text-to-image generation task:
Response:

2. Edit an Existing Image

Modify an existing image using text prompts:

3. Check Generation Status

Use the returned taskId to monitor progress:
Status Values:
  • 0: GENERATING - Task is currently being processed
  • 1: SUCCESS - Task completed successfully
  • 2: CREATE_TASK_FAILED - Failed to create the task
  • 3: GENERATE_FAILED - Task creation succeeded but generation failed

Complete Workflow Example

Here’s a complete example that generates an image and waits for completion:

Advanced Features

Model Selection

Choose the appropriate model based on your needs:

Aspect Ratio Options

Support for various image formats:

Prompt Enhancement

Let the AI optimize your prompts:

Safety Tolerance Control

Adjust content moderation levels:

Using Callbacks

Set up webhook callbacks for automatic notifications:

Learn More About Callbacks

Set up webhook callbacks to receive automatic notifications when your images are ready.

Error Handling

Common error scenarios and how to handle them:

Best Practices

Performance Optimization

  1. Use Callbacks: Set up webhook callbacks instead of polling for better performance
  2. Model Selection: Use flux-kontext-pro for standard tasks, flux-kontext-max for complex scenes
  3. Prompt Engineering: Use detailed, specific prompts for better results
  4. Image Preprocessing: Ensure input images are accessible and optimized
  5. Download Management: Download images promptly as they expire after 14 days
  6. Translation Settings: Set enableTranslation: false if your prompts are already in English

Important Limitations

  • Language Support: Prompts only support English (use enableTranslation: true for auto-translation)
  • Image Storage: Generated images expire after 14 days
  • Original Image URLs: Valid for only 10 minutes after generation
  • Safety Tolerance: Generation mode (0-6), Editing mode (0-2)
  • Input Images: Must be publicly accessible URLs

Supported Parameters

Core Parameters

Optional Parameters

Next Steps

Generate or Edit Images

Learn about all generation and editing parameters and advanced options

Track Progress

Monitor task status and retrieve detailed generation information

Webhook Callbacks

Set up automatic notifications for task completion

Support

Need help? Here are your options:
  • Technical Support: support@apikley.ru
  • API Status: Monitor service health and announcements
  • Documentation: Explore detailed API references
  • Community: Join our developer community for tips and examples
Ready to create amazing AI images? Start with the examples above and explore the full API capabilities!
To find navigation and other pages in this documentation, fetch the llms.txt file at: https://docs.apikley.ru/llms.txt
Rate limits and quotas are enforced by Apikley and may differ from upstream providers.