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.baseUrl.replace(/\/$/, '')}/models`, {
382 method: 'GET',
383 headers: {
384 Authorization: `Bearer ${config.apiKey}`
385 }
386 })
387
388 if (!response.ok) {
389 return {
390 success: false,
391 error: `HTTP ${response.status}: ${response.statusText}`
392 }
393 }
394
395 const data = await response.json()
396 const models = data.data?.map((model: { id: string }) => model.id) || []
397 return { success: true, models }
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 1

setupAIHandlersFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected