Skip to main content

ImageModel

Trait ImageModel 

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

    // Provided methods
    fn specification_version(&self) -> &'static str { ... }
    fn max_images_per_call<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Contract every image-generation model implements.

Required Methods§

Source

fn provider(&self) -> &str

Provider id, e.g. "openai".

Source

fn model_id(&self) -> &str

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

Source

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

Generate images.

§Errors

Returns a crate::ProviderError when the upstream call fails or the response is malformed.

Provided Methods§

Source

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

Specification version (currently "v4").

Mirrors ImageModelV4.specificationVersion (ai-sdk image-model-v4.ts). Provider impls inherit the default.

Source

fn max_images_per_call<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Maximum images that can be requested per call.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§