API
If you're looking for an API, you can choose from your desired programming language.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
api_key = "YOUR_API_KEY"
url = "https://api.segmind.com/v1/flux-kontext-dev"
# Prepare data and files
data = {}
files = {}
data['seed'] = 42
data['prompt'] = "Replace the background with a bokeh light effect, zooming in on the subject, keeping the personâs pose, position, scale, and camera angle identical. Only change the surrounding environment. "
data['guidance'] = 7
# For parameter "input_image", you can send a raw file or a URI:
# files['input_image'] = open('IMAGE_PATH', 'rb') # To send a file
data['input_image'] = 'https://images.segmind.com/generations/901b78cd-381a-4284-8391-306d4c7409e1/6852c6602b5db2d623cc373cfa699b55.webp' # To send a URI
data['aspect_ratio'] = "match_input_image"
data['output_format'] = "png"
data['output_quality'] = 90
data['num_inference_steps'] = 35
data['disable_safety_checker'] = False
headers = {'x-api-key': api_key}
# If no files, send as JSON
if files:
response = requests.post(url, data=data, files=files, headers=headers)
else:
response = requests.post(url, json=data, headers=headers)
print(response.content) # The response is the generated image
Attributes
Set a random seed for reproducibility. Use for consistent results; leave blank for randomness.
Describe generation task or image edits. Use clear and specific instructions for best results.
Determines adherence to prompt. Use higher values for more precision.
min : 0,
max : 10
Reference image for context. Use jpeg, png, gif, or webp for varied image integrations.
Select aspect ratio. Match input for consistency; use fixed for specific dimensions.
Allowed values:
Specify output format. Use webp for compressibility; jpg or png for compatibility.
Allowed values:
Determine output image quality. Use high values for detailed images and adjustments for jpg outputs.
min : 0,
max : 100
Specify number of processing steps. Use more steps for complex images and fewer for faster results.
min : 4,
max : 50
Turn off NSFW filter. Use with caution if needing unrestricted content.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
FLUX.1 Kontext â Text-to-Image & Image Editing Model
What is FLUX.1 Kontext?
FLUX.1 Kontext is an advanced generative AI model that unifies image generation and in-context editing in a single framework. Leveraging state-of-the-art generative flow matching, it combines semantic cues from both text prompts and reference images to create new views and apply precise edits. Unlike traditional pipelines, FLUX.1 Kontext maintains object and character consistency across multiple editing steps, making it ideal for iterative design loops and rapid prototyping.
Key Features
- Generative Flow Matching: Integrates text and image inputs to produce coherent outputs.
- In-Context Editing: Refine or transform specific regions without losing global style.
- Character & Object Consistency: Preserve identity through multiple edit cycles.
- High Throughput: Faster inference than most current state-of-the-art systems.
- Validated on KontextBench: Excels at local/global edits, style transfer, character referencing, and text-based modifications.
- Interactive Prototyping: Suitable for real-time feedback in creative workflows.
Best Use Cases
- Concept Art & Illustration: Rapidly iterate character designs or environment sketches.
- Style Transfer: Apply new artistic styles while retaining scene structure.
- Product Mockups: Integrate branding elements into promotional imagery.
- Storyboarding & Previsualization: Maintain narrative consistency through multiple frames.
- Creative Ad Campaigns: Quickly generate varied outputs based on a single reference.
Prompt Tips and Output Quality
- Craft Clear Prompts: Use specific, detailed instructions (e.g., âCreate a cyberpunk cityscape at dusk with neon reflectionsâ).
- Reference Images: Supply
input_image
in JPEG, PNG, GIF, or WEBP to anchor edits. - Guidance Scale (0â10): Default 7; higher values yield tighter adherence to prompt.
- Num_Inference_Steps (4â50): Default 35; increase for fine details, reduce for speed.
- Aspect Ratio: Choose from presets (1:1, 16:9, 21:9, etc.) or use
match_input_image
. - Output_Format & Quality: Select
png
,jpg
, orwebp
; default quality is 90 for high fidelity. - Seed Control: Set a custom random seed for reproducible results (default 42).
FAQs
Q: How does FLUX.1 Kontext ensure consistency across edits?
A: By leveraging generative flow matching, the model retains semantic embeddings for characters and objects, preserving their appearance step after step.
Q: What image formats are supported?
A: FLUX.1 Kontext accepts JPEG, PNG, GIF, and WebP as input_image
sources.
Q: Can I control the level of creativity versus accuracy?
A: Yes. Adjust the guidance
parameter (0â10) to balance prompt fidelity and creative freedom.
Q: Whatâs the recommended number of inference steps?
A: We suggest 25â35 steps for most workflows. Fewer steps speed up generation; more steps enhance detail.
Q: Is FLUX.1 Kontext suitable for style transfer?
A: Absolutely. It outperforms benchmarks on global and local style transfer tasks within KontextBench.
Q: How fast is the model?
A: Optimized for interactive use, FLUX.1 Kontext delivers results significantly faster than comparable state-of-the-art systems, supporting rapid prototyping and real-time editing.
Integrated via Replicate. Commercial use is allowed.
Other Popular Models
sdxl-img2img
SDXL Img2Img is used for text-guided image-to-image translation. This model uses the weights from Stable Diffusion to generate new images from an input image using StableDiffusionImg2ImgPipeline from diffusers

fooocus
Fooocus enables high-quality image generation effortlessly, combining the best of Stable Diffusion and Midjourney.

insta-depth
InstantID aims to generate customized images with various poses or styles from only a single reference ID image while ensuring high fidelity

sdxl1.0-txt2img
The SDXL model is the official upgrade to the v1.5 model. The model is released as open-source software
