( modelId: string )
| 66 | * Fetches from API if cache is stale or empty. |
| 67 | */ |
| 68 | export async function getOpenRouterModelCapabilities( |
| 69 | modelId: string |
| 70 | ): Promise<ModelCapabilities | null> { |
| 71 | const now = Date.now() |
| 72 | |
| 73 | if (!modelCapabilitiesCache || now - cacheTimestamp > CACHE_TTL_MS) { |
| 74 | modelCapabilitiesCache = await fetchModelCapabilities() |
| 75 | cacheTimestamp = now |
| 76 | } |
| 77 | |
| 78 | const normalizedId = modelId.replace(/^openrouter\//, '') |
| 79 | return modelCapabilitiesCache.get(normalizedId) ?? null |
| 80 | } |
| 81 | |
| 82 | export async function supportsNativeStructuredOutputs(modelId: string): Promise<boolean> { |
| 83 | const capabilities = await getOpenRouterModelCapabilities(modelId) |
no test coverage detected