FLUX Pro Professional Image Generation Complete Guide
Next-generation AI image generation models with ultra-high resolution, precise style control, and batch generation features.
Ultra-high resolution
Supports 4K image generation
Style control
Precise artistic styles
Photographic quality
Professional photography effects
Creative enhancement
Intelligent creative expansion
1. Basic Image Generation
Getting Started
import requests
import json
import base64
from PIL import Image
from io import BytesIO
# API configuration
API_URL = "https://api.n1n.ai/v1/images/generations"
API_KEY = "your-api-key"
def generate_image(prompt, model="flux-pro", size="1024x1024"):
"""Generate images using FLUX Pro"""
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": model,
"prompt": prompt,
"n": 1,
"size": size,
"quality": "hd",
"response_format": "b64_json"
}
response = requests.post(API_URL, headers=headers, json=payload)
if response.status_code == 200:
result = response.json()
image_data = result["data"][0]["b64_json"]
# Convert base64 to image
image = Image.open(BytesIO(base64.b64decode(image_data)))
image.save(f"flux_{size}.png")
print(f"Image saved")
return image
else:
print(f"Error: {response.status_code}")
return None
# Usage example
prompt = "cyberpunk city at night, neon lights, flying cars, ultra detailed, 8k"
image = generate_image(prompt, model="flux-pro")Model versions
- • FLUX Pro - Highest quality
- • FLUX Dev - Developer edition
- • FLUX Schnell - Fast edition
Supported sizes
- • 1024x1024 (1:1)
- • 1792x1024 (16:9)
- • 1024x1792 (9:16)
- • 2048x2048 (Ultra)
Quality tiers
- • Standard - Standard quality
- • HD - High definition
- • Ultra - Ultra high definition
2. Advanced Prompt Building
Prompt Builder
class FluxProPromptBuilder:
"""FLUX Pro prompt builder"""
def __init__(self):
self.elements = {
"subject": "",
"style": "",
"lighting": "",
"camera": "",
"quality": []
}
def subject(self, description):
self.elements["subject"] = description
return self
def style(self, *styles):
self.elements["style"] = ", ".join(styles)
return self
def lighting(self, lighting_type):
self.elements["lighting"] = lighting_type
return self
def camera(self, angle, focal_length=None):
camera_str = angle
if focal_length:
camera_str += f", {focal_length} lens"
self.elements["camera"] = camera_str
return self
def quality_tags(self, *tags):
self.elements["quality"].extend(tags)
return self
def build(self):
prompt_parts = []
if self.elements["subject"]:
prompt_parts.append(self.elements["subject"])
if self.elements["style"]:
prompt_parts.append(self.elements["style"])
if self.elements["lighting"]:
prompt_parts.append(self.elements["lighting"])
if self.elements["camera"]:
prompt_parts.append(self.elements["camera"])
if self.elements["quality"]:
prompt_parts.extend(self.elements["quality"])
return ", ".join(prompt_parts)
# Usage example
builder = FluxProPromptBuilder()
prompt = builder\
.subject("majestic dragon soaring through clouds")\
.style("fantasy art", "digital painting")\
.lighting("dramatic sunset lighting")\
.camera("wide angle shot", "24mm")\
.quality_tags("8k resolution", "highly detailed", "masterpiece")\
.build()
print("Generated prompt:", prompt)💡 Prompt Best Practices
- • Put the subject first; more important details come earlier
- • Use specific adjectives; avoid vague wording
- • Add modifiers like art style, lighting, and composition
- • Use weighting syntax (word:1.2) to emphasize key elements
- • Use negative prompts to exclude unwanted elements
3. Precise Style Control
Style presets and blending
# FLUX Pro style control
class FluxProStyleControl:
"""Precise style control"""
STYLE_PRESETS = {
"photorealistic": {
"prompt_suffix": "photorealistic, ultra realistic, professional photography",
"guidance_scale": 7.5,
"steps": 50
},
"anime": {
"prompt_suffix": "anime style, manga art, cel shaded",
"guidance_scale": 12,
"steps": 40
},
"oil_painting": {
"prompt_suffix": "oil painting, traditional art, brush strokes",
"guidance_scale": 8,
"steps": 45
}
}
@classmethod
def apply_style(cls, prompt, style_name):
if style_name not in cls.STYLE_PRESETS:
raise ValueError(f"Unknown style: {style_name}")
style = cls.STYLE_PRESETS[style_name]
full_prompt = f"{prompt}, {style['prompt_suffix']}"
return {
"prompt": full_prompt,
"guidance_scale": style["guidance_scale"],
"steps": style["steps"]
}
# Blend styles
def blend_styles(prompt, style1, style2, ratio=0.7):
"""Blend two styles"""
s1 = FluxProStyleControl.STYLE_PRESETS[style1]
s2 = FluxProStyleControl.STYLE_PRESETS[style2]
blended_prompt = f"{prompt}, [{s1['prompt_suffix']}:{ratio}], [{s2['prompt_suffix']}:{1-ratio}]"
return {
"prompt": blended_prompt,
"guidance_scale": s1["guidance_scale"] * ratio + s2["guidance_scale"] * (1-ratio),
"steps": int(s1["steps"] * ratio + s2["steps"] * (1-ratio))
}Art styles
- • Photorealistic
- • Anime/Manga
- • Oil Painting
- • Watercolor
- • 3D Render
- • Concept Art
Camera parameters
- • 镜头焦距 - 24mm, 50mm, 85mm
- • 光圈 - f/1.4, f/2.8, f/5.6
- • 景深 - shallow/deep DOF
- • 视角 - wide/close-up/aerial
- • ISO - 100, 400, 1600
4. Batch Generation Optimization
Asynchronous batch processing
import asyncio
import aiohttp
class FluxProBatchGenerator:
"""Batch generation optimization"""
def __init__(self, api_key, max_concurrent=3):
self.api_key = api_key
self.api_url = "https://api.n1n.ai/v1/images/generations"
self.max_concurrent = max_concurrent
async def generate_single(self, session, prompt, **kwargs):
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json"
}
payload = {
"model": "flux-pro",
"prompt": prompt,
"n": 1,
**kwargs
}
async with session.post(self.api_url, headers=headers, json=payload) as response:
if response.status == 200:
return await response.json()
else:
return {"error": f"Status {response.status}"}
async def generate_batch(self, prompts_with_params):
async with aiohttp.ClientSession() as session:
semaphore = asyncio.Semaphore(self.max_concurrent)
async def generate_with_limit(prompt_params):
async with semaphore:
prompt = prompt_params["prompt"]
params = prompt_params.get("params", {})
return await self.generate_single(session, prompt, **params)
tasks = [generate_with_limit(pp) for pp in prompts_with_params]
return await asyncio.gather(*tasks)🚀 Batch generation tips
- • Use async concurrency to increase throughput
- • Control concurrency to avoid rate limits
- • Reuse parameters for similar styles
- • Add retry logic to handle failures
- • Save results in real time to avoid data loss
5. Performance and Cost Optimization
⚡ Performance optimization
- ✅ Use FLUX Schnell for quick previews
- ✅ Batch processing improves efficiency
- ✅ 30–50 steps are usually sufficient
- ✅ Generate small images first, then upscale
- ✅ Cache frequently used results
💰 Cost control
- ✅ Use FLUX Dev for development
- ✅ Use FLUX Pro for production
- ✅ Standard quality suits most needs
- ✅ Avoid overly large resolutions
- ✅ Set a budget cap
Cost reference
FLUX Pro
$0.05/image (1024x1024)
FLUX Dev
$0.03/image (1024x1024)
FLUX Schnell
$0.01/image (1024x1024)