Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Togethercomputer Together python Image Prompt Format

From Leeroopedia
Revision as of 13:56, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Togethercomputer_Together_python_Image_Prompt_Format.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Computer_Vision, Image_Generation, API_Client
Last Updated 2026-02-15 16:00 GMT

Overview

A pattern document describing how users construct prompt and negative prompt strings for the Together AI image generation API. Prompts are plain Python strings passed directly to the client.images.generate() method.

Description

Image prompts in the Together Python SDK are standard Python strings. There is no special prompt object or builder class; the user constructs a descriptive text string and passes it as the prompt parameter. An optional negative_prompt string specifies visual elements to suppress during generation.

The prompt parameter is the only required input for image generation (along with model). Its maximum length varies by the underlying diffusion model. The negative_prompt parameter defaults to None when not provided.

Usage

Use this pattern whenever calling client.images.generate(). Construct your prompt string before invoking the API method, and optionally prepare a negative prompt to improve output quality.

Code Reference

Source Location

Signature

# Relevant parameters from Images.generate()
def generate(
    self,
    *,
    prompt: str,                        # Required: text description of desired image
    model: str,                         # Required: model identifier
    negative_prompt: str | None = None, # Optional: what to avoid
    ...
) -> ImageResponse:

Import

from together import Together

client = Together()

I/O Contract

Inputs

Name Type Required Description
prompt str Yes A text description of the desired image. Maximum length varies by model.
negative_prompt None No Text describing elements to avoid in the generated image. Defaults to None.

Outputs

Prompt strings are consumed internally by ImageRequest and sent to the API. They do not produce a direct return value themselves; the generation result is an ImageResponse object (see Implementation:Togethercomputer_Together_python_ImageResponse_Handling).

Usage Examples

Basic Prompt

from together import Together

client = Together()

# Simple descriptive prompt
response = client.images.generate(
    prompt="A golden retriever playing in autumn leaves in a park",
    model="black-forest-labs/FLUX.1-schnell-Free",
)

Detailed Prompt with Style Guidance

# More specific prompt with style and quality descriptors
response = client.images.generate(
    prompt="A futuristic cityscape at night with neon lights reflecting on wet streets, "
           "cyberpunk style, highly detailed, cinematic lighting, 8k resolution",
    model="black-forest-labs/FLUX.1-schnell-Free",
)

Using Negative Prompt

# Positive prompt describes what to generate
# Negative prompt describes what to avoid
response = client.images.generate(
    prompt="Professional portrait of a woman in a garden, soft natural lighting, "
           "sharp focus, photorealistic",
    model="stabilityai/stable-diffusion-xl-base-1.0",
    negative_prompt="blurry, low quality, watermark, text, deformed hands, "
                    "extra fingers, oversaturated",
)

Multi-line Prompt Construction

# Building prompts programmatically
subject = "a medieval castle on a cliff"
style = "oil painting, impressionist style"
details = "dramatic sunset sky, ocean waves below, birds in flight"

prompt = f"{subject}, {style}, {details}"
negative_prompt = "modern elements, cars, electricity, photorealistic"

response = client.images.generate(
    prompt=prompt,
    model="stabilityai/stable-diffusion-xl-base-1.0",
    negative_prompt=negative_prompt,
)

Related Pages

Implements

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment