Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

collab: Add support for overage billing for Claude Sonnet 4 (#31206)

Marshall Bowers37f49ce30426
diff --git a/crates/collab/src/api/billing.rs b/crates/collab/src/api/billing.rs
index 3840f5c9090..a0912b7a4ff 100644
--- a/crates/collab/src/api/billing.rs
+++ b/crates/collab/src/api/billing.rs
@@ -1499,6 +1499,12 @@ async fn sync_model_request_usage_with_stripe(
.get_active_zed_pro_billing_subscriptions(user_ids)
.await?;
+ let claude_sonnet_4 = stripe_billing
+ .find_price_by_lookup_key("claude-sonnet-4-requests")
+ .await?;
+ let claude_sonnet_4_max = stripe_billing
+ .find_price_by_lookup_key("claude-sonnet-4-requests-max")
+ .await?;
let claude_3_5_sonnet = stripe_billing
.find_price_by_lookup_key("claude-3-5-sonnet-requests")
.await?;
@@ -1532,6 +1538,10 @@ async fn sync_model_request_usage_with_stripe(
let model = llm_db.model_by_id(usage_meter.model_id)?;
let (price, meter_event_name) = match model.name.as_str() {
+ "claude-sonnet-4" => match usage_meter.mode {
+ CompletionMode::Normal => (&claude_sonnet_4, "claude_sonnet_4/requests"),
+ CompletionMode::Max => (&claude_sonnet_4_max, "claude_sonnet_4/requests/max"),
+ },
"claude-3-5-sonnet" => (&claude_3_5_sonnet, "claude_3_5_sonnet/requests"),
"claude-3-7-sonnet" => match usage_meter.mode {
CompletionMode::Normal => (&claude_3_7_sonnet, "claude_3_7_sonnet/requests"),