pub trait EmbeddingModel:
Send
+ Sync
+ Debug {
// Required methods
fn provider(&self) -> &str;
fn model_id(&self) -> &str;
fn do_embed<'life0, 'async_trait>(
&'life0 self,
options: EmbedOptions,
) -> Pin<Box<dyn Future<Output = Result<EmbedResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn specification_version(&self) -> &'static str { ... }
fn max_embeddings_per_call<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<u32>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn supports_parallel_calls<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Contract every text-embedding model implements.
Mirrors EmbeddingModelV4. We pin the input type to String for now —
audio / image embeddings will introduce a parallel trait when needed.
Required Methods§
Sourcefn do_embed<'life0, 'async_trait>(
&'life0 self,
options: EmbedOptions,
) -> Pin<Box<dyn Future<Output = Result<EmbedResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn do_embed<'life0, 'async_trait>(
&'life0 self,
options: EmbedOptions,
) -> Pin<Box<dyn Future<Output = Result<EmbedResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Embed a batch of inputs.
§Errors
Returns a crate::ProviderError when the upstream call fails or
the response is malformed.
Provided Methods§
Sourcefn specification_version(&self) -> &'static str
fn specification_version(&self) -> &'static str
Specification version (currently "v4").
Mirrors EmbeddingModelV4.specificationVersion (ai-sdk
embedding-model-v4.ts). Provider impls inherit the default.
Sourcefn max_embeddings_per_call<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<u32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn max_embeddings_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 inputs the provider accepts per call.
None means “no documented limit”; callers should still batch
conservatively. Defaults to None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".