MCPcopy
hub / github.com/codedogQBY/ReadAny / fetchGoogleModels

Function fetchGoogleModels

packages/core/src/stores/settings-store.ts:241–269  ·  view source on GitHub ↗

Google Gemini — list models via generativelanguage API

(endpoint: AIEndpoint)

Source from the content-addressed store, hash-verified

239
240/** Google Gemini — list models via generativelanguage API */
241async function fetchGoogleModels(endpoint: AIEndpoint): Promise<string[]> {
242 const requestUrl = buildProviderModelsUrl(
243 "google",
244 endpoint.baseUrl,
245 endpoint.apiKey,
246 endpoint.useExactRequestUrl,
247 );
248 const response = await fetch(requestUrl);
249 if (!response.ok) {
250 if (response.status === 404 || response.status === 403) {
251 return [
252 "gemini-2.5-pro",
253 "gemini-2.5-flash",
254 "gemini-2.0-flash",
255 "gemini-2.0-flash-lite",
256 "gemini-1.5-pro",
257 "gemini-1.5-flash",
258 ];
259 }
260 throw new Error(`Failed to fetch Google models: ${response.status} ${response.statusText}`);
261 }
262 const data = await response.json();
263 return (data.models || [])
264 .filter((m: { name: string; supportedGenerationMethods?: string[] }) =>
265 m.supportedGenerationMethods?.includes("generateContent"),
266 )
267 .map((m: { name: string }) => m.name.replace("models/", ""))
268 .sort((a: string, b: string) => a.localeCompare(b));
269}
270
271/** DeepSeek — uses OpenAI-compatible /models endpoint with fallback */
272async function fetchDeepSeekModels(endpoint: AIEndpoint): Promise<string[]> {

Callers 1

fetchModelsFromEndpointFunction · 0.70

Calls 4

buildProviderModelsUrlFunction · 0.90
mapMethod · 0.80
replaceMethod · 0.80
fetchFunction · 0.50

Tested by

no test coverage detected