MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / fetchOpenRouterModels

Function fetchOpenRouterModels

out/cli.cjs:86312–86330  ·  view source on GitHub ↗
(apiKey)

Source from the content-addressed store, hash-verified

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}
86318async 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 {

Callers 1

fetchModelsForProviderFunction · 0.70

Calls 3

filterMethod · 0.80
jsonMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…