(apiKey: string)
| 130 | } |
| 131 | |
| 132 | export async function fetchMistralModels(apiKey: string): Promise<string[]> { |
| 133 | try { |
| 134 | const response = await fetch('https://api.mistral.ai/v1/models', { |
| 135 | headers: { |
| 136 | Authorization: `Bearer ${apiKey}` |
| 137 | } |
| 138 | }); |
| 139 | |
| 140 | if (!response.ok) { |
| 141 | return MODEL_LIST.mistral; |
| 142 | } |
| 143 | |
| 144 | const data = await response.json(); |
| 145 | const models = data.data?.map((m: { id: string }) => m.id).sort(); |
| 146 | |
| 147 | return models && models.length > 0 ? models : MODEL_LIST.mistral; |
| 148 | } catch { |
| 149 | return MODEL_LIST.mistral; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | export async function fetchGroqModels(apiKey: string): Promise<string[]> { |
| 154 | try { |
no test coverage detected