diff --git a/open-sse/services/usage.ts b/open-sse/services/usage.ts index d1508855..18c2df67 100644 --- a/open-sse/services/usage.ts +++ b/open-sse/services/usage.ts @@ -318,7 +318,7 @@ async function getAntigravityUsage(accessToken, providerSpecificData) { // Filter only recommended/important models (must match PROVIDER_MODELS ag ids) const importantModels = [ "claude-opus-4-6-thinking", - "claude-sonnet-4-6-thinking", + "claude-sonnet-4-6", "gemini-3.1-pro-high", "gemini-3.1-pro-low", "gemini-3-flash", diff --git a/src/shared/utils/apiKeyPolicy.ts b/src/shared/utils/apiKeyPolicy.ts index 9a314d8a..a009684c 100644 --- a/src/shared/utils/apiKeyPolicy.ts +++ b/src/shared/utils/apiKeyPolicy.ts @@ -13,12 +13,23 @@ import { getApiKeyMetadata, isModelAllowedForKey } from "@/lib/localDb"; import { checkBudget } from "@/domain/costRules"; import { errorResponse } from "@omniroute/open-sse/utils/error.ts"; import { HTTP_STATUS } from "@omniroute/open-sse/config/constants.ts"; +import * as log from "@/sse/utils/logger"; + +/** Metadata stored for an API key in the local database. */ +export interface ApiKeyMetadata { + id: string; + name?: string; + allowedModels?: string[]; + budget?: number; + usedBudget?: number; + [key: string]: unknown; +} export interface ApiKeyPolicyResult { /** API key string (null if no key provided) */ apiKey: string | null; /** Metadata from DB (null if no key or key not found) */ - apiKeyInfo: any | null; + apiKeyInfo: ApiKeyMetadata | null; /** If set, the request should be rejected with this Response */ rejection: Response | null; } @@ -53,11 +64,12 @@ export async function enforceApiKeyPolicy( } // Fetch key metadata (includes allowedModels) - let apiKeyInfo: any = null; + let apiKeyInfo: ApiKeyMetadata | null = null; try { apiKeyInfo = await getApiKeyMetadata(apiKey); - } catch { - // If metadata fetch fails, don't block — degrade gracefully + } catch (error) { + // If metadata fetch fails, don't block — degrade gracefully, but log for debugging + log.warn("API_POLICY", "Failed to fetch API key metadata. Request will be allowed.", { error }); return { apiKey, apiKeyInfo: null, rejection: null }; } @@ -95,8 +107,9 @@ export async function enforceApiKeyPolicy( ), }; } - } catch { - // Budget check is best-effort — don't block on errors + } catch (error) { + // Budget check is best-effort — don't block on errors, but log them + log.warn("API_POLICY", "Budget check failed. Request will be allowed.", { error }); } }