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

Function fetchOpenRouterModels

src/utils/modelCache.ts:174–200  ·  view source on GitHub ↗
(apiKey: string)

Source from the content-addressed store, hash-verified

172}
173
174export async function fetchOpenRouterModels(apiKey: string): Promise<string[]> {
175 try {
176 const response = await fetch('https://openrouter.ai/api/v1/models', {
177 headers: {
178 Authorization: `Bearer ${apiKey}`
179 }
180 });
181
182 if (!response.ok) {
183 return MODEL_LIST.openrouter;
184 }
185
186 const data = await response.json();
187 // Filter to text-capable models only (exclude image/audio models)
188 const models = data.data
189 ?.filter(
190 (m: { id: string; context_length?: number }) =>
191 m.context_length && m.context_length > 0
192 )
193 .map((m: { id: string }) => m.id)
194 .sort();
195
196 return models && models.length > 0 ? models : MODEL_LIST.openrouter;
197 } catch {
198 return MODEL_LIST.openrouter;
199 }
200}
201
202export async function fetchDeepSeekModels(apiKey: string): Promise<string[]> {
203 try {

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…