2
0
Files
bot/packages/forge/blocks/mistral/helpers/fetchModels.ts
2024-06-18 12:13:00 +02:00

21 lines
438 B
TypeScript

import ky from 'ky'
import { apiBaseUrl } from '../constants'
export const fetchModels = async ({
credentials,
}: {
credentials?: { apiKey?: string }
}) => {
if (!credentials?.apiKey) return []
const { data } = await ky
.get(apiBaseUrl + '/v1/models', {
headers: {
Authorization: `Bearer ${credentials.apiKey}`,
},
})
.json<{ data: { id: string }[] }>()
return data.map((model) => model.id)
}