This commit is contained in:
Mckay Wrigley
2023-03-22 12:55:20 -06:00
parent 1ebae96dca
commit ec20db24de
6 changed files with 21 additions and 10 deletions
+5
View File
@@ -9,6 +9,7 @@ const handler = async (req: Request): Promise<Response> => {
const { key } = (await req.json()) as {
key: string;
};
console.log("key", key);
const response = await fetch("https://api.openai.com/v1/models", {
headers: {
@@ -23,6 +24,8 @@ const handler = async (req: Request): Promise<Response> => {
const json = await response.json();
console.log("json", json);
const models: OpenAIModel[] = json.data
.map((model: any) => {
for (const [key, value] of Object.entries(OpenAIModelID)) {
@@ -36,6 +39,8 @@ const handler = async (req: Request): Promise<Response> => {
})
.filter(Boolean);
console.log("models", models);
return new Response(JSON.stringify(models), { status: 200 });
} catch (error) {
console.error(error);