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/multi-image-kontext-pro"
# Prepare data and files
data = {}
files = {}
data['seed'] = None
data['prompt'] = "A woman is taking a selfie with the man in front of the Taj Mahal."
data['aspect_ratio'] = "1:1"
# For parameter "input_image_1", you can send a raw file or a URI:
# files['input_image_1'] = open('IMAGE_PATH', 'rb') # To send a file
data['input_image_1'] = 'https://segmind-resources.s3.amazonaws.com/output/80b5e919-9150-43eb-a07c-b56f73ea3dcb-image_31.png' # To send a URI
# For parameter "input_image_2", you can send a raw file or a URI:
# files['input_image_2'] = open('IMAGE_PATH', 'rb') # To send a file
data['input_image_2'] = 'https://segmind-resources.s3.amazonaws.com/output/9c4b025f-dad6-4dae-88ab-d01765f0c2b8-man2.png' # To send a URI
data['output_format'] = "png"
data['safety_tolerance'] = 2
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. leave blank for random outcomes.
Describe how to transform images.
Choose the output aspect ratio. '16:9' for widescreen or '1:1' for square images.
Allowed values:
Provide the first image URL.
Provide the second image URL.
Select the output file format. Use 'png' for high quality or 'jpg' for smaller file size.
Allowed values:
Adjust safety levels: '0' for strict filtering, '2' for more lenient results.
min : 0,
max : 2
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 Pro – Text-Guided Image Editing Model
## What is FLUX.1 Kontext Pro?
FLUX.1 Kontext Pro is an advanced AI-driven, text-guided image editing model that transforms simple prompts into professional-grade visuals with speed and precision. Engineered for seamless API integration, it automates complex, multi-step manipulations—such as object alteration, style transfer, and background replacement—while maintaining consistent image quality. Whether you’re a developer building dynamic image pipelines, a creator seeking intuitive editing commands, or a product manager streamlining marketing mockups, FLUX.1 Kontext Pro delivers reliable, high-fidelity results.
## Key Features
- Text-Guided Editing: Convert natural-language prompts into precise image transformations.
- Multi-Image Fusion: Merge two input images (JPEG/PNG/GIF/WEBP) into a seamless composition.
- Style Transfer & Background Replacement: Apply artistic styles or swap backgrounds without artifacts.
- API-First Design: Easy integration via REST endpoints; ideal for automated workflows.
- Fast Performance: Millisecond-scale inference for rapid iteration on prototypes and campaigns.
- Parameter Control:
- prompt (required): Describe desired edits (“Merge the images to create a new, imaginative scene”).
- input_image_1, input_image_2 (required): Supply high-resolution URLs for best output.
- aspect_ratio (optional): Choose from common ratios (1:1, 16:9, 4:3, etc.) or match_input_image.
- seed (advanced): Set an integer for reproducible results or omit for random variations.
- output_format (advanced): Select “png” for maximum fidelity or “jpg” for smaller file size.
- safety_tolerance (advanced): Adjust filtering strictness (0 = strict, 2 = lenient).
## Best Use Cases
- Automated Marketing Visuals: Generate on-brand banners, ads, and social posts at scale.
- Product Mockups: Swap backgrounds and tweak product angles for e-commerce catalogs.
- Creative Prototyping: Explore style blends, object augmentations, and surreal composites.
- App Integrations: Embed real-time image editing in web or mobile applications.
- Content Personalization: Dynamically tailor visuals based on user preferences or A/B tests.
## Prompt Tips and Output Quality
- Be Descriptive: Specify objects, styles, or moods (“Replace beach background with a rainy cityscape”).
- Use High-Quality Inputs: Provide clear, high-resolution images for crisp composites.
- Control Aspect Ratio: Match your target display (e.g., 16:9 for widescreen, 1:1 for social).
- Lock the Seed: Reuse `seed=1234` to reproduce exact outputs for testing.
- Balance Safety Tolerance: Start at `safety_tolerance=1` to filter unwanted content without over-strictness.
- Preview & Iterate: Adjust prompts and advanced parameters to fine-tune color, composition, and detail.
## FAQs
**Q: How do I edit images with FLUX.1 Kontext Pro?**
A: Call the API with two image URLs and a `prompt` string. Optionally set `aspect_ratio`, `seed`, and `output_format`.
**Q: What file formats are supported?**
A: Input: JPEG, PNG, GIF, WEBP. Output: “png” (default) or “jpg”.
**Q: Can I control the output aspect ratio?**
A: Yes. Use `aspect_ratio` values like “1:1”, “16:9”, or “match_input_image” to fit your layout.
**Q: How do I ensure reproducible results?**
A: Include a fixed integer in the `seed` parameter (e.g., `seed=1234`) for consistent outputs.
**Q: What does safety_tolerance mean?**
A: It adjusts the model’s content filter: `0` = strict, `2` = more lenient. Default is `2` for creative flexibility.
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

faceswap-v2
Take a picture/gif and replace the face in it with a face of your choice. You only need one image of the desired face. No dataset, no training

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

codeformer
CodeFormer is a robust face restoration algorithm for old photos or AI-generated faces.
