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

url = "https://api.fireworks.ai/inference/v1/workflows/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.

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.
Content-Type
string
The media type of the request body.
Authorization
string
The Bearer with Fireworks API Key.

Request Body

prompt
string
required
Prompt to use for the image generation process.
aspect_ratio
string
Aspect ratio of the generated image.Options: 1:1, 21:9, 16:9, 3:2, 5:4, 4:5, 2:3, 9:16, 9:21, 4:3, 3:4
guidance_scale
float
Classifier-free guidance scale for the image diffusion process. Default value is 3.5.
num_inference_steps
integer
Number of denoising steps for the image generation process. Default value is 4.
seed
integer
Random seed to use for the image generation process. If 0, we will use a totally random seed.
import requests

url = "https://api.fireworks.ai/inference/v1/workflows/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.