* Check if an account is rate-limited for a specific model.
(account, modelKey, now)
| 1085 | * Check if an account is rate-limited for a specific model. |
| 1086 | */ |
| 1087 | function isRateLimitedForModel(account, modelKey, now) { |
| 1088 | // Global rate limit |
| 1089 | if (account.rateLimitedUntil && account.rateLimitedUntil > now) return true; |
| 1090 | // Per-model rate limit |
| 1091 | if (modelKey && account._modelRateLimits) { |
| 1092 | const until = account._modelRateLimits[modelKey]; |
| 1093 | if (until && until > now) return true; |
| 1094 | // Clean up expired entries |
| 1095 | if (until && until <= now) delete account._modelRateLimits[modelKey]; |
| 1096 | } |
| 1097 | return false; |
| 1098 | } |
| 1099 | |
| 1100 | /** |
| 1101 | * Report an error for an API key (increment error count, auto-disable). |
no outgoing calls
no test coverage detected