pub struct EmbeddingResponse {
pub object: String,
pub data: Vec<EmbeddingObject>,
pub model: String,
pub usage: Option<Usage>,
}Fields§
§object: StringAlways "list" from OpenAI-compatible APIs. Stored as a plain
String so non-standard provider values do not break deserialization.
data: Vec<EmbeddingObject>§model: String§usage: Option<Usage>Implementations§
Source§impl EmbeddingResponse
impl EmbeddingResponse
Sourcepub fn estimated_cost(&self) -> Option<f64>
pub fn estimated_cost(&self) -> Option<f64>
Estimate the cost of this embedding request based on embedded pricing data.
Returns None if:
- the
modelfield is not present in the embedded pricing registry, or - the
usagefield is absent from the response.
Embedding models only charge for input tokens; output cost is zero.
§Example
ⓘ
let cost = response.estimated_cost();
if let Some(usd) = cost {
println!("Embedding cost: ${usd:.8}");
}Trait Implementations§
Source§impl Clone for EmbeddingResponse
impl Clone for EmbeddingResponse
Source§fn clone(&self) -> EmbeddingResponse
fn clone(&self) -> EmbeddingResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EmbeddingResponse
impl Debug for EmbeddingResponse
Source§impl<'de> Deserialize<'de> for EmbeddingResponse
impl<'de> Deserialize<'de> for EmbeddingResponse
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for EmbeddingResponse
impl PartialEq for EmbeddingResponse
Source§impl Serialize for EmbeddingResponse
impl Serialize for EmbeddingResponse
impl StructuralPartialEq for EmbeddingResponse
Auto Trait Implementations§
impl Freeze for EmbeddingResponse
impl RefUnwindSafe for EmbeddingResponse
impl Send for EmbeddingResponse
impl Sync for EmbeddingResponse
impl Unpin for EmbeddingResponse
impl UnsafeUnpin for EmbeddingResponse
impl UnwindSafe for EmbeddingResponse
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
Mutably borrows from an owned value. Read more