pub struct EmbeddingOptions {
pub user: Option<String>,
pub encoding_format: Option<String>,
pub dimensions: Option<u32>,
pub api_key: Option<String>,
pub api_base: Option<String>,
pub timeout: Option<u64>,
pub headers: Option<HashMap<String, String>>,
pub task_type: Option<String>,
pub extra_params: HashMap<String, Value>,
}Expand description
Embedding options - Python LiteLLM compatible
These options control how embeddings are generated and allow customization of API behavior, authentication, and encoding format.
§Example
use litellm_rs::core::embedding::EmbeddingOptions;
let options = EmbeddingOptions::new()
.with_api_key("sk-...")
.with_dimensions(1536)
.with_encoding_format("float");Fields§
§user: Option<String>User identifier for tracking
encoding_format: Option<String>Encoding format for the embeddings (e.g., “float”, “base64”)
dimensions: Option<u32>Number of dimensions for the embedding output Only supported by models that allow dimension reduction
api_key: Option<String>API key to use for this request Overrides environment variable configuration
api_base: Option<String>Custom API base URL Allows using custom endpoints or proxies
timeout: Option<u64>Request timeout in seconds
headers: Option<HashMap<String, String>>Custom headers to include in the request
task_type: Option<String>Task type for specialized embeddings (e.g., for Vertex AI) Values: “RETRIEVAL_QUERY”, “RETRIEVAL_DOCUMENT”, “SEMANTIC_SIMILARITY”, etc.
extra_params: HashMap<String, Value>Extra provider-specific parameters
Implementations§
Source§impl EmbeddingOptions
impl EmbeddingOptions
Sourcepub fn with_encoding_format(self, format: impl Into<String>) -> Self
pub fn with_encoding_format(self, format: impl Into<String>) -> Self
Set encoding format
Sourcepub fn with_dimensions(self, dimensions: u32) -> Self
pub fn with_dimensions(self, dimensions: u32) -> Self
Set output dimensions
Sourcepub fn with_api_key(self, api_key: impl Into<String>) -> Self
pub fn with_api_key(self, api_key: impl Into<String>) -> Self
Set API key
Sourcepub fn with_api_base(self, api_base: impl Into<String>) -> Self
pub fn with_api_base(self, api_base: impl Into<String>) -> Self
Set API base URL
Sourcepub fn with_timeout(self, timeout: u64) -> Self
pub fn with_timeout(self, timeout: u64) -> Self
Set request timeout in seconds
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> Self
pub fn with_headers(self, headers: HashMap<String, String>) -> Self
Set custom headers
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a single custom header
Sourcepub fn with_task_type(self, task_type: impl Into<String>) -> Self
pub fn with_task_type(self, task_type: impl Into<String>) -> Self
Set task type for specialized embeddings
Sourcepub fn with_extra_param(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_extra_param( self, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Add an extra parameter
Sourcepub fn with_extra_params(self, params: HashMap<String, Value>) -> Self
pub fn with_extra_params(self, params: HashMap<String, Value>) -> Self
Set multiple extra parameters
Trait Implementations§
Source§impl Clone for EmbeddingOptions
impl Clone for EmbeddingOptions
Source§fn clone(&self) -> EmbeddingOptions
fn clone(&self) -> EmbeddingOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EmbeddingOptions
impl Debug for EmbeddingOptions
Source§impl Default for EmbeddingOptions
impl Default for EmbeddingOptions
Source§fn default() -> EmbeddingOptions
fn default() -> EmbeddingOptions
Source§impl<'de> Deserialize<'de> for EmbeddingOptions
impl<'de> Deserialize<'de> for EmbeddingOptions
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EmbeddingOptions
impl RefUnwindSafe for EmbeddingOptions
impl Send for EmbeddingOptions
impl Sync for EmbeddingOptions
impl Unpin for EmbeddingOptions
impl UnwindSafe for EmbeddingOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BudgetAwareRouting for T
impl<T> BudgetAwareRouting for T
Source§fn filter_by_budget(
&self,
providers: Vec<String>,
budget_router: &BudgetAwareRouter,
) -> Vec<String>
fn filter_by_budget( &self, providers: Vec<String>, budget_router: &BudgetAwareRouter, ) -> Vec<String>
Source§impl<T> CacheValue for T
impl<T> CacheValue for T
Source§fn from_bytes(bytes: &[u8]) -> Result<T, CacheError>
fn from_bytes(bytes: &[u8]) -> Result<T, CacheError>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more