Skip to main content
Black Forest Labs’ FLUX.2 dev is the next-generation text-to-image diffusion transformer, with improved prompt adherence and detail.

Setup

Install the Baseten CLI and sign in, then install the client library for the tab you’ll use: requests for the Python tab, or the OpenAI SDK for the OpenAI tab.
Install and sign in to Baseten
Terminal
For other platforms or a specific version, see the Baseten CLI install reference.
Install requests
Install the OpenAI SDK
To install without Homebrew, see the Baseten CLI install reference. This variant ships in 2 presets tuned for different goals: Lossless for maximum visual fidelity, and Lossy for faster generation with minor perceptual trade-offs. Pick the tab that matches your workload.

Hardware

H100

Engine

Baseten 1.2

Write the config

Create and move into the project directory:
Then create a file named config.yaml and paste the following:
config.yaml

Deploy

Push the config to Baseten with the Baseten CLI, or with the Truss CLI if you prefer it:
You should see output similar to:
baseten model push prints your model ID (abc1d2ef in the example). The examples below use it wherever you see {model_id}, and read your API key from the BASETEN_API_KEY environment variable.

Call the model

Use the /v1/images/generations endpoint to generate your model’s images.The deployment returns the generated image as base64-encoded bytes. Decode the response to write the image to disk. The size parameter sets the output resolution in pixels.
main.py

Next steps

Call your model

Endpoint anatomy, authentication, and sync versus async inference

Autoscaling

Scale replicas with traffic, including scale to zero