1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! How audio providers bill, for metering their calls against the current run.
//!
//! A cloud provider reports the vendor and model its calls are billed under
//! ([`SttProvider::billing`](crate::SttProvider::billing),
//! [`TtsProvider::billing`](crate::TtsProvider::billing)); a local model bills nothing and
//! reports `None`. [`TranscribeTool`](crate::TranscribeTool) and
//! [`SpeakTool`](crate::SpeakTool) meter every billed call through
//! [`adk_core::meter_usage`], against the run the tool call belongs to:
//!
//! | Call | Unit |
//! |------|------|
//! | Transcription | [`UsageUnit::AudioMillis`] of the audio sent |
//! | Synthesis | [`UsageUnit::Characters`] of the text sent |
//!
//! The bundled cloud providers carry no per-unit price, so their cost is unknown: under a
//! run budget's cost cap or a spend-ledger limit the call is refused before it is sent
//! (opt out of the budget check with `RunBudget::allow_unpriced_models`), and without a cap
//! the ledger commits the run's per-call spend estimate. A provider built with a price
//! ([`AudioBilling::with_rate`]) is held and committed at that price.
//!
//! # Example
//!
//! ```
//! use adk_audio::AudioBilling;
//! use adk_core::{UnitRate, UsageUnit, UsageVector};
//!
//! // $0.18 per audio hour, billed in whole seconds rounded down.
//! let billing = AudioBilling::new("muse", "muse-voice-transcribe-1.0").with_rate(
//! UnitRate::new(UsageUnit::AudioMillis, 180_000, 3_600_000).rounded_down_to(1_000),
//! );
//! let (call, usage) = billing.meter(UsageVector::new().with(UsageUnit::AudioMillis, 90_000));
//! assert_eq!(call.max_cost_micro_usd, Some(4_500));
//! assert_eq!(usage.cost_micro_usd, Some(4_500));
//! ```
use ;
use UsageUnit;
/// The vendor and model an audio provider's calls are billed under, and their price when
/// known.