Repository navigation
Replies: 5 comments
|
I built a working prototype of this on my fork to check the shape before asking for approval. Screenshots use a local mock gateway with dummy data. Settings → Providers → Add source → HTTP endpoint. Field paths default to LiteLLM's Usage → Limits shows the source like a CLIProxyAPI account, using the amount shape from #14911: Context Window popover gets a compact budget line (the thread-cost part is tracked in #13073): One compatibility note: today an undecodable Would you approve this direction? If yes, I'll open a PR with only the budget-source commits. The open questions above still stand, especially whether the auth header should be a stored secret only. |
|
+1 to the generic Not every gateway returns one object per user. Inferrail (the gateway I maintain, open source) holds budgets per run, per project or globally, and its spend endpoint returns a list, one entry per budget, with money as decimal strings: GET /v1/local/budgets/spend
Authorization: Bearer <local api token>[
{"budget_id": "project:jdoe:monthly", "limit_usd": "1000", "spent_usd": "42.500000", "has_unpriced_usage": false},
{"budget_id": "work_id:fix-loop-17:per_work", "limit_usd": "25", "spent_usd": "3.120000", "has_unpriced_usage": false}
]Two small additions would make the proposed config map that without a per-gateway adapter:
On the Claude Code side, it routes through this gateway with |
|
+1 to the generic I run Claude Code behind OmniRoute, which fronts a Kiro subscription for a T3 Claude provider instance ( What the gateway returns (sanitized), from {"plan":"KIRO POWER","quotas":{"credit":{"used":2639.13,"total":10000,"remaining":7360.87,"resetAt":"2026-11-01T00:00:00.000Z","unlimited":false}}}Three things from this setup bear on the open questions:
Mobile is why I care about the generic kind. The mobile widget snapshot builder already consumes |
|
Another concrete use case for the generic HTTP source: Ollama Cloud used through Pi. In my T3 Code 0.1.0 setup, model discovery and inference work, but the underlying Ollama account has no balance/allowance card in Usage → Limits. I already display this in a local dsh-cost-meter custom-balance entry using an endpoint, credential references, extraction rules, source currency, and a refresh interval. A generic source in T3 would cover the same need without a dedicated Ollama integration. I verified that authenticated {
"included": {
"balance_usd": 42,
"allowance_usd": 60,
"period": {
"from": "2026-10-01T00:00:00Z",
"until": "2026-11-01T00:00:00Z"
}
},
"purchased": { "balance_usd": 5 }
}This adds a few requirements to the proposed field mappings:
A remaining-balance field plus simple add/subtract mappings, with optional limits/reset dates per pool, would make this usable. Keep USD as the source unit; display-currency conversion should be separate from quota calculations. The card should represent provider-reported account credits, which can include usage outside T3, separately from estimated session costs or the cash paid for a subscription. On refresh failure, keep the last valid reading marked stale rather than displaying zero. This is an observed endpoint response, not a claim of a guaranteed stable Ollama API contract. Credentials should remain server-side. Happy to provide more sanitized mapping details if useful. |
|
+1 to a generic extensible One additional requirement worth considering in the schema: beyond percentage-based spending budgets (
Having optional |



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
Many teams run Claude Code (and other agents) through an internal LLM gateway (LiteLLM Proxy, a corporate API platform, etc.) via
ANTHROPIC_BASE_URL. The real limit for those users is a monthly spending budget enforced by the gateway, not a provider subscription window.Today in T3 Code:
get_usage, Codex, …). Behind a gateway, nothing reports the budget that actually applies.As a result, gateway users keep a separate terminal script or status line running just to see "$42 of $1000 used, resets Nov 1".
Proposal
Add a second
UsageLimitSourceConfigkind next tocliproxy.UsageLimitSourceSnapshot.kindalready anticipates more kinds. The new kind is a generic HTTP JSON source with field mapping, so T3 doesn't need per-gateway integrations:Example response from a LiteLLM-style gateway that this config maps:
{ "spend": 42.5, "budget_table": { "soft_budget": 800.0, "max_budget": 1000.0, "budget_duration": "1mo", "budget_reset_at": "2026-11-01T00:00:00Z" } }The source publishes one window (
usedPercent = used / limit, plus amounts andresetsAt). It goes through the existing pipeline: secret storage, poll interval, Refresh button, error state when the probe fails. Amounts would follow the shape #14911 introduces for Claude Enterprisemonthly_spend, so both render the same way.Configured from the UI
The JSON above is only how the source is stored. Users set it up entirely in Settings → Providers → usage hubs, by extending the existing
AddUsageLimitSourceDialog:Test runs the request once on the server and shows the parsed values, or the exact path that failed (for example
budget_table.max_budget not found), before anything is saved. Existing rows keep the current edit, disable and remove actions.Where it shows
Why generic, not per-gateway
PR #10904 (OpenRouter balance as its own kind) was closed pending scope approval. A single mapped HTTP kind covers OpenRouter, LiteLLM, Portkey and in-house gateways without adding a new integration for each.
Open questions for maintainers
ANTHROPIC_AUTH_TOKEN)?windows: [...]array of mappings in a single source?Related: #15043 (per-thread cost in the Context Window popover).
All reactions