Skip to main content

Module usage

Module usage 

Source
Expand description

Core traits and types.

Always available regardless of feature flags. Includes:

  • Agent - The fundamental trait for all agents
  • Tool / Toolset - For extending agents with capabilities
  • Session / State - For managing conversation context
  • Event - For streaming agent responses
  • AdkError / 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.

UnitCountsTypical vendor billing
InputTokensTokens sent to a modelPer million tokens
OutputTokensTokens a model generatedPer million tokens
ImagesImages generated, edited or analysedPer image, per thousand images
AudioMillisMilliseconds of audio processed or producedPer hour, per minute
VideoMillisMilliseconds of video processed or producedPer second
CharactersCharacters of text synthesized or translatedPer thousand characters
PagesDocument pages processedPer page
RequestsRequests billed as a wholePer request
FramesVideo frames analysedPer 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§

UnitRate
A price per unit of usage: micro_usd for every per units of unit.
UsageVector
Usage counted per UsageUnit.

Enums§

UsageUnit
A unit a call’s usage is counted and billed in.