# Flux 2 Pro > FLUX.2 generates photorealistic images while ensuring consistency across multiple assets using reference images. ## Overview - **Endpoint**: `https://api.segmind.com/v1/flux-2-pro` - **Model ID**: `flux-2-pro` - **Category**: Image-to-Image Transformation - **Type**: Synchronous (Direct response) - **Average Cost**: $0.07137411971830986 ## Pricing Megapixel-based pricing: - Generated image: $0.0405 (first megapixel), $0.02025 (subsequent megapixels) - Reference image: $0.02025 per megapixel Notes: - for pricing, resolution is always rounded up to the next megapixel, separately for each reference image and for the generated image - 1 megapixel is counted as 1024x1024 pixels - for multiple reference images, each reference image is counted as 1 megapixel - images exceeding 4 megapixels are resized to 4 megapixels ## API Information This model uses a **synchronous response pattern**: 1. Make a POST request with your parameters 2. Receive the output directly in the response (binary for images/videos/audio, JSON for text) 3. No polling required - response is immediate ### Input Schema The API accepts the following input parameters: - **`prompt`** (`string`, _required_): Prompt Text prompt guides image creation. Use descriptive phrases for detailed images. - Default: `"Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”"` - **`image_urls`** (`array`, _required_): Input image list Provide URLs for reference images. Ensure URLs are valid and image quality is high. - Item type: string - **`seed`** (`integer | null`, _optional_): Seed Seed allows image reproducibility. Use specific numbers for consistency, random for variety. - Default: `42` - **`width`** (`integer | null`, _optional_): Width Set image width. Use larger sizes for detail, smaller for quick generation. - Default: `1024` - **`height`** (`integer | null`, _optional_): Height Set image height. Adjust based on aspect ratio needs or desired output dimension. - Default: `1024` - **`safety_tolerance`** (`integer | null`, _optional_): Safety tolerance Adjust safety levels for moderation. Higher values for stricter checking. - Default: `3` - Range: 0 to 6 - **`output_format`** (`string | null`, _optional_): Output format Choose image format. Use 'jpeg' for quality, 'png' for transparency. - Default: `"png"` - Options: "jpeg" (jpeg), "png" (png) **Required Parameters Example**: ```json { "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”", "image_urls": [] } ``` **Full Example**: ```json { "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”", "image_urls": [], "seed": 42, "width": 1024, "height": 1024, "safety_tolerance": 3, "output_format": "png" } ``` ### Output Schema The API returns a synchronous response based on the model type: **For Image/Video/Audio Models**: - Response contains binary data (image/png, video/mp4, audio/mp3) - Content-Type header indicates the media type - Save the response body directly to a file **For Text Models**: - Response is JSON with the generated text - Structure varies by model **HTTP Response Codes**: - **200 - OK**: Request successful, output in response body - **400 - Bad Request**: Invalid parameters - **401 - Unauthorized**: Invalid or missing API key - **404 - Not Found**: Model not found - **406 - Not Acceptable**: Insufficient credits - **429 - Too Many Requests**: Rate limit exceeded - **500 - Server Error**: Internal server error ## Usage Examples ### cURL ```bash curl -X POST "https://api.segmind.com/v1/flux-2-pro" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”", "image_urls": [], "seed": 42, "width": 1024, "height": 1024, "safety_tolerance": 3, "output_format": "png" }' ``` ### Python ```python import requests import json api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/flux-2-pro" data = { "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”", "image_urls": [], "seed": 42, "width": 1024, "height": 1024, "safety_tolerance": 3, "output_format": "png" } response = requests.post( url, json=data, headers={ 'x-api-key': api_key, 'Content-Type': 'application/json' } ) if response.status_code == 200: # For image/video/audio models, response.content contains the binary data with open('output.png', 'wb') as f: f.write(response.content) print('Generation complete, saved to output.png') else: print(f"Error: {response.status_code}") print(response.text) ``` ### JavaScript ```javascript const apiKey = 'YOUR_API_KEY'; const url = 'https://api.segmind.com/v1/flux-2-pro'; const data = { "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”", "image_urls": [], "seed": 42, "width": 1024, "height": 1024, "safety_tolerance": 3, "output_format": "png" }; const response = await fetch(url, { method: 'POST', headers: { 'x-api-key': apiKey, 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); if (response.ok) { // For image/video/audio models, response contains binary data const blob = await response.blob(); const downloadUrl = URL.createObjectURL(blob); // Create download link const a = document.createElement('a'); a.href = downloadUrl; a.download = 'output.png'; a.click(); console.log('Generation complete'); } ``` ## Additional Resources ### Documentation - [Model Playground](https://www.segmind.com/models/flux-2-pro) - [API Documentation](https://www.segmind.com/models/flux-2-pro/api) - [Pricing Details](https://www.segmind.com/models/flux-2-pro/pricing) - [Platform Documentation](https://docs.segmind.com/) ### Tags No tags available