MCPcopy Create free account
hub / github.com/experdot/pointer / getModels

Method getModels

src/main/aiHandler.ts:377–404  ·  view source on GitHub ↗
(
    config: LLMConfig
  )

Source from the content-addressed store, hash-verified

375 }
376
377 public async getModels(
378 config: LLMConfig
379 ): Promise<{ success: boolean; models?: string[]; error?: string }> {
380 try {
381 const response = await fetch(`${config.apiHost.replace(/\/$/, '')}/models`, {
382 method: 'GET',
383 headers: {
384 Authorization: `Bearer ${config.apiKey}`
385 }
386 })
387
388 if (response.ok) {
389 const data = await response.json()
390 const models = data.data?.map((model: any) => model.id) || []
391 return { success: true, models }
392 } else {
393 return {
394 success: false,
395 error: `HTTP ${response.status}: ${response.statusText}`
396 }
397 }
398 } catch (error) {
399 return {
400 success: false,
401 error: error instanceof Error ? error.message : 'Failed to fetch models'
402 }
403 }
404 }
405}
406
407export const aiHandler = new AIHandler()

Callers 2

fetchModelsFunction · 0.80
setupAIHandlersFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected