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

Function fetchAnthropicModels

core/llm/fetchModels.ts:152–174  ·  view source on GitHub ↗
(apiKey?: string)

Source from the content-addressed store, hash-verified

150}
151
152async function fetchAnthropicModels(apiKey?: string): Promise<FetchedModel[]> {
153 const response = await fetch(
154 "https://api.anthropic.com/v1/models?limit=100",
155 {
156 headers: {
157 "x-api-key": apiKey ?? "",
158 "anthropic-version": "2023-06-01",
159 },
160 },
161 );
162 if (!response.ok) {
163 throw new Error(`Failed to fetch Anthropic models: ${response.status}`);
164 }
165 const data = await response.json();
166 return (data.data ?? []).map((m: any) => ({
167 name: m.display_name ?? m.id,
168 modelId: m.id,
169 icon: "anthropic.png",
170 contextLength: m.max_input_tokens,
171 maxTokens: m.max_tokens,
172 supportsTools: true,
173 }));
174}
175
176async function fetchGeminiModels(
177 apiKey?: string,

Callers 1

fetchModelsFunction · 0.85

Calls 1

fetchFunction · 0.70

Tested by

no test coverage detected