Overview
High-quality image generation using the Flux 2 Pro model. Delivers strong results for both creative and photorealistic use cases with fast inference.
Primary Endpoint
/api/v1/userFlux2/startGenerate images from text or edit existing images with Flux 2 Pro or Flux 3 Klein. Select the version with `model`. Flux 3 Klein supports 1K, 2K, and 4K output. For 1K, each reference image after the first increases the cost. The returned `coins` field reports the credits charged for the task. **Features:** - Text-to-Image generation with advanced prompt understanding - Image-to-Image editing (up to 8 references for Flux 2 Pro; up to 10 for Flux 3 Klein) - Character consistency across multiple images - Text rendering within images - High-quality output with professional-grade results **Processing Time:** - Usually 20-60 seconds **Output:** - Images are stored in R2 storage (3days-apac bucket) and expire 3 days after the task is created (createdAt + 3 days, same as `expirationDate`) - Download and persist the result to your own storage before it expires; `image_url` is a temporary CDN URL, not a permanent asset address - Expired tasks are omitted from the list endpoint; the detail endpoint still returns the record with `isExpired: true`, but its media URLs are no longer downloadable. ### Request - Send a valid bearer token. The server evaluates the operation in the authenticated caller's access context. - Send an `application/json` body. Required fields: `name`, `prompt`. - API-token callers may include `webhook_url` and `webhook_token` for best-effort terminal-state notifications; ordinary JWT/cookie calls ignore these fields. ### Behavior - This is an asynchronous operation: a successful submission creates a task and returns before processing finishes. - Persist the returned task identifier and use the corresponding detail or list operation to observe progress. - Treat the detail endpoint as the source of truth even when webhook delivery is enabled. ### Response - A `200` response confirms task acceptance; it does not by itself mean media generation has completed. - Retain the returned identifier and wait for a documented terminal status before using output URLs. - JSON object responses, including error responses, normally carry a top-level `trace_id` string for this request; include it when contacting support. It is not a task identifier. - Do not infer undocumented fields or statuses; clients should tolerate additional response properties. ### Errors - `400` — Invalid request parameters. - `401` — Unauthorized - Invalid or missing token. - `402` — Insufficient credits. - `422` — Content moderation rejected the `input_images`. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`. - `500` — Internal server error. ### Related Operations - `GET /api/v1/userFlux2/list` — Get Flux 2 Pro task list. - `GET /api/v1/userFlux2/detail/{id}` — Get task details. - `DELETE /api/v1/userFlux2/{id}` — Delete Flux 2 Pro task. Authentication: set header Authorization: Bearer <token> (supports user JWT or sk_ API token).
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ai_sharing_consent | object | No | Consent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged. The recipient example below is for the default Flux 2 Pro model. When supplied, receipts for Flux 3 Klein must include KIE, Black Forest Labs, and ByteDance as the fallback provider for technical failures. |
| ai_sharing_consent.version | enum: 2026-11-12 | Yes | - |
| ai_sharing_consent.recipients | array<string> | Yes | - |
| model | enum: flux-2-pro | flux-3-klein | No | Select the Flux model version. Flux 3 Klein supports up to ten reference images and 4K output.; default: "flux-2-pro" |
| name | string | Yes | Name of the image generation task |
| prompt | string | Yes | Text prompt for image generation or editing instruction. |
| creation_mode | enum: text-to-image | image-edit | No | Optional compatibility field for history and mode reporting; callers may omit it. The server ignores any supplied value and records `image-edit` when `input_images` contains a valid HTTP(S) image URL, otherwise `text-to-image`. It is not forwarded to the model provider. |
| input_images | array<string> | No | Array of input image URLs for image-to-image editing or multi-image composition (up to 8 for Flux 2 Pro, 10 for Flux 3 Klein). When provided, automatically switches to image-to-image mode for character consistency. |
| aspect_ratio | enum: auto | 1:1 | 16:9 | 9:16 | 4:3 | 3:4 | 2:3 | 3:2 | 21:9 | 9:21 | custom | match_input_image | No | Flux 3 also supports auto for image editing, 21:9 and 9:21. Flux 2 supports custom and match_input_image.; default: "9:16" |
| resolution | enum: 1K | 2K | 4K | No | Resolution of the generated image. - 1K: ~1 megapixel - 2K: ~2 megapixels - 4K: Flux 3 Klein only ; default: "1K" |
| force_generate | boolean | No | Force generation even if NSFW content is detected. Defaults to true for API users, false for web users; default: true |
| minor_suspected_skip | boolean | No | Confirm retry after the suspected-minor soft block; hard blocks remain enforced.; default: false |
| webhook_url | string | No | HTTPS URL to receive task.completed / task.failed notifications. Best-effort delivery, single attempt, no retries; clients should treat the detail API as the source of truth.; maxLength: 2048 |
| webhook_token | string | No | Optional plaintext token returned in the X-A2e-Webhook-Token header so receivers can verify the request originated from a2e.; maxLength: 256 |
Request schema and conditional rules
{
"allOf": [
{
"type": "object",
"properties": {
"ai_sharing_consent": {
"type": "object",
"description": "Consent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged. The recipient example below is for the default Flux 2 Pro model. When supplied, receipts for Flux 3 Klein must include KIE, Black Forest Labs, and ByteDance as the fallback provider for technical failures.",
"required": [
"version",
"recipients"
],
"properties": {
"version": {
"type": "string",
"enum": [
"2026-11-12"
]
},
"recipients": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"A2E",
"Alibaba Cloud",
"KIE",
"Black Forest Labs"
]
}
}
},
"model": {
"type": "string",
"enum": [
"flux-2-pro",
"flux-3-klein"
],
"default": "flux-2-pro",
"description": "Select the Flux model version. Flux 3 Klein supports up to ten reference images and 4K output."
},
"name": {
"type": "string",
"description": "Name of the image generation task",
"example": "Elon Musk and Mark Zuckerberg boxing"
},
"prompt": {
"type": "string",
"description": "Text prompt for image generation or editing instruction.\n",
"example": "Elon Musk and Mark Zuckerberg boxing in a professional ring"
},
"creation_mode": {
"type": "string",
"enum": [
"text-to-image",
"image-edit"
],
"description": "Optional compatibility field for history and mode reporting; callers may omit it. The server ignores any supplied value and records `image-edit` when `input_images` contains a valid HTTP(S) image URL, otherwise `text-to-image`. It is not forwarded to the model provider."
},
"input_images": {
"type": "array",
"items": {
"type": "string"
},
"description": "Array of input image URLs for image-to-image editing or multi-image composition (up to 8 for Flux 2 Pro, 10 for Flux 3 Klein).\nWhen provided, automatically switches to image-to-image mode for character consistency.\n",
"example": [
"https://example.com/reference1.jpg",
"https://example.com/reference2.jpg"
]
},
"aspect_ratio": {
"type": "string",
"description": "Flux 3 also supports auto for image editing, 21:9 and 9:21. Flux 2 supports custom and match_input_image.",
"enum": [
"auto",
"1:1",
"16:9",
"9:16",
"4:3",
"3:4",
"2:3",
"3:2",
"21:9",
"9:21",
"custom",
"match_input_image"
],
"default": "9:16",
"example": "9:16"
},
"resolution": {
"type": "string",
"description": "Resolution of the generated image.\n- 1K: ~1 megapixel\n- 2K: ~2 megapixels\n- 4K: Flux 3 Klein only\n",
"enum": [
"1K",
"2K",
"4K"
],
"default": "1K",
"example": "1K"
},
"force_generate": {
"type": "boolean",
"description": "Force generation even if NSFW content is detected. Defaults to true for API users, false for web users",
"default": true
},
"minor_suspected_skip": {
"type": "boolean",
"default": false,
"description": "Confirm retry after the suspected-minor soft block; hard blocks remain enforced."
}
},
"required": [
"name",
"prompt"
]
},
{
"$ref": "#/components/schemas/WebhookInput"
}
]
}Response Fields
- code: enum: 0
- data: object
- data.hasRefundCoin: boolean
- Stored refund flag; true does not confirm crediting while refund_pending is true. Omitted when unknown, including legacy records without a stored flag.
- data.refund_pending: boolean
- True means refund pending resolution and takes precedence over hasRefundCoin. Explicit false is preserved; omitted when unknown, including legacy records without a stored flag.
- data._id: string
- Task ID
- data.name: string
- data.prompt: string
- data.input_images: array<string>
- data.aspect_ratio: string
- data.resolution: string
- data.current_status: enum: initialized | processing
- data.reference_id: string
- Unique reference ID for tracking
- data.coins: integer
- Credits deducted for this task
- data.createdAt: string
- data.expirationDate: string
- Date when the generated image expires (createdAt + 3 days)
- data.expirationDays: integer
- Retention period in days
- data.remainingDays: integer
- Days left before the result expires
- data.isExpired: boolean
- Whether the result has expired
- trace_id: string
- Trace ID of this HTTP request. Include it when contacting support about this request. It is generated per request and is not a task identifier; use the returned task `_id` to query results.
- data.nsfw_detected: enum: true
- data.message: string
- data.severity: enum: low | medium | high
- data.detected_categories: array<string>
Request Example
curl -X POST "https://headswap.app/api/v1/userFlux2/start" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Native Flux image",
"prompt": "A quiet mountain landscape",
"model": "flux-3-klein",
"ai_sharing_consent": {
"version": "2026-11-12",
"recipients": [
"A2E",
"Alibaba Cloud",
"KIE",
"Black Forest Labs",
"ByteDance"
]
}
}'Related Endpoints
Responses
Flux 2 Pro task started successfully or NSFW content detected
Invalid request parameters
Unauthorized - Invalid or missing token
Insufficient credits
Content moderation rejected the `input_images`. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`.
Internal server error