Skip to main content

supercode_runtime/
usage.rs

1//! Provider-reported token accounting for native runtime turns.
2
3use serde::Deserialize;
4
5/// Token accounting returned with a completion.
6#[derive(Debug, Clone, Default, Deserialize)]
7pub struct Usage {
8    /// Input tokens.
9    #[serde(default)]
10    pub prompt_tokens: u64,
11    /// Output tokens.
12    #[serde(default)]
13    pub completion_tokens: u64,
14    /// Total tokens.
15    #[serde(default)]
16    pub total_tokens: u64,
17    /// Prompt-token cache breakdown, when the provider reports one.
18    #[serde(default)]
19    pub prompt_tokens_details: Option<PromptTokensDetails>,
20}
21
22/// The cache portion of [`Usage::prompt_tokens_details`].
23#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize)]
24pub struct PromptTokensDetails {
25    /// Tokens served from the provider's prompt cache.
26    #[serde(default)]
27    pub cached_tokens: u64,
28}