Skip to main content

CostRecord

Struct CostRecord 

Source
pub struct CostRecord {
Show 28 fields pub id: String, pub channel_id: String, pub upstream_channel: String, pub upstream_model: String, pub request_time_ms: i64, pub project: String, pub user_id: String, pub agent_type: String, pub input_tokens: i64, pub output_tokens: i64, pub cache_write_tokens: i64, pub cache_read_tokens: i64, pub thinking_tokens: i64, pub cost: f64, pub schema_saved_tokens: i64, pub response_saved_tokens: i64, pub rtk_saved_tokens: i64, pub pre_compress_tokens: i64, pub post_compress_tokens: i64, pub compression_tokens_saved: i64, pub unit: String, pub pricing_snapshot_json: String, pub timestamp: String, pub session_id: Option<String>, pub before_tokens: i64, pub after_tokens: i64, pub tokens_saved: i64, pub compression_breakdown_json: String,
}
Expand description

A single proxied request with token usage and cost.

Fields§

§id: String

UUID v7 primary key.

§channel_id: String

Channel used for this request (proxy channel ID, e.g. “deepseek”).

§upstream_channel: String

Human-readable upstream channel name (e.g. “DeepSeek Official”).

§upstream_model: String

Upstream model name sent to the API (e.g. “deepseek-v4-pro”).

§request_time_ms: i64

Request processing time in milliseconds (from request arrival to response return).

§project: String

Project path or identifier.

§user_id: String

User who made the request.

§agent_type: String

Agent type: “ClaudeCode”, “Codex”, etc.

§input_tokens: i64

Input/prompt tokens consumed.

§output_tokens: i64

Output/completion tokens consumed.

§cache_write_tokens: i64

Tokens written to the provider’s prompt cache.

§cache_read_tokens: i64

Tokens read from the provider’s prompt cache.

§thinking_tokens: i64

Extended thinking tokens consumed.

§cost: f64

Actual monetary cost of this request.

§schema_saved_tokens: i64

Tokens saved by schema compression.

§response_saved_tokens: i64

Tokens saved by response compression.

§rtk_saved_tokens: i64

Tokens saved by RTK token optimization.

§pre_compress_tokens: i64

Token count before tokenless compression.

§post_compress_tokens: i64

Token count after tokenless compression.

§compression_tokens_saved: i64

Tokens saved by tokenless compression.

§unit: String

Currency of cost: “USD”, “CNY”, “credits”.

§pricing_snapshot_json: String

Serialized pricing snapshot for audit trail.

§timestamp: String

When the request was completed (RFC 3339).

§session_id: Option<String>

Session ID from X-Claude-Code-Session-Id header (for billing correlation).

§before_tokens: i64

Estimated tokens before any compression (tokenless + proxy layers).

§after_tokens: i64

Actual tokens consumed by the upstream API (input + output).

§tokens_saved: i64

Total tokens saved across all compression layers.

§compression_breakdown_json: String

JSON array breakdown of each compression operation.

Each element:

{
  "op": "compress-schema",      // opType — see report.rs for full enum
  "method": "ToonHrv",          // compression strategy
  "beforeTokens": 1500,
  "afterTokens": 700,
  "savedTokens": 800,
  "beforeBytes": 6000,
  "afterBytes": 2800,
  "savedBytes": 3200
}

See [crate::report] module docs for the complete opType / method lookup table.

Trait Implementations§

Source§

impl Clone for CostRecord

Source§

fn clone(&self) -> CostRecord

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CostRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CostRecord

Source§

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 Serialize for CostRecord

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.