mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-23 00:00:28 +00:00
feat: add account egress and client key USD budgets
Import sub2api proxy bindings, enforce durable daily and seven-day budgets alongside existing key concurrency, and integrate matching admin controls and audited reconciliation.
This commit is contained in:
@@ -110,6 +110,7 @@ export interface AccountUsage {
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
outboundProxyEndpoint: string | null
|
||||
id: string
|
||||
name: string
|
||||
provider: string
|
||||
@@ -288,6 +289,7 @@ interface AccountResetCreditConsumeParam extends AccountIdParam {
|
||||
}
|
||||
|
||||
interface AccountUpdateParam {
|
||||
outboundProxyUrl?: string
|
||||
accountId: string
|
||||
enabled: boolean
|
||||
concurrencyLimit: number | null
|
||||
@@ -296,6 +298,7 @@ interface AccountUpdateParam {
|
||||
}
|
||||
|
||||
interface AccountBatchUpdateParam {
|
||||
outboundProxyUrl?: string
|
||||
accountIds: string[]
|
||||
enabled: boolean
|
||||
concurrencyLimit: number | null
|
||||
@@ -314,6 +317,7 @@ interface AccountImportParam {
|
||||
}
|
||||
|
||||
interface AccountOAuthStartParam {
|
||||
outboundProxyUrl?: string
|
||||
provider: string
|
||||
name: string
|
||||
accountId?: string
|
||||
|
||||
@@ -11,6 +11,13 @@ export interface ApiKey {
|
||||
enabled: boolean
|
||||
maxConcurrency: number
|
||||
requestsPerMinute: number
|
||||
dailyLimitUsd: string
|
||||
weeklyLimitUsd: string
|
||||
dailyUsedUsd: string
|
||||
weeklyUsedUsd: string
|
||||
dailyResetsAt: string | null
|
||||
weeklyResetsAt: string | null
|
||||
unresolvedRequests: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
lastUsedAt: string | null
|
||||
@@ -40,6 +47,21 @@ export interface ApiKeyMutationResponse {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface UnresolvedClientCharge {
|
||||
requestId: string
|
||||
startedAt: string
|
||||
completedAt: string | null
|
||||
state: string
|
||||
}
|
||||
|
||||
export function getUnresolvedClientCharges(id: string) {
|
||||
return request<{ items: UnresolvedClientCharge[] }>({ url: '/api/admin/client-keys/unresolved-charges', method: 'GET', params: { id } })
|
||||
}
|
||||
|
||||
export function reconcileClientCharge(data: { id: string, requestId: string, amountUsd: string, reason: string }) {
|
||||
return request<{ reconciled: boolean }>({ url: '/api/admin/client-keys/reconcile-charge', method: 'POST', data })
|
||||
}
|
||||
|
||||
// 请求参数类型:仅定义 API 边界的形状,调用方不依赖显式声明。
|
||||
interface ApiKeyListParams {
|
||||
cursor?: string
|
||||
@@ -55,6 +77,8 @@ export interface ApiKeyWriteParam {
|
||||
groupIds: string[]
|
||||
maxConcurrency: number
|
||||
requestsPerMinute: number
|
||||
dailyLimitUsd: string
|
||||
weeklyLimitUsd: string
|
||||
}
|
||||
|
||||
interface ApiKeyUpdateParam extends ApiKeyWriteParam {
|
||||
|
||||
Reference in New Issue
Block a user