Generate images using a FLUX.1 [Dev], a 12 billion parameter model using text descriptions. It excels in photorealism, processes complex prompts, and generates clear text.

OctoAI’s FLUX.1 [Dev] API supports text-to-image, image-to-image, and inpainting use cases.

You need to create an OctoAI Authentication Token to access this API.

How to use

Invoke https://image.octoai.run/generate/flux-dev endpoint with a POST request.

The headers of the request must include an Authentication Token in the authorization field. The accept header should be set to application/json to receive the image encoded as base64 in a JSON response.

Generating with a prompt: Commonly referred to as text-to-image, this mode generates an image from text alone. While the only required parameter is the prompt, it also supports a width and height parameter which can be used to control the aspect ratio of the generated image.

Generating with a prompt and an image: Commonly referred to as image-to-image, this mode also generates an image from text but uses an existing image as the starting point. The required parameters are:

  • prompt - text to generate the image from
  • init_image - the image to use as the starting point for the generation. Argument takes an image encoded as a string in base64 format.
  • strength - controls how much influence the image parameter has on the output image

Inpainting with a prompt: Inpainting replaces or edits specific areas of an image. This makes it a useful tool for image restoration like removing defects and artifacts, or even replacing an image area with something entirely new. Inpainting relies on a mask to determine which regions of an image to fill in. The required parameters are:

  • prompt - text to generate the image from
  • init_image - the image to use as the starting point for the generation. Argument takes an image encoded as a string in base64 format.
  • mask_image - area of the picture to inpaint. Argument takes an image encoded as a string in base64 format.

For more details about all parameters, please see the request schema below.

Output

The resolution of the generated image will be 1 megapixel. The default resolution is 1024x1024.

Pricing

$0.02 per image, 30 steps, 1024X1024

Check Pricing Page for more details.

Request Details

Headers:

Authorization (Required): Your OCTOAI_TOKEN
Content-Type (Required): Set to application/json

Parameters:

  • prompt (string [ 1 .. 10000 ] characters, Required): A string of text describing the image to generate. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.
  • cfg_scale (double, Optional): Floating-point number represeting how closely to adhere to prompt description. Must be a positive number no greater than 50.0. Recommended values greater than 8.
  • num_images (integer, Optional): Integer representing how many output images to generate with a single prompt/configuration. Defaults to 1. Allowed values: 1-16.
  • seed (union, Optional): Integer number or list of integers representing the seeds of random generators. Fixing random seed is useful when attempting to generate a specific image. Must be greater than 0 and less than 2^32.
  • steps (integer, Optional Defaults to 30): Integer representing how many steps of diffusion to run. Must be greater than 0 and less than or equal to 200.
  • height (integer, Optional): Integer representing the height of image to generate. Default to 1024.
  • width (integer, Optional): Integer representing the width of image to generate. Default to 1024.
  • loras (string,Optional): Here you can specify LoRAs, in name-weight pairs, either from the OctoAI asset library or your private asset library.
  • init_image (string, Optional): The image (encoded in b64 string) to use as the starting point for the generation. This parameter is for Image-to-Image generation and Inpainting.
    Use .jpg format to ensure best latency
  • strength (double,Optional): Floating-point number indicating how much creative the Image-to-Image generation mode should be. Must be greater than 0 and less than or equal to 1.0. Defaults to 0.8. This parameter is for Image-to-Image generation.
  • mask_image (string, Optional): Only applicable for inpainting use cases i.e. to specify which area of the picture to paint onto. Argument takes an image encoded as a string in base64 format.
    Use .jpg format to ensure best latency

Supported Output Resolutions (Width x Height) are as follows:

FLUX.1 [Dev]:

(512, 512), (576, 1024), (640, 1536), (768, 1024), (768, 1344),
(832, 1216),(896, 1152), (1024, 576), (1024, 768), (1024, 1024),
(1152, 896), (1216, 832), (1344, 768), (1536, 640)

Request Examples

cURL
$curl -X POST "https://image.octoai.run/generate/flux-dev" \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $OCTOAI_TOKEN" \
> --data-raw '{
> "prompt": "A vibrant image showcasing a tub of \"Frosty Delight Mango and Raspberry\" ice cream. The packaging is primarily white with a swirl of yellow and red, featuring the brand name in bold maroon letters. The tub is surrounded by artfully placed slices of fresh mango and whole raspberries on a light pink background. Swirls of ice cream are smeared around the tub, adding texture and enhancing the visual appeal. The overall composition is colorful and enticing, highlighting the tropical and fruity flavors of the ice cream.",
> "width": 1024,
> "height": 1024,
> "num_images": 4,
> "steps": 30,
> "cfg_scale": 8
> }'