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-10 imagesMust be square

Example Usage

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://..."
    }
  ]
}