add api key

This commit is contained in:
Mckay Wrigley
2023-03-18 22:19:19 -06:00
parent 396fe4ec6f
commit e6449998ef
6 changed files with 101 additions and 9 deletions
+3 -2
View File
@@ -7,9 +7,10 @@ export const config = {
const handler = async (req: Request): Promise<Response> => {
try {
const { model, messages } = (await req.json()) as {
const { model, messages, key } = (await req.json()) as {
model: OpenAIModel;
messages: Message[];
key: string;
};
const charLimit = 12000;
@@ -25,7 +26,7 @@ const handler = async (req: Request): Promise<Response> => {
messagesToSend.push(message);
}
const stream = await OpenAIStream(model, messagesToSend);
const stream = await OpenAIStream(model, key, messagesToSend);
return new Response(stream);
} catch (error) {