pub struct Client { /* private fields */ }Expand description
A configured embeddings client. Cheap to clone (reqwest::Client is an
Arc internally); build it once and reuse it. Debug redacts the API key.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder(provider: Provider, model: impl Into<String>) -> ClientBuilder
pub fn builder(provider: Provider, model: impl Into<String>) -> ClientBuilder
Start configuring a client for provider using model.
Sourcepub async fn embed(
&self,
texts: &[String],
kind: EmbedKind,
) -> Result<Vec<Vec<f32>>, Error>
pub async fn embed( &self, texts: &[String], kind: EmbedKind, ) -> Result<Vec<Vec<f32>>, Error>
Embed a batch of texts, preserving input order. kind distinguishes
stored documents from search queries (see EmbedKind; symmetric
providers ignore it). Batches larger than max_batch are split into
sequential requests and their results concatenated.
No retry or backoff. A transient failure (network blip, a 429
rate-limit) returns Err immediately; if it happens partway through a
split batch, the vectors already fetched in this call are discarded.
Resilience is deliberately the caller’s job - inspect Error::Api’s
status and re-invoke embed if you need it.