pub struct AssistantUsageData {Show 19 fields
pub api_call_id: Option<String>,
pub api_endpoint: Option<AssistantUsageApiEndpoint>,
pub cache_read_tokens: Option<i64>,
pub cache_write_tokens: Option<i64>,
pub content_filter_triggered: Option<bool>,
pub copilot_usage: Option<AssistantUsageCopilotUsage>,
pub cost: Option<f64>,
pub duration: Option<i64>,
pub finish_reason: Option<String>,
pub initiator: Option<String>,
pub input_tokens: Option<i64>,
pub inter_token_latency_ms: Option<f64>,
pub model: String,
pub output_tokens: Option<i64>,
pub provider_call_id: Option<String>,
pub reasoning_effort: Option<String>,
pub reasoning_tokens: Option<i64>,
pub service_request_id: Option<String>,
pub time_to_first_token_ms: Option<i64>,
/* private fields */
}Expand description
Session event “assistant.usage”. LLM API call usage metrics including tokens, costs, quotas, and billing information
Fields§
§api_call_id: Option<String>Completion ID from the model provider (e.g., chatcmpl-abc123)
api_endpoint: Option<AssistantUsageApiEndpoint>API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
cache_read_tokens: Option<i64>Number of tokens read from prompt cache
cache_write_tokens: Option<i64>Number of tokens written to prompt cache
content_filter_triggered: Option<bool>Whether the model response was blocked or truncated by content filtering (finish_reason === ‘content_filter’). For Anthropic models this corresponds to a ‘refusal’ stop reason.
copilot_usage: Option<AssistantUsageCopilotUsage>Per-request cost and usage data from the CAPI copilot_usage response field
cost: Option<f64>Model multiplier cost for billing purposes
Experimental. This type is part of an experimental wire-protocol surface and may change or be removed in future SDK or CLI releases.
duration: Option<i64>Duration of the API call in milliseconds
finish_reason: Option<String>Finish reason reported by the model for this API call (e.g. “stop”, “length”, “tool_calls”, “content_filter”). Normalized to OpenAI vocabulary; for Anthropic models a “refusal” stop reason maps to “content_filter”.
initiator: Option<String>What initiated this API call (e.g., “sub-agent”, “mcp-sampling”); absent for user-initiated calls
input_tokens: Option<i64>Number of input tokens consumed
inter_token_latency_ms: Option<f64>Average inter-token latency in milliseconds. Only available for streaming requests
model: StringModel identifier used for this API call
output_tokens: Option<i64>Number of output tokens produced
provider_call_id: Option<String>GitHub request tracing ID (x-github-request-id header) for server-side log correlation
reasoning_effort: Option<String>Reasoning effort level used for model calls, if applicable (e.g. “none”, “low”, “medium”, “high”, “xhigh”, “max”)
reasoning_tokens: Option<i64>Number of output tokens used for reasoning (e.g., chain-of-thought)
service_request_id: Option<String>Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
time_to_first_token_ms: Option<i64>Time to first token in milliseconds. Only available for streaming requests
Trait Implementations§
Source§impl Clone for AssistantUsageData
impl Clone for AssistantUsageData
Source§fn clone(&self) -> AssistantUsageData
fn clone(&self) -> AssistantUsageData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more