Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
anthropic: Classify exhausted credits as payment required (#63988)
Conrad Irwin7e0b34bad6b9
diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rsindex e24f9fd927d..178cd8d831e 100644--- a/crates/anthropic/src/anthropic.rs+++ b/crates/anthropic/src/anthropic.rs@@ -1317,6 +1317,13 @@ fn completion_error_from_anthropic_api_with_status(ProviderErrorCategory::PromptTooLarge {tokens: Some(tokens),}+ } else if error+ .message+ .starts_with("Your credit balance is too low to access the Anthropic API.")+ {+ // Anthropic sends credit exhaustion as invalid_request_error rather than+ // the billing_error documented at https://platform.claude.com/docs/en/api/errors.+ ProviderErrorCategory::PaymentRequired} else {ProviderErrorCategory::InvalidRequest}