feat: validate model IDs before processing requests
Add model validation cache with 5-minute TTL to reject invalid model IDs upfront instead of sending them to the API. This provides better error messages and avoids unnecessary API calls. - Add MODEL_VALIDATION_CACHE_TTL_MS constant (5 min) - Add isValidModel() with lazy cache population - Warm cache when listModels() is called - Validate model ID in /v1/messages before processing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,9 @@ export const GEMINI_SKIP_SIGNATURE = 'skip_thought_signature_validator';
|
||||
// Cache TTL for Gemini thoughtSignatures (2 hours)
|
||||
export const GEMINI_SIGNATURE_CACHE_TTL_MS = 2 * 60 * 60 * 1000;
|
||||
|
||||
// Cache TTL for model validation (5 minutes)
|
||||
export const MODEL_VALIDATION_CACHE_TTL_MS = 5 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* Get the model family from model name (dynamic detection, no hardcoded list).
|
||||
* @param {string} modelName - The model name from the request
|
||||
@@ -295,6 +298,7 @@ export default {
|
||||
GEMINI_MAX_OUTPUT_TOKENS,
|
||||
GEMINI_SKIP_SIGNATURE,
|
||||
GEMINI_SIGNATURE_CACHE_TTL_MS,
|
||||
MODEL_VALIDATION_CACHE_TTL_MS,
|
||||
getModelFamily,
|
||||
isThinkingModel,
|
||||
OAUTH_CONFIG,
|
||||
|
||||
Reference in New Issue
Block a user