(apiKey)
| 86310 | } |
| 86311 | const data = await response.json(); |
| 86312 | const models = data.data?.map((m5) => m5.id).sort(); |
| 86313 | return models && models.length > 0 ? models : MODEL_LIST.groq; |
| 86314 | } catch { |
| 86315 | return MODEL_LIST.groq; |
| 86316 | } |
| 86317 | } |
| 86318 | async function fetchOpenRouterModels(apiKey) { |
| 86319 | try { |
| 86320 | const response = await fetch("https://openrouter.ai/api/v1/models", { |
| 86321 | headers: { |
| 86322 | Authorization: `Bearer ${apiKey}` |
| 86323 | } |
| 86324 | }); |
| 86325 | if (!response.ok) { |
| 86326 | return MODEL_LIST.openrouter; |
| 86327 | } |
| 86328 | const data = await response.json(); |
| 86329 | const models = data.data?.filter( |
| 86330 | (m5) => m5.context_length && m5.context_length > 0 |
| 86331 | ).map((m5) => m5.id).sort(); |
| 86332 | return models && models.length > 0 ? models : MODEL_LIST.openrouter; |
| 86333 | } catch { |
no test coverage detected
searching dependent graphs…