pub struct ChatCompletionResponse {
pub id: String,
pub object: String,
pub created: u64,
pub model: String,
pub choices: Vec<Choice>,
pub usage: Option<Usage>,
pub system_fingerprint: Option<String>,
pub service_tier: Option<String>,
}Fields§
§id: String§object: StringAlways "chat.completion" from OpenAI-compatible APIs. Stored as a
plain String so non-standard provider values do not break deserialization.
created: u64§model: String§choices: Vec<Choice>§usage: Option<Usage>§system_fingerprint: Option<String>§service_tier: Option<String>Implementations§
Source§impl ChatCompletionResponse
impl ChatCompletionResponse
Sourcepub fn estimated_cost(&self) -> Option<f64>
pub fn estimated_cost(&self) -> Option<f64>
Estimate the cost of this response 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.
§Example
ⓘ
let cost = response.estimated_cost();
if let Some(usd) = cost {
println!("Request cost: ${usd:.6}");
}Trait Implementations§
Source§impl Clone for ChatCompletionResponse
impl Clone for ChatCompletionResponse
Source§fn clone(&self) -> ChatCompletionResponse
fn clone(&self) -> ChatCompletionResponse
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 ChatCompletionResponse
impl Debug for ChatCompletionResponse
Source§impl Default for ChatCompletionResponse
impl Default for ChatCompletionResponse
Source§fn default() -> ChatCompletionResponse
fn default() -> ChatCompletionResponse
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ChatCompletionResponse
impl<'de> Deserialize<'de> for ChatCompletionResponse
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 ChatCompletionResponse
impl PartialEq for ChatCompletionResponse
Source§impl Serialize for ChatCompletionResponse
impl Serialize for ChatCompletionResponse
impl StructuralPartialEq for ChatCompletionResponse
Auto Trait Implementations§
impl Freeze for ChatCompletionResponse
impl RefUnwindSafe for ChatCompletionResponse
impl Send for ChatCompletionResponse
impl Sync for ChatCompletionResponse
impl Unpin for ChatCompletionResponse
impl UnsafeUnpin for ChatCompletionResponse
impl UnwindSafe for ChatCompletionResponse
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