feat(api-key): add independent quota and expiration support
This feature allows API Keys to have their own quota limits and expiration times, independent of the user's balance. Backend: - Add quota, quota_used, expires_at fields to api_key schema - Implement IsExpired() and IsQuotaExhausted() checks in middleware - Add ResetQuota and ClearExpiration API endpoints - Integrate quota billing in gateway handlers (OpenAI, Anthropic, Gemini) - Include quota/expiration fields in auth cache for performance - Expiration check returns 403, quota exhausted returns 429 Frontend: - Add quota and expiration inputs to key create/edit dialog - Add quick-select buttons for expiration (+7, +30, +90 days) - Add reset quota confirmation dialog - Add expires_at column to keys list - Add i18n translations for new features (en/zh) Migration: - Add 045_add_api_key_quota.sql for new columns
This commit is contained in:
@@ -407,6 +407,7 @@ export default {
|
||||
usage: 'Usage',
|
||||
today: 'Today',
|
||||
total: 'Total',
|
||||
quota: 'Quota',
|
||||
useKey: 'Use Key',
|
||||
useKeyModal: {
|
||||
title: 'Use API Key',
|
||||
@@ -470,6 +471,33 @@ export default {
|
||||
geminiCli: 'Gemini CLI',
|
||||
geminiCliDesc: 'Import as Gemini CLI configuration',
|
||||
},
|
||||
// Quota and expiration
|
||||
quotaLimit: 'Quota Limit',
|
||||
quotaAmount: 'Quota Amount (USD)',
|
||||
quotaAmountPlaceholder: 'Enter quota limit in USD',
|
||||
quotaAmountHint: 'Set the maximum amount this key can spend. 0 = unlimited.',
|
||||
quotaUsed: 'Quota Used',
|
||||
reset: 'Reset',
|
||||
resetQuotaUsed: 'Reset used quota to 0',
|
||||
resetQuotaTitle: 'Confirm Reset Quota',
|
||||
resetQuotaConfirmMessage: 'Are you sure you want to reset the used quota (${used}) for key "{name}" to 0? This action cannot be undone.',
|
||||
quotaResetSuccess: 'Quota reset successfully',
|
||||
failedToResetQuota: 'Failed to reset quota',
|
||||
expiration: 'Expiration',
|
||||
expiresInDays: '{days} days',
|
||||
extendDays: '+{days} days',
|
||||
customDate: 'Custom',
|
||||
expirationDate: 'Expiration Date',
|
||||
expirationDateHint: 'Select when this API key should expire.',
|
||||
currentExpiration: 'Current expiration',
|
||||
expiresAt: 'Expires',
|
||||
noExpiration: 'Never',
|
||||
status: {
|
||||
active: 'Active',
|
||||
inactive: 'Inactive',
|
||||
quota_exhausted: 'Quota Exhausted',
|
||||
expired: 'Expired',
|
||||
},
|
||||
},
|
||||
|
||||
// Usage
|
||||
|
||||
Reference in New Issue
Block a user