MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / resolveProviderEndpoint

Function resolveProviderEndpoint

src/tools/vision/vision-analyze.ts:107–121  ·  view source on GitHub ↗

Map a provider NAME to its OpenAI-compatible {baseUrl, apiKey}, or undefined if it * isn't an OpenAI-compatible HTTP provider with a key set. (anthropic/ollama/lm-studio * are intentionally excluded — they're handled by their own dedicated backends.)

(cfg: any, providerName?: string)

Source from the content-addressed store, hash-verified

105 * isn't an OpenAI-compatible HTTP provider with a key set. (anthropic/ollama/lm-studio
106 * are intentionally excluded — they're handled by their own dedicated backends.) */
107function resolveProviderEndpoint(cfg: any, providerName?: string): { baseUrl: string; apiKey: string } | undefined {
108 if (!providerName) return undefined;
109 const norm = (u: string) => u.replace(/\/+$/, '');
110 const custom = (cfg.providers?.custom ?? []).find((c: any) => c?.name === providerName);
111 if (custom?.baseUrl && custom?.apiKeyEnv && /^https?:\/\//.test(custom.baseUrl)) {
112 const key = process.env[custom.apiKeyEnv];
113 if (key) return { baseUrl: norm(custom.baseUrl), apiKey: key };
114 }
115 if (providerName === 'openai') {
116 const key = process.env[cfg.providers?.openai?.apiKeyEnv ?? 'OPENAI_API_KEY'];
117 const baseUrl = cfg.providers?.openai?.baseUrl ?? 'https://api.openai.com/v1';
118 if (key && /^https?:\/\//.test(baseUrl)) return { baseUrl: norm(baseUrl), apiKey: key };
119 }
120 return undefined;
121}
122
123const VisionAnalyzeArgs = z.object({
124 image_path: z.string().min(1).describe('Path to a PNG/JPEG/WebP file on disk. Often the result of browser_screenshot.'),

Callers 1

Calls 1

normFunction · 0.70

Tested by

no test coverage detected