Flux 2 - image generation API

Flux 2 API

active

High-quality AI image generation with excellent prompt following and photorealistic output.

Black Forest Labsimage10 credits/call
Provider
Black Forest Labs
Pricing
5–24 credits per image (~$0.01–$0.048)
Speed
3–8 seconds
Output
image

Quick Start

Send a request to the Flux 2 API:

bash
1curl -X POST https://apiin.one/api/v1/images/generations \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "flux-2",
6 "prompt": "A serene Japanese garden with cherry blossoms, koi pond, and wooden bridge, photorealistic",
7 "aspect_ratio": "16:9",
8 "type": "pro",
9 "resolution": "1K"
10}'

API Endpoint

POST/api/v1/images/generations

Send a POST request with your API key to generate content using Flux 2.

Headers

Body ParametersJSON
Authorization:string

Bearer YOUR_API_KEY

Content-Type:string

application/json

Body Parameters

Body ParametersJSON
model:string

Model identifier: flux-2

prompt:string

Text description of the image (3–5000 chars)

aspect_ratio:optional string

Output aspect ratio (e.g. 1:1, 16:9, 9:16) Defaults to 1:1.

type:optional string

Generation mode: pro (higher quality) or flex (faster/cheaper) Defaults to pro.

resolution:optional string

Output resolution: 1K or 2K Defaults to 1K.

input_urls:optional array

Array of image URLs for image-to-image (max 8 images)

Example Request

json
1{
2 "model": "flux-2",
3 "prompt": "A serene Japanese garden with cherry blossoms, koi pond, and wooden bridge, photorealistic",
4 "aspect_ratio": "16:9",
5 "type": "pro",
6 "resolution": "1K"
7}

Example Response

Successful task creation response.

1{
2 "code": 200,
3 "message": "success",
4 "data": {
5 "task_id": "n41xxxx_flux2",
6 "status": "IN_PROGRESS"
7 }
8}

Check Task Status

For asynchronous tasks, poll the status endpoint to check when your task is complete:

GET/api/v1/tasks/{task_id}

Returns the current status of a generation task. Poll until status is 'completed' or 'failed'.

bash
1curl https://apiin.one/api/v1/tasks/task_abc123 \
2 -H "Authorization: Bearer aio_your_key"

Use Cases

  • Generate product mockups and marketing visuals from text descriptions
  • Create AI-generated artwork and illustrations for content
  • Build AI image generation features into your application
  • Produce photorealistic stock images on demand

API Tester

Test the Flux 2 API directly from your browser:

Aire de jeux APIPOST

Error Codes

1{
2 "error": {
3 "code": 400,
4 "message": "Invalid parameters",
5 "type": "invalid_request"
6 }
7}

Frequently Asked Questions

How much does the Flux 2 API cost?

Credits vary by mode and resolution. Pro mode at 1K costs 5 credits, 2K costs 7 credits. Flex mode at 1K costs 14 credits, 2K costs 24 credits. Free credits included on sign up.

What is the difference between Pro and Flex mode?

Pro mode produces higher quality results. Flex mode is faster and cheaper, suitable for rapid iteration. Set the "type" parameter to "pro" or "flex".

Can I use reference images?

Yes. Flux 2 supports image-to-image by providing up to 8 input image URLs via the "input_urls" parameter alongside your text prompt.

What resolutions are supported?

Flux 2 supports 1K and 2K resolution output. Set via the "resolution" parameter.

Is the Flux 2 API compatible with OpenAI?

Yes. API in One uses an OpenAI-compatible REST format. If you're already using the OpenAI Images API, switching to Flux 2 requires minimal code changes.

Why Use Flux 2 Through API in One?

1.Pro and Flex modes for quality vs speed tradeoff
2.1K and 2K resolution support
3.Image-to-image with up to 8 reference images
4.Webhook support for async workflows

Ready to use Flux 2?

Get Your API Key →