POST
/
images
/
generations
from together import Together
import os

client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)

response = client.images.generate(
model="black-forest-labs/FLUX.1-schnell",
steps=4,
prompt="A cartoon of an astronaut riding a horse on the moon",
)

print(response.data[0].url)
{
  "id": "<string>",
  "model": "<string>",
  "object": "list",
  "data": [
    {
      "index": 123,
      "b64_json": "<string>",
      "type": "b64_json"
    }
  ]
}

Authorizations

Authorization
string
header
default:default
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

A description of the desired images. Maximum length varies by model.

Example:

"cat floating in space, cinematic"

model
required

The model to use for image generation.<br> <br> See all of Together AI's image models

Available options:
black-forest-labs/FLUX.1-schnell-Free,
black-forest-labs/FLUX.1-schnell,
black-forest-labs/FLUX.1.1-pro
Example:

"black-forest-labs/FLUX.1-schnell"

steps
integer
default:20

Number of generation steps.

image_url
string

URL of an image to use for image models that support it.

seed
integer

Seed used for generation. Can be used to reproduce image generations.

n
integer
default:1

Number of image results to generate.

height
integer
default:1024

Height of the image to generate in number of pixels.

width
integer
default:1024

Width of the image to generate in number of pixels.

negative_prompt
string

The prompt or prompts not to guide the image generation.

response_format
enum<string>

Format of the image response. Can be either a base64 string or a URL.

Available options:
base64,
url
guidance_scale
number
default:3.5

Adjusts the alignment of the generated image with the input prompt. Higher values (e.g., 8-10) make the output more faithful to the prompt, while lower values (e.g., 1-5) encourage more creative freedom.

output_format
enum<string>
default:jpeg

The format of the image response. Can be either be jpeg or png. Defaults to jpeg.

Available options:
jpeg,
png
image_loras
object[]

An array of objects that define LoRAs (Low-Rank Adaptations) to influence the generated image.

disable_safety_checker
boolean

If true, disables the safety checker for image generation.

Response

200 - application/json

Image generated successfully

id
string
required
model
string
required
object
enum<string>
required
Available options:
list
Example:

"list"

data
object[]
required