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
}
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.Documentation Index
Fetch the complete documentation index at: https://docs.fireworks.ai/llms.txt
Use this file to discover all available pages before exploring further.
image/png and
image/jpeg, the server will populate the response body with a binary image
of the specified format.1:1, 21:9, 16:9, 3:2, 5:4, 4:5, 2:3, 9:16, 9:21, 4:3, 3:4import 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
}
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.image/jpeg, the response body will contain a binary image. Additionally, the response will include headers such as:Content-Length: Represents the length of the binary image content.Seed: The random seed used to generate the image.Finish-Reason: Indicates the outcome of the image generation, such as CONTENT_FILTERED or SUCCESS.image/png, the response body will contain a binary image. Additionally, the response will include headers such as:Content-Length: Represents the length of the binary image content.Seed: The random seed used to generate the image.Finish-Reason: Indicates the outcome of the image generation, such as CONTENT_FILTERED or SUCCESS.Was this page helpful?