//native
type Groq = {
api_key: string;
};
/**
* List models
* get all available models
*/
export async function main(auth: Groq) {
const url = new URL(`https://api.groq.com/openai/v1/models`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.api_key,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago