mirror of
https://github.com/openai/codex.git
synced 2026-12-04 00:51:02 +00:00
Expose gateway spend in app-server account rate limits (#65193)
## Why Clients need to show the spend and cap for the account behind a thread's model provider. The existing ChatGPT usage read cannot provide those figures for a gateway account. ## What changed - Route `account/rateLimits/read` through the provider's configured `usage_url` using the provider's credentials. An optional `threadId` selects a loaded thread's provider for the account-wide read. Omitting it selects the default provider. - Return `usageUnavailable` for a thread whose provider has neither a usage endpoint nor first-party authentication. Surface gateway errors without falling back to ChatGPT usage. - Report monthly gateway spend in `individualLimit` as exact USD decimal strings, with `limit: "unlimited"` for uncapped accounts. Use `spendControlReached` for the gateway's cap status. Spend snapshots identify their unit as `usd` or `credit`, with omitted units defaulting to `credit` for compatibility. ## Testing Add integration coverage for thread-specific provider selection, gateway usage taking precedence over ChatGPT without fallback, and reuse of an existing gateway OAuth session without interactive login. GitOrigin-RevId: e6ec9d83eecc3084fcc98e72e2c031bd3e53a2cd
This commit is contained in:
@@ -20,6 +20,8 @@ pub struct SpendControlLimitDetails {
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub source: Option<Option<String>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub unit: Option<String>,
|
||||
#[serde(rename = "limit")]
|
||||
pub limit: String,
|
||||
#[serde(rename = "used")]
|
||||
@@ -48,6 +50,7 @@ impl SpendControlLimitDetails {
|
||||
) -> SpendControlLimitDetails {
|
||||
SpendControlLimitDetails {
|
||||
source: None,
|
||||
unit: None,
|
||||
limit,
|
||||
used,
|
||||
remaining,
|
||||
|
||||
Reference in New Issue
Block a user