MCPcopy
hub / github.com/continuedev/continue / fetchProviderModelsViaListModels

Function fetchProviderModelsViaListModels

core/llm/fetchModels.ts:218–239  ·  view source on GitHub ↗
(
  provider: string,
  apiKey?: string,
  apiBase?: string,
)

Source from the content-addressed store, hash-verified

216}
217
218async function fetchProviderModelsViaListModels(
219 provider: string,
220 apiKey?: string,
221 apiBase?: string,
222): Promise<FetchedModel[]> {
223 try {
224 const cls = LLMClasses.find((llm) => llm.providerName === provider);
225 const defaultApiBase = cls?.defaultOptions?.apiBase;
226
227 const llm = llmFromProviderAndOptions(provider, {
228 apiKey,
229 apiBase: apiBase || defaultApiBase,
230 model: "",
231 });
232 const modelIds = await llm.listModels();
233 return modelIds.map((id) => ({ name: id }));
234 } catch (error: any) {
235 throw new Error(
236 `Failed to fetch models for ${provider}: ${error?.message ?? error}`,
237 );
238 }
239}
240
241export async function fetchModels(
242 provider: string,

Callers 1

fetchModelsFunction · 0.85

Calls 2

listModelsMethod · 0.65

Tested by

no test coverage detected