fix(providers): estimate cost for Azure Foundry models via inferred catalog pricing (#11264)
Signed-off-by: Michael Neale <michael.neale@gmail.com> Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
@@ -190,6 +190,25 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Both agent loops price a chunk through `estimate_model_cost` and tag the result
|
||||
/// `CostSource::Estimated` when it returns `Some` — `reply_parts::resolve_chunk_cost` for
|
||||
/// the legacy path, `state_machine::usage::enrich` for the new one. Pinning the shared
|
||||
/// helper covers the behaviour both paths inherit.
|
||||
#[test]
|
||||
fn azure_foundry_estimates_from_the_azure_catalog_rate() {
|
||||
let used = usage(Some(1_000_000), Some(1_000_000), None);
|
||||
|
||||
let gpt5 = estimate_model_cost("azure_foundry", "gpt-5", &used)
|
||||
.expect("gpt-5 prices through the Azure catalog");
|
||||
assert!(gpt5 > 0.0);
|
||||
|
||||
// Priced from azure/llama-3.3-70b-instruct ($0.71/M in and out), not from the
|
||||
// meta-llama publisher row that lists the open weights at 0.0/0.0.
|
||||
let llama = estimate_model_cost("azure_foundry", "llama-3.3-70b-instruct", &used)
|
||||
.expect("llama-3.3-70b-instruct prices through the Azure catalog");
|
||||
assert!((llama - 1.42).abs() < 1e-9, "got {llama}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pricing_from_model_info_converts_per_token_to_per_million_usd() {
|
||||
let info = ModelInfo::with_cost("m", 262_144, 0.000002, 0.000006);
|
||||
|
||||
Reference in New Issue
Block a user