# Flux Kontext Pro > FLUX.1 Kontext Pro transforms text prompts into high-quality, customized images with remarkable efficiency and precision. ## Overview - **Endpoint**: `https://api.segmind.com/v1/flux-kontext-pro` - **Model ID**: `flux-kontext-pro` - **Category**: Image-to-Image Transformation - **Type**: Synchronous (Direct response) - **Average Cost**: $0.049999999999999996 ## Pricing - **Cost**: $0.050 per generation ## 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: - **`seed`** (`integer | null`, _optional_): Seed Sets the random seed for generation consistency. Use specific numbers for repeatable results. - **`prompt`** (`string`, _required_): Prompt Describes the desired output or edit. To create lively imagery, try instructions like 'Turn this into a cyberpunk cityscape.' - **`input_image`** (`File (URL)`, _optional_): Input image Image to edit or guide the generation. Use high-resolution images for the best quality results. - Default: `"https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp"` - **`aspect_ratio`** (`string | null`, _optional_): Aspect ratio Defines the image's width-to-height ratio. Choose '16:9' for widescreen or '1:1' for square images. - Default: `"match_input_image"` - Options: "match_input_image" (match_input_image), "1:1" (1:1), "16:9" (16:9), "9:16" (9:16), "4:3" (4:3), "3:4" (3:4), "3:2" (3:2), "2:3" (2:3), "4:5" (4:5), "5:4" (5:4), "21:9" (21:9), "9:21" (9:21), "2:1" (2:1), "1:2" (1:2) - **`output_format`** (`string | null`, _optional_): Output format Output format for the generated image. - Default: `"png"` - Options: "jpg" (jpg), "png" (png) - **`safety_tolerance`** (`integer | null`, _optional_): Safety tolerance Safety tolerance, 1 is most strict and 6 is most permissive. 2 is currently the maximum allowed when input images are used. - Default: `2` **Required Parameters Example**: ```json { "prompt": "make this a real photograph" } ``` **Full Example**: ```json { "seed": null, "prompt": "make this a real photograph", "input_image": "https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp", "aspect_ratio": "match_input_image", "output_format": "png", "safety_tolerance": 6 } ``` ### 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-kontext-pro" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "seed": null, "prompt": "make this a real photograph", "input_image": "https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp", "aspect_ratio": "match_input_image", "output_format": "png", "safety_tolerance": 6 }' ``` ### Python ```python import requests import json api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/flux-kontext-pro" data = { "seed": null, "prompt": "make this a real photograph", "input_image": "https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp", "aspect_ratio": "match_input_image", "output_format": "png", "safety_tolerance": 6 } 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-kontext-pro'; const data = { "seed": null, "prompt": "make this a real photograph", "input_image": "https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp", "aspect_ratio": "match_input_image", "output_format": "png", "safety_tolerance": 6 }; 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-kontext-pro) - [API Documentation](https://www.segmind.com/models/flux-kontext-pro/api) - [Pricing Details](https://www.segmind.com/models/flux-kontext-pro/pricing) - [Platform Documentation](https://docs.segmind.com/) ### Tags No tags available