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
6–20 credits per image (~$0.012–$0.04)
Speed
3–8 seconds
Output
image

Quick Start

Send a request to the Flux 2 API:

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

API Endpoint

POST/api/v1/images/generations
Send a POST request with your API key to generate content using Flux 2.

Headers

HeaderTypeRequisDescription
AuthorizationstringRequisBearer YOUR_API_KEY
Content-TypestringRequisapplication/json

Body Parameters

ParamètreTypeRequisDescription
modelstringRequisModel identifier: "flux-2"
promptstringRequisText description of the image (3–5000 chars)
aspect_ratiostringOptionnelOutput aspect ratio (e.g. 1:1, 16:9, 9:16) (Par défaut : 1:1)
typestringOptionnelGeneration mode: "pro" (higher quality) or "flex" (faster/cheaper) (Par défaut : pro)
resolutionstringOptionnelOutput resolution: "1K" or "2K" (Par défaut : 1K)
input_urlsarrayOptionnelArray of image URLs for image-to-image (max 8 images)

Example Request

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

Example Response

Successful task creation response.

{
  "code": 200,
  "message": "success",
  "data": {
    "task_id": "n41xxxx_flux2",
    "status": "IN_PROGRESS"
  }
}

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
curl https://apiin.one/api/v1/tasks/task_abc123 \
  -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

{
  "error": {
    "code": 400,
    "message": "Invalid parameters",
    "type": "invalid_request"
  }
}

Frequently Asked Questions

How much does the Flux 2 API cost?

Credits vary by mode and resolution. Pro mode at 1K costs ~10 credits, 2K costs ~20 credits. Flex mode at 1K costs ~6 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?

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

Ready to use Flux 2?

Get Your API Key →