Skip to main content
Dartantic provides a unified generateMedia() API that works across multiple providers. Each provider uses its own underlying mechanism (native image generation, code execution, etc.) but the API surface is consistent.

Provider Support

When you request an image, Dartantic routes to the provider’s native image model (DALL-E for OpenAI, Nano Banana Pro for Google). For other file types, it uses each provider’s code execution environment.

Basic Usage

Image Editing with Attachments

All providers support image editing by providing an input image as an attachment. Google uses native Imagen for high-quality editing, while OpenAI and Anthropic use code execution (PIL/Pillow):
Common image editing use cases:
  • Colorization: Add color to black and white images
  • Style Transfer: Apply artistic styles to existing images
  • Object Removal: Remove unwanted objects (inpainting)
  • Background Replacement: Change backgrounds while preserving subjects
  • Enhancement: Improve quality, lighting, or resolution

Example MIME Types

The mimeTypes parameter tells the provider what kind of output you want, e.g.
  • image/png, image/jpeg - Images
  • application/pdf - PDF documents
  • text/csv - CSV files
  • Other file types depend on provider code execution capabilities

Streaming Generation

Use generateMediaStream() to receive incremental updates:

Specifying Media Models

Use the model string to specify which media model to use:
The model string is passed through to the provider’s API, so you can use new models as soon as they’re available without waiting for a Dartantic update.

Provider-Specific Options

Each provider accepts options for customization:

OpenAI Responses

Google

Anthropic

Result Structure

MediaGenerationResult contains:
  • assets - List of Part objects (typically DataPart with bytes)
  • links - List of LinkPart for hosted URLs (if applicable)
  • messages - Conversation messages generated during the run
  • metadata - Provider-specific metadata (previews, progress, etc.)
  • isComplete - Whether generation is finished (for streaming)

Examples