Generate an image
To query an image model, use the.images method and specify the image model:
TypeScript examples that call
together.images.generate require [email protected] or later. If your project already has an older SDK installed, upgrade with npm install together-ai@latest.
Save to disk
The recommended pattern for saving a generated image locally isresponse_format="base64". This avoids a separate download step and works without any special HTTP headers.
url instead, download it with a non-empty User-Agent header. The CDN rejects requests with a blank User-Agent (HTTP 403):
Python
Supported models
For the current list of image-generation models, see the serverless catalog or the dedicated model inference catalog. The table below shows the most commonly used serverless image models.Parameters
The image generation endpoint accepts a common set of parameters across models, includingprompt, model, width, height, n, steps, seed, and negative_prompt. The full parameter reference also covers image_url, reference_images, frame_images, and model-specific notes.
A few quick notes:
promptis required for all models except Kling.widthandheightrely on defaults unless otherwise specified. Available dimensions differ by model.- FLUX Schnell and Kontext (Pro/Max/Dev) models use the
aspect_ratioparameter to set the output image size, whereas FLUX.1 Pro, FLUX 1.1 Pro, and FLUX.1 Dev usewidthandheight.
Generate multiple variations
Generate multiple variations of the same prompt and choose between them:
Next steps
Image-to-image generation
Edit or transform an existing image with
image_url or reference_images.Image generation parameters
Look up the full parameter reference, custom dimensions, quality control, base64 responses, the safety checker, and troubleshooting.