Skip to main content

ImageModel

Trait ImageModel 

Source
pub trait ImageModel: Send + Sync {
    // Required methods
    fn provider(&self) -> &str;
    fn model_id(&self) -> &str;
    fn max_images_per_call(&self) -> Option<u32>;
    fn do_generate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        options: &'life1 ImageCallOptions,
    ) -> Pin<Box<dyn Future<Output = Result<ImageResult, AiMuxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn specification_version(&self) -> &'static str { ... }
    fn retry_config(&self) -> RetryConfig { ... }
}
Expand description

The unified image generation model trait (provider-facing).

Aligned with V4 ImageModelV4.

Required Methods§

Source

fn provider(&self) -> &str

Provider name, e.g. "openai".

Source

fn model_id(&self) -> &str

Provider-specific model ID, e.g. "dall-e-3".

Source

fn max_images_per_call(&self) -> Option<u32>

Limit of how many images can be generated in a single API call.

None means there is no fixed limit. The TS spec allows this to be a function of modelId; in Rust the provider resolves it to a plain Option<u32>.

Source

fn do_generate<'life0, 'life1, 'async_trait>( &'life0 self, options: &'life1 ImageCallOptions, ) -> Pin<Box<dyn Future<Output = Result<ImageResult, AiMuxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate an array of images.

Naming: the do_ prefix prevents accidental direct usage by users.

Provided Methods§

Source

fn specification_version(&self) -> &'static str

Specification version (always "v4").

Source

fn retry_config(&self) -> RetryConfig

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§