POST
/
inference
/
v1
/
workflows
/
accounts
/
fireworks
/
models
/
accounts
/
fireworks
/
models
/
flux-1-schnell-fp8
/
text_to_image
import requests

url = "https://api.fireworks.ai/inference/v1/workflows/accounts/fireworks/models/accounts/fireworks/models/flux-1-schnell-fp8/text_to_image"
headers = {
    "Content-Type": "application/json",
    "Accept": "image/jpeg",
    "Authorization": "Bearer $API_KEY",
}
data = {
    "prompt": "A beautiful sunset over the ocean"
}

response = requests.post(url, headers=headers, json=data)

if response.status_code == 200:
    with open("a.jpg", "wb") as f:
        f.write(response.content)
    print("Image saved as a.jpg")
else:
    print("Error:", response.status_code, response.text)

{
  "id": "1234567890",
  "base64": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."],
  "finishReason": "SUCCESS",
  "seed": 1234567890
}

FLUX.1 [schnell] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions. The FP8 version uses reduced precision numerics for 2x faster inference.

See our Playground to quickly try it out in your browser.

Path

model
string
required

The model to use for image generation.

Headers

Accept
string

Specifies which format to return the response in. With image/png and image/jpeg, the server will populate the response body with a binary image of the specified format. With application/json, the server will populate the response body with schema:

{
  "base64": [string, ...],
  "finishReason": string enum [SUCCESS, CONTENT_FILTERED],
  "seed": int
}

base64 contains a list of base64-encoded image files in PNG format. finishReason is SUCCESS unless safety_check=true and the image response was filtered. seed is the seed that was used when generating the image.

Content-Type
string

The media type of the request body.

Jpeg-Quality
integer

Quality (percent) of the JPEG image to return. Only used when Accept: image/jpeg. Range: 0-100.

Json-Return-Image-Accept
string

MIME type for the image to return in the JSON response. Only used when Accept: application/json.

Options: image/jpeg, image/png

Request Body

prompt
string
required

Prompt to use for the image generation process.

negative_prompt
string

Negative prompt to use for the image generation process.

height
integer

Height of the image in pixels. Supported resolutions (width, height) are (1024, 1024), (1152, 896), (896, 1152), (1216, 832), (832, 1216), (1344, 768), (768, 1344), (1536, 640), and (640, 1536).

Range: 512-1536

width
integer

Width of the image in pixels. Supported resolutions (width, height) are (1024, 1024), (1152, 896), (896, 1152), (1216, 832), (832, 1216), (1344, 768), (768, 1344), (1536, 640), and (640, 1536).

Range: 512-1536

cfg_scale
float

Classifier-free guidance scale for the image diffusion process.

sampler
string

Diffusion scheduler to use for the image generation process.

Options: null, K_EULER, K_DPMPP_2M

samples
integer

Number of images to generate.

Range: 1+

seed
integer

Random seed to use for the image generation process. If 0, we will use a totally random seed.

steps
integer

Number of steps to use for the image generation process.

Range: 1+

safety_check
boolean

Enable a safety check for each response. If the safety check model detects unsafe content, the response will be filtered with Finish-Reason = CONTENT_FILTERED.

import requests

url = "https://api.fireworks.ai/inference/v1/workflows/accounts/fireworks/models/accounts/fireworks/models/flux-1-schnell-fp8/text_to_image"
headers = {
    "Content-Type": "application/json",
    "Accept": "image/jpeg",
    "Authorization": "Bearer $API_KEY",
}
data = {
    "prompt": "A beautiful sunset over the ocean"
}

response = requests.post(url, headers=headers, json=data)

if response.status_code == 200:
    with open("a.jpg", "wb") as f:
        f.write(response.content)
    print("Image saved as a.jpg")
else:
    print("Error:", response.status_code, response.text)

{
  "id": "1234567890",
  "base64": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."],
  "finishReason": "SUCCESS",
  "seed": 1234567890
}

Response

id
string
required

The unique identifier for the image generation request.

base64
string
required

Includes a base64-encoded string containing an image in PNG format. To retrieve the image, base64-decode the string into binary data, then load that binary data as a PNG file.

finishReason
string
required

Can be SUCCESS or CONTENT_FILTERED.

Specifies the outcome of the image generation process. It could be SUCCESS indicating that the image was successfully generated, or CONTENT_FILTERED if the image was filtered due to the safety_check=true parameter being set.

seed
integer
required

The seed used for the image generation process.