Skip to main content
Generate and edit images from text prompts, sketches, or existing images with creative control. Perfect for creative content generation, marketing and advertising, product visualization, and artistic expression.
Image generation example showing AI-generated images from text prompts with creative control

Image generation example showing AI-generated images from text prompts with creative control

Image-to-Image
Text-to-Image
Image-Inpainting
Image-Inpainting
Style Transfer
Style Transfer

Examples of image generation supported.

Example Usage

For most image-generation examples, you can use the Structured Outputs API to ensure that the returned response can be structured with a valid pre-signed (public) image URL.

Text-to-Image

Generate images from text descriptions with creative control over style, composition, and details. Generate an image of a cat flying through the sky and clouds, with the background of a green city with river
import openai
from pydantic import BaseModel, Field

class ImageGenerationResponse(BaseModel):
  url: str = Field(..., description="The URL of the generated image")

# Initialize the client
client = openai.OpenAI(
    base_url="https://agent.vlm.run/v1/openai",
    api_key="<VLMRUN_API_KEY>"
)

# Generate the image
response = client.chat.completions.create(
    model="vlm-agent-1",
    messages=[
        {
            "role": "user",
            "content": "Generate an image of a modern building as a cyberpunk-style futuristic structure with neon lights and holographic elements"
        }
    ],
    response_format={"type": "json_schema", "schema": ImageGenerationResponse.model_json_schema()}
)

# Print the response
print(response.choices[0].message.content)
>>> {"url": "https://.../image.jpg"}

# Validate the response
print(ImageGenerationResponse.model_validate_json(response.choices[0].message.content))
>>> ImageGenerationResponse(url="https://.../image.jpg")

Image-to-Image

Transform existing images by applying new styles, enhancing details, or changing specific elements while preserving the original structure.
Image-to-Image example showing AI-generated images combining objects from two separate images

Example of image inpainting.

Reference Dog Image
Reference Dog Image
Dog flying through space
More examples of image-to-image

Examples of image inputs for inpainting.

import openai
from pydantic import BaseModel, Field

class ImageGenerationResponse(BaseModel):
  url: str = Field(..., description="The URL of the generated image")

# Initialize the client
client = openai.OpenAI(
    base_url="https://agent.vlm.run/v1/openai",
    api_key="<VLMRUN_API_KEY>"
)

# Generate the image
response = client.chat.completions.create(
    model="vlm-agent-1",
    messages=[
        {
            "role": "user",
            "content": "Transform the image of my dog on the right into a flying dog with superman cape, with majestic background"
        },
        {
            "role": "image_url",
            "image_url": {"url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.object-detection/dog-cat.jpg", "detail": "auto"}
        }
    ],
    response_format={"type": "json_schema", "schema": ImageGenerationResponse.model_json_schema()}
)

# Print the response
print(response.choices[0].message.content)
>>> {"url": "https://.../image.jpg"}

# Validate the response
print(ImageGenerationResponse.model_validate_json(response.choices[0].message.content))
>>> ImageGenerationResponse(url="https://.../image.jpg")

Image Inpainting

Fill in missing areas, remove unwanted objects, or add new elements to existing images seamlessly.
Image inpainting example showing AI-generated images combining objects from two separate images

Example of image inpainting.

Reference Dog Image
Reference Dog Image
Reference Car Image
Reference Car Image

Examples of image inputs for inpainting.

import openai
from pydantic import BaseModel, Field

class ImageGenerationResponse(BaseModel):
  url: str = Field(..., description="The URL of the generated image")

# Initialize the client
client = openai.OpenAI(
    base_url="https://agent.vlm.run/v1/openai",
    api_key="<VLMRUN_API_KEY>"
)

# Generate the image
response = client.chat.completions.create(
    model="vlm-agent-1",
    messages=[
        {
            "role": "user",
            "content": "Given two images: the first with a dog in front holding a yellow ball, inpaint her driving the car shown in the second image."
        },
        {
            "role": "image_url",
            "image_url": {"url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.object-detection/dogs.jpg", "detail": "auto"}
        },
        {
            "role": "image_url",
            "image_url": {"url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.caption/car.jpg", "detail": "auto"}
        }
    ],
    response_format={"type": "json_schema", "schema": ImageGenerationResponse.model_json_schema()}
)

# Print the response
print(response.choices[0].message.content)
>>> {"url": "https://.../image.jpg"}

# Validate the response
print(ImageGenerationResponse.model_validate_json(response.choices[0].message.content))
>>> ImageGenerationResponse(url="https://.../image.jpg")

Style Transfer

Apply artistic styles from reference images to transform the visual appearance while preserving content. In the example below, we apply the Van Gogh’s “Starry Night” painting style to a photo of a city skyline at night.
Example of image style transfer

Example of image style transfer.

Reference Van Gogh Image
Reference Van Gogh Image
Reference City Image
Reference City Image

Examples of image inputs for style transfer.

import openai
from pydantic import BaseModel, Field

class ImageGenerationResponse(BaseModel):
  url: str = Field(..., description="The URL of the generated image")

# Initialize the client
client = openai.OpenAI(
    base_url="https://agent.vlm.run/v1/openai",
    api_key="<VLMRUN_API_KEY>"
)

# Generate the image
response = client.chat.completions.create(
    model="vlm-agent-1",
    messages=[
        {
            "role": "user",
            "content": "Given two images: the first with a Van Gogh painting, and the second with a city skyline at night, apply the Van Gogh painting style to the city skyline."
        },
        {
            "role": "image_url",
            "image_url": {"url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.generation/starry-night.jpg", "detail": "auto"}
        },
        {
            "role": "image_url",
            "image_url": {"url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.generation/sf-golden-gate.jpg", "detail": "auto"}
        }
    ],
    response_format={"type": "json_schema", "schema": ImageGenerationResponse.model_json_schema()}
)

# Print the response
print(response.choices[0].message.content)
>>> {"url": "https://.../image.jpg"}

# Validate the response
print(ImageGenerationResponse.model_validate_json(response.choices[0].message.content))
>>> ImageGenerationResponse(url="https://.../image.jpg")

FAQ

  • Photorealistic: Ultra-realistic images with fine details
  • High Detail: Ultra-realistic images with fine details
  • Natural Lighting: Realistic lighting and shadows
  • Professional Quality: Suitable for commercial and professional use
  • Multiple Subjects: People, objects, landscapes, architecture
  • Be Specific: Include details about style, composition, lighting, and mood
  • Use Keywords: Include relevant art terms, techniques, and descriptors
  • Reference Styles: Mention specific artists, art movements, or visual styles
  • Technical Details: Specify resolution, quality, and output format needs