together.Image.create()

  • prompt (string, required) -- A string providing context for the model to complete
  • model (string, optional) -- Model string to query. Default: runwayml/stable-diffusion-v1-5
  • steps (integer, optional) -- Sampling steps is the number of iterations that the model runs to go from random noise to a recognizable image based on the text. Default: 20
  • seed (integer, optional) -- Random seed used for generation. Default: 42
  • results (integer, optional) -- Number of result images to generate. Default: 1
  • height (integer, optional) -- Height of the image to generate in number of pixels. Default: 256
  • width (integer, optional) -- Width of the image to generate in number of pixels. Default: 256

Example:

import together
import base64

together.api_key = "xxxxx"

# generate image 
response = together.Image.create(prompt="Space robots")

# save the first image
image = response["output"]["choices"][0]
with open("spacerobots.png", "wb") as f:
    f.write(base64.b64decode(image["image_base64"]))