"Inference Engineering" is now available. Get your copy here
image generation

black forest labs logoFlux.2 [dev]

High-quality 32B parameter image generation model from Black Forest Labs.

Model details

View repository

Example usage

Generate an image using the OpenAI-compatible images API. The response contains a base64-encoded image.

Input
1from openai import OpenAI
2import base64
3import os
4
5client = OpenAI(
6    base_url="https://model-{MODEL_ID}.api.baseten.co/production/sync/v1",
7    api_key=os.environ["BASETEN_API_KEY"],
8)
9
10response = client.images.generate(
11    model="flux2-dev",
12    prompt="A cat holding a sign that says Hello World",
13    n=1,
14    size="1024x1024",
15    response_format="b64_json",
16    extra_body={
17        "num_inference_steps": 50,
18        "guidance_scale": 1.0,
19    },
20)
21
22# Decode and save the image
23img_data = base64.b64decode(response.data[0].b64_json)
24with open("flux2_output.png", "wb") as f:
25    f.write(img_data)
26
JSON output
1{
2    "created": 1234567890,
3    "data": [
4        {
5            "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQA..."
6        }
7    ]
8}

🔥 Trending models