pub trait MultimodalModel:
BaseChatModel
+ Send
+ Sync {
// Provided methods
fn transcribe<'life0, 'async_trait>(
&'life0 self,
_audio: AudioContent,
) -> Pin<Box<dyn Future<Output = Result<String, MultimodalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn generate_speech<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MultimodalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn generate_image<'life0, 'life1, 'async_trait>(
&'life0 self,
_prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ImageContent, MultimodalError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Multimodal model trait — extends BaseChatModel with audio, speech, and image generation.
Providers implement only the methods they support. The default
implementation of every method returns an explicit
Err(MultimodalError::Unsupported(..)) — this is a hard capability
limit reported as an error, never a silent no-op or placeholder output.
Callers MUST match on MultimodalError::Unsupported (or propagate via
?) before assuming the operation produced meaningful content.
§Example
use lc_core::language_models::MultimodalModel;
// Transcribe audio
let transcript = llm.transcribe(AudioContent::from_url("https://...")).await?;
// Generate speech
let audio_bytes = llm.generate_speech("Hello, world!").await?;
// Generate image
let image = llm.generate_image("A cat wearing a hat").await?;Provided Methods§
Sourcefn transcribe<'life0, 'async_trait>(
&'life0 self,
_audio: AudioContent,
) -> Pin<Box<dyn Future<Output = Result<String, MultimodalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn transcribe<'life0, 'async_trait>(
&'life0 self,
_audio: AudioContent,
) -> Pin<Box<dyn Future<Output = Result<String, MultimodalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Transcribes audio to text (Speech-to-Text).
Returns the transcribed text.
Sourcefn generate_speech<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MultimodalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_speech<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MultimodalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generates audio from text (Text-to-Speech).
Returns the raw audio bytes (format depends on provider, typically MP3 or PCM).
Sourcefn generate_image<'life0, 'life1, 'async_trait>(
&'life0 self,
_prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ImageContent, MultimodalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_image<'life0, 'life1, 'async_trait>(
&'life0 self,
_prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ImageContent, MultimodalError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generates an image from a text prompt.
Returns the generated image content.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".