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
42
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-max";
const reqBody = {
"seed": 42,
"prompt": "put the green dress on the woman while maintaining the pose of the woman as it is",
"aspect_ratio": "1:1",
"input_image_1": "https://segmind-resources.s3.amazonaws.com/output/9cb479d3-5c5f-4d5d-a782-972acbc42598-c1.jpg",
"input_image_2": "https://segmind-resources.s3.amazonaws.com/output/79feee7b-d09f-4bde-bec3-c8e8a8703f04-d2.png",
"output_format": "jpg",
"safety_tolerance": 1
};
(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);
}
})();
Sets seed for reproducibility.
Describes the prompt for image transformation.
Sets output aspect ratio. Use '16:9' for wide images.
Allowed values:
First image for transformation
Second image for transformation.
Sets output forma.
Allowed values:
Controls content safety level. Use 1 for moderate strictness.
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 [max] is an advanced AI image generation and editing model from Black Forest Labs. Using a cutting-edge multimodal transformer-diffusion architecture, it converts rich text prompts and one or more input images into stunning, photorealistic visuals with integrated typography. Developers, creators, and product managers leverage its rapid inference to innovate in branding, editorial design, social media, and beyond—without extensive prompt tuning.
• Multimodal Transformer-Diffusion
– Deep text understanding meets diffusion-based image synthesis for lifelike results.
• Dynamic Style Transfer
– Blend textures, colors, and forms from two inputs (input_image_1
, input_image_2
) in a single pass.
• Native Typography Integration
– Auto-place and style headlines, captions, and logos within generated imagery.
• Robust Prompt Comprehension
– Handles complex instructions (“A futuristic cityscape at dusk with neon typography”) out of the box.
• Aspect Ratio & Format Control
– Supports common ratios (1:1, 16:9, 9:16, 4:3, 21:9) and output_format
choices (jpg
, png
).
• Reproducibility & Safety
– Set a seed
(default 42) for consistent outputs and adjust safety_tolerance
(0–2) to meet compliance needs.
• Be Descriptive: Include setting, materials, lighting, and perspective.
• Specify Typography: Add font style descriptors (“bold serif”, “neon cursive”) for precise text integration.
• Use Technical Tags: Combine natural language with tags like #retro or #neon to hint style.
• Adjust Aspect Ratio Early: Choose aspect_ratio
to match final medium (print, web, mobile).
• Control Reproducibility: Use seed
to lock randomness and regenerate identical outputs.
• Match Format to Deliverables: Select jpg
for smaller files or png
when transparency is needed.
Q: How do I get the most photorealistic images?
A: Provide detailed prompts with lighting, camera angle, materials, and supply high-quality input images.
Q: Can I merge two source images?
A: Yes—use input_image_1
and input_image_2
together. The model blends them via style-transfer techniques.
Q: Which aspect ratios are available?
A: From match_input_image to 1:1, 16:9, 9:16, 4:3, 3:2, 21:9, 9:21, and more—choose based on your target platform.
Q: How is consistency maintained across runs?
A: Set the integer seed
parameter; identical seeds yield reproducible results.
Q: Do I need lengthy prompt engineering?
A: No. FLUX.1 Kontext [max] excels at interpreting nuanced prompts with minimal iteration.