# Docs for v2 can be found by changing the above selector ^
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"
}
]
}Use an image model to generate an image for a given prompt.
# Docs for v2 can be found by changing the above selector ^
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"
}
]
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
A description of the desired images. Maximum length varies by model.
"cat floating in space, cinematic"
The model to use for image generation.
See all of Together AI's image models
black-forest-labs/FLUX.1-schnell-Free, black-forest-labs/FLUX.1-schnell, black-forest-labs/FLUX.1.1-pro "black-forest-labs/FLUX.1-schnell"
Number of generation steps.
URL of an image to use for image models that support it.
Seed used for generation. Can be used to reproduce image generations.
Number of image results to generate.
Height of the image to generate in number of pixels.
Width of the image to generate in number of pixels.
The prompt or prompts not to guide the image generation.
Format of the image response. Can be either a base64 string or a URL.
base64, url 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.
The format of the image response. Can be either be jpeg or png. Defaults to jpeg.
jpeg, png An array of objects that define LoRAs (Low-Rank Adaptations) to influence the generated image.
Show child attributes
The URL of the LoRA to apply (e.g. https://huggingface.co/strangerzonehf/Flux-Midjourney-Mix2-LoRA).
The strength of the LoRA's influence. Most LoRA's recommend a value of 1.
An array of image URLs that guide the overall appearance and style of the generated image. These reference images influence the visual characteristics consistently across the generation.
URL of a reference image to guide the image generation.
If true, disables the safety checker for image generation.
Image generated successfully
Was this page helpful?