Expand description
Core traits and types.
Always available regardless of feature flags. Includes:
Agent- The fundamental trait for all agentsTool/Toolset- For extending agents with capabilitiesSession/State- For managing conversation contextEvent- For streaming agent responsesAdkError/Result- Unified error handling Vendor-neutral usage units and per-unit prices. Vendor-neutral usage units and per-unit prices.
Token-billed model calls report UsageMetadata. Calls billed in
other units — generated images, seconds of audio transcribed, characters synthesized —
report a UsageVector: an amount per UsageUnit. A UnitRate prices one unit in
integer micro-USD, so cost stays the canonical rollup across every unit.
| Unit | Counts | Typical vendor billing |
|---|---|---|
InputTokens | Tokens sent to a model | Per million tokens |
OutputTokens | Tokens a model generated | Per million tokens |
Images | Images generated, edited or analysed | Per image, per thousand images |
AudioMillis | Milliseconds of audio processed or produced | Per hour, per minute |
VideoMillis | Milliseconds of video processed or produced | Per second |
Characters | Characters of text synthesized or translated | Per thousand characters |
Pages | Document pages processed | Per page |
Requests | Requests billed as a whole | Per request |
Frames | Video frames analysed | Per thousand frames, with a minimum per request |
§Example
use adk_core::{UnitRate, UsageUnit, UsageVector};
// $0.18 per audio hour, billed in whole seconds rounded down.
let rate = UnitRate::new(UsageUnit::AudioMillis, 180_000, 3_600_000).rounded_down_to(1_000);
let usage = UsageVector::new().with(UsageUnit::AudioMillis, 90_400);
assert_eq!(rate.cost_micro_usd(usage.get(UsageUnit::AudioMillis)), 4_500);
assert_eq!(serde_json::to_value(&usage).unwrap(), serde_json::json!({ "audioMillis": 90_400 }));Structs§
- Unit
Rate - A price per unit of usage:
micro_usdfor everyperunits ofunit. - Usage
Vector - Usage counted per
UsageUnit.
Enums§
- Usage
Unit - A unit a call’s usage is counted and billed in.