MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / fetchAnthropicModels

Function fetchAnthropicModels

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

Source from the content-addressed store, hash-verified

86258 return [];
86259 }
86260 const data = await response.json();
86261 return data.data?.map((m5) => m5.id) || [];
86262 } catch {
86263 return [];
86264 }
86265}
86266async function fetchAnthropicModels(apiKey) {
86267 try {
86268 const response = await fetch("https://api.anthropic.com/v1/models", {
86269 headers: {
86270 "x-api-key": apiKey,
86271 "anthropic-version": "2023-06-01"
86272 }
86273 });
86274 if (!response.ok) {
86275 return MODEL_LIST.anthropic;
86276 }
86277 const data = await response.json();
86278 const models = data.data?.map((m5) => m5.id).filter((id) => id.startsWith("claude-")).sort();
86279 return models && models.length > 0 ? models : MODEL_LIST.anthropic;
86280 } catch {

Callers 1

fetchModelsForProviderFunction · 0.70

Calls 4

filterMethod · 0.80
startsWithMethod · 0.80
jsonMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected