type Openai = {
api_key: string;
organization_id: string;
};
/**
* List models
* Lists the currently available models, and provides basic information about each one such as the owner and availability.
*/
export async function main(auth: Openai) {
const url = new URL(`https://api.openai.com/v1/models`);
const response = await fetch(url, {
method: "GET",
headers: {
"OpenAI-Organization": auth.organization_id,
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 369 days ago