Overview
FLUX is the flagship image generation model family from Black Forest Labs (BFL), based in Germany. The latest FLUX.2 generation spans 5 tiers from sub-second to 4MP flagship quality, alongside the previous-generation FLUX.1 Kontext for image editing — 7 active models in total. Legacy FLUX.1 [pro] models also remain callable. The APIYI gateway wraps BFL’s async polling API into a synchronous OpenAI Images API (/v1/images/generations and /v1/images/edits), so you can drop in the OpenAI SDK with just a base_url change.
Text-to-Image API
/v1/images/generations, generate images from text prompts across all 5 FLUX.2 models.Image Editing API
input_image fields (up to 8 references for fusion, via /generations), plus an OpenAI-compatible multipart /edits single-image path. Works for FLUX.2 + FLUX.1 Kontext.Historical Versions
Why APIYI’s FLUX?
A drop-in replacement for the BFL official channel, optimized in stability, cost, and integration experience for production:OpenAI-Compatible Wrapper · Zero-Code Migration
base_url here — no need to write your own polling_url loop.No Concurrency Cap · Beyond 24 Active Tasks
flux-kontext-max only 6). APIYI pools requests at the gateway, so enterprise users scale linearly without the per-account ceiling.Same Price or Up to 17% Off
Global Zero-Friction Access
api.apiyi.com directly with stable latency.Complete Model Ecosystem
Professional Service · Enterprise Support
Key Features
Full Speed Spectrum
Native 4MP Output
Multi-Reference Fusion
input_image ~ input_image_8 carry multiple references (URL or base64 data URL): FLUX.2 [pro/max/flex] up to 8, [klein] up to 4. Reference them in the prompt as “image 1 / image 2”.Grounding Search
Precise Hex Color Control
#02eb3c / #ff0088 directly in prompts. The model renders exact colors — no post-processing needed for brand-critical work.32K-Token Long Prompts
Typography-Tuned
OpenAI SDK Drop-in
base_url to https://api.apiyi.com/v1 and call client.images.generate(model="flux-2-pro", ...) directly — zero code change.Pricing
Per-image pricing — see the APIYI Price column. BFL’s official pricing is per MP (megapixel), with a base price within 1MP and incremental cost per extra MP. APIYI’s flat per-image pricing is more predictable.FLUX.2 Series (Latest Generation)
FLUX.1 Kontext Series (Image Editing Specialist)
FLUX.1 [pro] Legacy (Historical, Still Callable)
- APIYI uses flat per-image pricing — same cost regardless of output MP
- Official prices are MP-tiered: a base price for the first MP plus incremental cost per extra MP
- Editing requests cost the same as text-to-image (unlike OpenAI gpt-image-2 where edits are billed via Vision tokens)
- klein 4B / klein 9B open weights are available on Hugging Face for self-hosting (Apache 2.0 / FLUX NCL)
- Failed requests (4xx / moderation blocks) are not billed
Technical Specs
API Endpoints
/generations (JSON input_image_N). The /edits endpoint accepts a single image file only — best for migrating existing OpenAI SDK editing code.
Size (width / height) in Detail
Common Dimensions
Custom Size Constraints
FLUX.2 accepts arbitrary dimensions, as long as all of the following hold:- width / height must be multiples of 16
- Minimum 64×64
- Maximum ~4MP (e.g., 2048×2048 / 1920×2048 / 2048×1920)
- Recommended total ≤ 2MP to balance speed and cost
1280x720, 1920x1080, 2048x1024, 1456x1920
Invalid examples: 1000x1000 (not multiple of 16), 3840x2160 (exceeds 4MP), 32x32 (below 64×64)
Best Practices
Pick model by scenario
flux-2-max. Production batch → flux-2-pro. Typography posters / infographics → flux-2-flex. High-throughput real-time → flux-2-klein-9b. Image editing → flux-kontext-max or flux-kontext-pro.Default to ≤ 2MP
Reference images by index in prompts
input_image / input_image_2 / input_image_3 is exactly the “image 1 / image 2 / image 3” index in your prompt. Say “the person from image 1 in the scene of image 2 with the color palette of image 3” — far more reliable than letting the model guess.Download result URLs immediately
data[0].url is valid for only 10 minutes, hosted on delivery-eu.bfl.ai / delivery-us.bfl.ai, with CORS disabled. Production must server-side download to your own CDN.Lock typography to flex or max
flux-2-flex (typography specialist) or flux-2-max (highest overall quality). Other models may still blur small text.Use max for grounding search
flux-2-max. Other models rely on training data and cannot fetch live info.Client timeout 60–120s
Fix seed for reproducibility
seed + same other params = consistent results, useful for A/B tests and client review. klein doesn’t support prompt_upsampling; pro/max/flex have it off by default — opt in as needed.Error Codes & Retries
- Request timeout 60–120s (flex up to 180s)
- Exponential backoff for 5xx and 429 (recommended 2 retries)
- Once
data[0].urlis received, download asynchronously immediately — do not wait for user click - Log the
x-request-idresponse header for support
FAQ
Why does the url field expire in 10 minutes?
Why does the url field expire in 10 minutes?
delivery-eu.bfl.ai / delivery-us.bfl.ai with signed URLs valid for 10 minutes, and CORS is disabled. Production services must server-side download to your own OSS / CDN. Don’t pass the original URL to browsers, and don’t expect users to access it later.APIYI inherits the same URL mechanism — behavior matches the official channel.The official API uses async polling — how does APIYI make it synchronous?
The official API uses async polling — how does APIYI make it synchronous?
polling_url until Ready, then wraps the final result.sample URL as data[0].url and returns. From the client’s perspective, it’s a single request-response — identical to OpenAI / GPT-Image / Nano Banana.How many reference images can I send? How to write the prompt?
How many reference images can I send? How to write the prompt?
- FLUX.2 [pro/max/flex]: up to 8
- FLUX.2 [klein]: up to 4
- FLUX.1 Kontext [pro/max]: single reference (multi-image needs client-side stitching)
What does prompt_upsampling do? Should I enable it?
What does prompt_upsampling do? Should I enable it?
prompt_upsampling=true makes the model auto-expand and refine your prompt (especially helpful for short prompts). But it changes the original intent — keep it off for brand work and on for free exploration.Limitation: FLUX.2 [klein] doesn’t support it (silently ignored if passed).How do I use grounding search?
How do I use grounding search?
flux-2-max supports it. No special parameter needed — if your prompt requires real-time knowledge, the model will automatically search the web before generating. Example:“Generate a news photo of the snowstorm hitting NYC on Dec 15, 2025”Great for “yesterday’s match score”, “live weather”, “historical event recreation”, “latest trends”. Prompts without time-sensitive content won’t trigger search and bill as normal generation.
What's the most effective way to use hex colors?
What's the most effective way to use hex colors?
What's structured JSON prompting?
What's structured JSON prompting?
prompt field. Ideal for production automation and templated batch generation.Which endpoint should I use for image editing?
Which endpoint should I use for image editing?
- Option A (recommended): JSON +
input_image(~input_image_8) to/v1/images/generations— works for all FLUX models and supports multi-reference fusion - Option B:
multipart/form-datato/v1/images/edits— the file field name must beimage(single image), directly compatible with the OpenAI SDK’sclient.images.edit(), verified on the Kontext series
Can I use the OpenAI official SDK directly?
Can I use the OpenAI official SDK directly?
base_url to https://api.apiyi.com/v1:openai package. All FLUX models follow the OpenAI Images API response shape with data[0].url.Can I cancel a running task?
Can I cancel a running task?
What are the rate limits and concurrency caps?
What are the rate limits and concurrency caps?
flux-kontext-max separately limited to 6.APIYI pools at the gateway, so enterprise concurrency is not bound by the per-account ceiling. For explicit SLA / RPM commitments, contact our team for a dedicated quota.Do webhook callbacks work?
Do webhook callbacks work?
webhook_url + webhook_secret, but APIYI’s OpenAI-compatible wrapper waits synchronously and does not pass through webhook fields — you don’t need to poll, request-response is one shot. If your business genuinely needs webhooks, contact us to enable a native async channel.Are failed requests billed?
Are failed requests billed?
400 (param error), 403 (moderation block), 429 (rate-limited) all return errors and are not billed. Only requests that actually enter generation (200 + data[0].url) are billed.Related Docs
- Text-to-Image Playground —
/v1/images/generationsinteractive debugger - Image Editing Playground — multi-reference fusion + edit
- Historical Versions & Migration — FLUX.1 [pro] / [pro] 1.1 / Ultra / [dev]
- API Manual — general usage spec
- GPT-Image-2 Overview — OpenAI flagship, supports 4K
- Seedream Overview — BytePlus partnership channel