KIE.AI
English
  • English
  • Chinese
English
  • English
  • Chinese
Support
English
  • English
  • Chinese
MarketVeo3.1 APISuno API4o Image APIFlux Kontext API
Runway APILuma APIFile Upload APICommon API
MarketVeo3.1 APISuno API4o Image APIFlux Kontext API
Runway APILuma APIFile Upload APICommon API
  1. Flux Kontext API
  • Flux Kontext API Quickstart
  • Image Generation or Editing Callbacks
  • Generate or Edit Image
    POST
  • Get Image Details
    GET
English
  • English
  • Chinese
Support
English
  • English
  • Chinese
MarketVeo3.1 APISuno API4o Image APIFlux Kontext API
Runway APILuma APIFile Upload APICommon API
MarketVeo3.1 APISuno API4o Image APIFlux Kontext API
Runway APILuma APIFile Upload APICommon API
  1. Flux Kontext API

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:
cURL
Node.js
Python
Response:
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_flux_abc123"
  }
}

2. Edit an Existing Image#

Modify an existing image using text prompts:
cURL
Node.js
Python

3. Check Generation Status#

Use the returned taskId to monitor progress:
cURL
Node.js
Python
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:
JavaScript
Python

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:
Content Policy Violations (Code 400)
Safety Tolerance Out of Range (Code 500)
Rate Limiting (Code 429)

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#

ParameterTypeDescriptionDefault
promptstringRequired. Text description for generation/editing-
aspectRatiostringOutput image aspect ratio16:9
modelstringflux-kontext-pro or flux-kontext-maxflux-kontext-pro
outputFormatstringjpeg or pngjpeg

Optional Parameters#

ParameterTypeDescriptionDefault
inputImagestringURL for image editing mode-
enableTranslationbooleanAuto-translate non-English promptstrue
promptUpsamplingbooleanAI prompt enhancementfalse
safetyToleranceintegerContent moderation level2
callBackUrlstringWebhook notification URL-
uploadCnbooleanUse China servers for uploadfalse
watermarkstringWatermark identifier-

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@kie.ai
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!
Next
Image Generation or Editing Callbacks
Built with