Skip to main content
POST
/
generate
/
k
/
flux-kontext
Flux Kontext Image Generation/Edit
curl --request POST \
  --url https://api.sinancode.com/v1/generate/k/flux-kontext \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "a beautiful landscape with mountains",
  "aspect_ratio": "16:9",
  "enable_translation": true,
  "input_image": "https://example.com/input.jpg",
  "model": "flux-kontext-pro",
  "output_format": "jpeg",
  "prompt_upsampling": false,
  "safety_tolerance": 2,
  "upload_cn": false,
  "watermark": ""
}
'
{
  "task_id": "01234567-89ab-cdef-0123-456789abcdef"
}
Generate and edit images using Black Forest Labs’ FLUX.1 Kontext model with context-aware capabilities. Key Features:
  • Context Understanding - Modify existing images through text instructions without complex workflows
  • Character Consistency - Maintain visual features of characters/objects across multiple scenes
  • Local Editing - Precisely modify specific areas of an image without affecting other parts
  • Fast Iteration - Generate 1MP images in 3-5 seconds, 8x faster than GPT-Image

Authorizations

Authorization
string
header
required

Please use your API Token for authentication

Body

application/json

Task parameters

prompt
string
required

Prompt (required, supports English)

Minimum string length: 1
Example:

"a beautiful landscape with mountains"

aspect_ratio
enum<string>
default:auto

Aspect ratio (optional, default 16:9)

Available options:
auto,
21:9,
16:9,
4:3,
1:1,
3:4,
9:16
Example:

"16:9"

enable_translation
boolean
default:true

Enable automatic translation (optional, default true)

Example:

true

input_image
string

Input image URL (optional, for editing mode)

Example:

"https://example.com/input.jpg"

model
enum<string>
default:flux-kontext-pro

Model version (optional, default flux-kontext-pro)

Available options:
flux-kontext-pro,
flux-kontext-max
Example:

"flux-kontext-pro"

output_format
enum<string>
default:jpeg

Output format (optional, default jpeg)

Available options:
jpeg,
png
Example:

"jpeg"

prompt_upsampling
boolean
default:false

Enable prompt enhancement (optional, default false)

Example:

false

safety_tolerance
integer
default:2

Safety tolerance level (optional, 0-6, default 2)

Required range: 0 <= x <= 6
Example:

2

upload_cn
boolean

Use China mainland server for upload (optional)

Example:

false

watermark
string

Watermark identifier (optional)

Example:

""

Response

OK

task_id
string
required

Task ID

Example:

"01234567-89ab-cdef-0123-456789abcdef"