Skip to main content
TrueFoundry AI Gateway supports image variation capabilities that allow you to generate new versions of existing images while preserving the core visual elements and style. This feature is perfect for creating artistic variations, exploring different compositions, or generating multiple options from a single source image.

Supported Providers

  • OpenAI: Supports dall-e-2 model

Requirements

ProviderModelFormatSize LimitImage CountImage Requirements
OpenAIdall-e-2Square PNG< 4MB1 image onlyMust be square
AWS Bedrockamazon-nova-canvasPNG, JPEG-Upto 5 images-

Example Usage

The meaning of the parameters are present in the OpenAI API documentation. The AWS Bedrock specfic parameters are explained here
from openai import OpenAI

BASE_URL = "https://{controlPlaneUrl}/api/llm"
API_KEY = "your-truefoundry-api-key"

# Configure OpenAI client with TrueFoundry settings
client = OpenAI(
    api_key=API_KEY,
    base_url=BASE_URL,
)

response = client.images.create_variation(
    model="openai-main/dall-e-2",
    image=open("source_image.png", "rb"),  # Source image for variation
    n=3,  # Number of variations to generate
    size="1024x1024"
)

print(response)

Response Format

The API returns an ImagesResponse object containing:
{
  "created": 1589478378,
  "data": [
    {
      "url": "https://..."
    },
    {
      "url": "https://..."
    },
    {
      "url": "https://..."
    }
  ]
}