Compare commits

...
1 Commits
Author SHA1 Message Date
Hunter Bown 2b1ea69b1d fix: /balance cannot be used for providers.deepseek (#7055)
Produced by CodeWhale running in a Boat VM. Untested.
2026-10-24 22:29:52 -07:00
2 changed files with 30 additions and 1 deletions

No files matched your search

+10 -1
View File
@@ -208,11 +208,20 @@ async fn fetch_deepseek_user_balance(
api_key: &str,
base_url: &str,
) -> Option<crate::pricing::BalanceInfo> {
let url = format!("{}/user/balance", base_url.trim_end_matches('/'));
let url = deepseek_balance_url(base_url);
let body: crate::pricing::BalanceResponse = balance_get_json(api_key, &url).await?;
body.balance_infos.into_iter().next()
}
pub(crate) fn deepseek_balance_url(base_url: &str) -> String {
let origin = base_url.trim_end_matches('/');
let origin = origin
.strip_suffix("/beta")
.or_else(|| origin.strip_suffix("/v1"))
.unwrap_or(origin);
format!("{origin}/user/balance")
}
#[derive(serde::Deserialize)]
struct OpenRouterCreditsResponse {
data: OpenRouterCreditsData,
+20
View File
@@ -28993,6 +28993,26 @@ fn openrouter_credits_map_remaining_usd() {
assert_eq!(info.chip_label().as_deref(), Some("$37.66"));
}
#[test]
fn deepseek_balance_url_strips_beta_and_v1_prefixes() {
assert_eq!(
deepseek_balance_url("https://api.deepseek.com/beta"),
"https://api.deepseek.com/user/balance"
);
assert_eq!(
deepseek_balance_url("https://api.deepseek.com"),
"https://api.deepseek.com/user/balance"
);
assert_eq!(
deepseek_balance_url("https://api.deepseek.com/v1"),
"https://api.deepseek.com/user/balance"
);
assert_eq!(
deepseek_balance_url("https://api.deepseek.com/beta/"),
"https://api.deepseek.com/user/balance"
);
}
/// Regression for issue #244: visible session spend must not decrease.
/// Sub-agent token usage events arrive out of order and may be reconciled
/// later (cache adjustments, provisional → final swap). The displayed total