FLUX.2-klein-4B model, but you can replace it with
any supported model that’s listed as an “Image” type.
Requirements
-
An API key. The code below assumes you set it
in an environment variable:
-
The
openaiPython package. You can install it with this command:
Generate an image
To generate an image, setinput to a text description of the image and
set generation parameters in provider_options.image.

Transform an image
To transform an image, setinput to a user message containing:
- An
input_imageblock with an image URL or base64-encoded data URI. - An
input_textblock describing the transformation.
landscape.png file created above and transforms it
into a watercolor painting:
