POST
javascript
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 30 31 32 33 34 35 36 37 38 39 40 41 const axios = require('axios'); const FormData = require('form-data'); const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/multi-image-kontext-pro"; const reqBody = { "prompt": "A woman is taking a selfie with the man in front of the Taj Mahal.", "aspect_ratio": "1:1", "input_image_1": "https://segmind-resources.s3.amazonaws.com/output/80b5e919-9150-43eb-a07c-b56f73ea3dcb-image_31.png", "input_image_2": "https://segmind-resources.s3.amazonaws.com/output/9c4b025f-dad6-4dae-88ab-d01765f0c2b8-man2.png", "output_format": "png", "safety_tolerance": 2 }; (async function() { try { const formData = new FormData(); // Append regular fields for (const key in reqBody) { if (reqBody.hasOwnProperty(key)) { formData.append(key, reqBody[key]); } } // Convert and append images as Base64 if necessary const response = await axios.post(url, formData, { headers: { 'x-api-key': api_key, ...formData.getHeaders() } }); console.log(response.data); } catch (error) { console.error('Error:', error.response ? error.response.data : error.message); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


seedint ( default: 1 )

Set a random seed for reproducibility. leave blank for random outcomes.


promptstr *

Describe how to transform images.


aspect_ratioenum:str ( default: match_input_image )

Choose the output aspect ratio. '16:9' for widescreen or '1:1' for square images.

Allowed values:


input_image_1str *

Provide the first image URL.


input_image_2str *

Provide the second image URL.


output_formatenum:str ( default: png )

Select the output file format. Use 'png' for high quality or 'jpg' for smaller file size.

Allowed values:


safety_toleranceint ( default: 2 )

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.