update pay function
This commit is contained in:
43
boilerplate-chakra-pro-main/app/api/premiumEssayAPI/route.ts
Normal file
43
boilerplate-chakra-pro-main/app/api/premiumEssayAPI/route.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { PremiumEssayBody } from '@/types/types';
|
||||
import { OpenAIStream } from '@/utils/streams/premiumEssayStream';
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
const handler = async (req: Request): Promise<Response> => {
|
||||
try {
|
||||
const {
|
||||
words,
|
||||
topic,
|
||||
essayType,
|
||||
tone,
|
||||
citation,
|
||||
level,
|
||||
citations,
|
||||
model,
|
||||
apiKey
|
||||
} = (await req.json()) as PremiumEssayBody;
|
||||
|
||||
if (!apiKey) {
|
||||
return new Response('API key not found', { status: 500 });
|
||||
}
|
||||
|
||||
const stream = await OpenAIStream(
|
||||
words,
|
||||
topic,
|
||||
essayType,
|
||||
tone,
|
||||
citation,
|
||||
level,
|
||||
citations,
|
||||
model,
|
||||
apiKey
|
||||
);
|
||||
|
||||
return new Response(stream);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return new Response('Error', { status: 500 });
|
||||
}
|
||||
};
|
||||
|
||||
export default handler;
|
||||
Reference in New Issue
Block a user