async_llm/types/
completion_usage.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4pub struct CompletionUsage {
5    /// Number of tokens in the generated completion.
6    pub completion_tokens: Option<u32>,
7
8    /// Number of tokens in the prompt.
9    pub prompt_tokens: Option<u32>,
10
11    /// Total number of tokens used in the request (prompt + completion).
12    pub total_tokens: Option<u32>,
13
14    /// Breakdown of tokens used in a completion.
15    pub completion_tokens_details: Option<CompletionTokensDetails>,
16
17    /// Breakdown of tokens used in the prompt.
18    pub prompt_tokens_details: Option<PromptTokensDetails>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
22pub struct CompletionUsageStream {
23    /// Number of tokens in the generated completion.
24    pub completion_tokens: Option<u32>,
25
26    /// Number of tokens in the prompt.
27    pub prompt_tokens: Option<u32>,
28
29    /// Total number of tokens used in the request (prompt + completion).
30    pub total_tokens: Option<u32>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
34pub struct CompletionTokensDetails {
35    /// When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
36    pub accepted_prediction_tokens: Option<u32>,
37
38    /// Audio input tokens generated by the model.
39    pub audio_tokens: Option<u32>,
40
41    /// Tokens generated by the model for reasoning.
42    pub reasoning_tokens: Option<u32>,
43
44    /// When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
45    pub rejected_prediction_tokens: Option<u32>,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
49pub struct PromptTokensDetails {
50    /// Audio input tokens present in the prompt.
51    pub audio_tokens: Option<u32>,
52
53    /// Cached tokens present in the prompt.
54    pub cached_tokens: Option<u32>,
55}