Skip to content
中文
Black Forest Labs · Model API

Flux Kontext API

Flux Kontext API with VezAPI. Explore model capabilities, credit pricing, request parameters, and integration examples.

Text to ImageImage to Image

Flux Kontext API documentation

Integrate Flux Kontext with your VezAPI key. The operations below share the same authentication and account balance.

Base URL: https://api.vezapi.com
Send Authorization: Bearer YOUR_VEZAPI_KEY. Use a unique Idempotency-Key for each submission; reuse it only when checking the same request.

Generate or Edit Image

POST/api/v1/jobs/createTask

Model IDs: flux1-kontext

ParameterTypeDescription & constraints
model
required
string

Model version to use for generation.

Values: "flux1-kontext"

Default: "flux1-kontext"

callBackUrl
optional
string

The URL to receive image generation or editing task completion updates. Optional but recommended for production use. - System will POST task status and results to this URL when image generation or editing completes - Callback includes generated image URLs and task information for both text-to-image and image editing operations - Your callback endpoint should accept POST requests with JSON payload containing image results - For detailed callback format and implementation guide, see [Image Generation/Editing Callbacks]([see VezAPI documentation]) - Alternatively, use [Get Task Details](/market/common/get-task-detail) to poll task status - To ensure callback security, see [Webhook Verification Guide](/common-api/webhook-verification) for signature verification implementation

input
required
object
input.prompt
required
string

Text prompt describing the desired image or edit. Required for both generation and editing modes. - Should be detailed and specific - For image editing, describe the desired changes - For image generation, describe the complete scene - IMPORTANT: Only English language is supported

input.model
optional
string

Model tier: flux-kontext-pro (default) or flux-kontext-max (higher quality, higher price).

Values: "flux-kontext-pro", "flux-kontext-max"

Default: "flux-kontext-pro"

input.enable_translation
optional
boolean

Whether to enable automatic translation feature. - Since prompt only supports English, when this parameter is true, the system will automatically translate non-English prompts to English - If your prompt is already in English, you can set this to false - Default value: true

input.upload_cn
optional
boolean

(Optional) Specifies the server region for image upload. Set to true to use servers in China, false to use non-China servers. Choose based on your geographical location for optimal upload speeds.

input.input_image
optional
string

URL of the input image for editing mode. Required when editing an existing image. - Must be a valid image URL - Image must be accessible to the API server

input.aspect_ratio
optional
string

Output image aspect ratio. You Applicable in both text-to-image generation and image editing modes. For **text-to-image generation** , the output image will follow the specified aspect ratio. For **image editing** , if aspect_ratio is provided, the edited image will follow that ratio. If not provided, the image will retain its original aspect ratio. Supported Aspect Ratios: | Ratio | Format Type | Common Use Cases | |-------|-------------|-----------------| | 21:9 | Ultra-wide | Cinematic displays, panoramic views | | 16:9 | Widescreen | HD video, desktop wallpapers | | 4:3 | Standard | Traditional displays, presentations | | 1:1 | Square | Social media posts, profile pictures | | 3:4 | Portrait | Magazine layouts, portrait photos | | 9:16 | Mobile Portrait | Smartphone wallpapers, stories | Set this field explicitly to get a specific ratio.

Values: "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"

input.output_format
optional
string

Output image format.

Values: "jpeg", "png"

Default: "jpeg"

input.prompt_upsampling
optional
boolean

- If true, performs upsampling on the prompt - May increase processing time

Default: false

input.safety_tolerance
optional
integer

**For Image Generation Mode:** Moderation level for inputs and outputs. Value ranges from 0 (most strict) to 6 (more permissive). **For Image Editing Mode:** Moderation level for inputs and outputs. Value ranges from 0 (most strict) to 2 (balanced). Default: 2

Values: 0, 1, 2, 3, 4, 5, 6

Default: 2

input.watermark
optional
string

Watermark identifier to add to the generated image. - Optional - If provided, a watermark will be added to the output image

Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "callBackUrl": "https://example.com/input.png",
  "input": {
    "aspect_ratio": "16:9",
    "enable_translation": true,
    "output_format": "jpeg",
    "prompt": "A serene mountain landscape at sunset with a lake reflecting the orange sky",
    "prompt_upsampling": false
  },
  "model": "flux1-kontext"
}'
Responses and errors

HTTP 200

Request successful

ParameterTypeDescription & constraints
code
optional
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

Values: 200, 401, 402, 404, 422, 429, 455, 500, 501, 505

msg
optional
string

Error message when code != 200

data
optional
object
data.taskId
optional
string

Task ID, can be used with [Get Task Details](/market/common/get-task-detail) to query task status

HTTP 500

Server error.

ParameterTypeDescription & constraints
code
required
integer

Response status code - **200**: Success - Request has been processed successfully - **401**: Unauthorized - Authentication credentials are missing or invalid - **402**: Insufficient Credits - Account does not have enough credits to perform the operation - **404**: Not Found - The requested resource or endpoint does not exist - **408**: Timeout - No result has been returned for over 10 minutes. - **422**: Validation Error - The request parameters failed validation checks - **429**: Rate Limited - Request limit has been exceeded for this resource - **455**: Service Unavailable - System is currently undergoing maintenance - **500**: Server Error - An unexpected error occurred while processing the request - **501**: Generation Failed - Content generation task failed - **505**: Feature Disabled - The requested feature is currently disabled

msg
required
string

Response message, error description when failed

data
required
object

Task status and callbacks

For asynchronous tasks, keep the returned taskId. Query GET /api/v1/jobs/recordInfo?taskId=... or provide callBackUrl when creating the task. Only the account that created a task can access it or derive new resources from it.

A timeout can mean the submission was accepted. Inspect the existing request in your dashboard; do not create another task automatically. Callback delivery is retried and may arrive more than once. Deduplicate with X-VezAPI-Event-Id.

Files, logs and billing

Generated media normally follows a 14-day provider lifetime; uploaded files expire after 24 hours. Save the files you need before expiration. VezAPI streams registered files without keeping a permanent media library. Request logs are retained for two calendar months.

Credits are reserved before submission. Final deductions match actual discounted consumption one for one. Unknown usage pauses new paid requests. If available funds cannot cover final usage while protecting other reservations, settlement stays pending until funded; model usage cannot make the wallet negative. Time-based inputs require server-side metadata reads; a failed read prevents submission.

Open full documentation →

Flux Kontext API pricing

Rates below are reference estimates; final deductions equal actual discounted consumption, one for one. At the standard pack rate, 1,000 credits ≈ $10. Larger packs reduce the effective credit price.

SpecificationCreditsUnitUSD reference
Black Forest Labs flux1-kontext, text-to-image, Pro5.0per image$0.05
Black Forest Labs flux1-kontext, text-to-image, Max10.0per image$0.1