pub struct ApiRequestPayload {
pub model: String,
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_creation_tokens: u64,
pub cache_read_tokens: u64,
pub latency_ms: u64,
pub stop_reason: String,
pub input_message_count: usize,
pub tool_count: usize,
pub default_model: bool,
pub purpose: Option<String>,
pub truncated: bool,
}Expand description
One completed model call: what it cost and what it was.
Emitted per call, which is what makes it the event a cost can be computed from — a turn is several calls, and every other number the engine reports is per turn.
No time-to-first-token and no retry count: the first is measured where the stream is consumed, not where a call is accounted for, and retries happen inside the client, under the model contract.
Fields§
§model: String§input_tokens: u64§output_tokens: u64§cache_creation_tokens: u64Tokens this call wrote into the prompt cache, and tokens it read back from it. Separate fields because they are separate prices — a read is a fraction of ordinary input and a write is a premium on it.
cache_read_tokens: u64§latency_ms: u64Wall clock for the whole call, request to last event.
stop_reason: String§input_message_count: usize§tool_count: usize§default_model: boolWhether this call went to the model the session was configured with. A fallback or a recovery switch makes it false.
purpose: Option<String>What this call was for, when it was not a turn: extracting memories,
summarizing for compaction, answering a prompt hook. None is a call
the turn loop made, which is the common case and the one a reader
summing a turn’s cost wants on its own.
truncated: boolThe provider closed the stream without marking the reply’s end; what arrived was taken as the whole reply.
Trait Implementations§
Source§impl Clone for ApiRequestPayload
impl Clone for ApiRequestPayload
Source§fn clone(&self) -> ApiRequestPayload
fn clone(&self) -> ApiRequestPayload
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ApiRequestPayload
impl Debug for ApiRequestPayload
Source§impl JsonSchema for ApiRequestPayload
impl JsonSchema for ApiRequestPayload
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more