-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
I'm getting a 502 (bad gateway) when calling my serverless function (API endpoint) that has a streaming response:
src/routes/api/soap/format.ts
...
export const POST: RequestHandler = async ({ request }) => {
response = await openai.createChatCompletion({
model: model,
messages: [{ role: 'user', content: prompt }],
stream: true,
}, { responseType: 'stream' }
);
const customReadable = new ReadableStream({
start(controller) {
response.data.on('data', (data: Buffer) => {
// ...etc
});
}
});
return new Response(customReadable, {
headers: { 'Content-Type': 'text/html; charset=utf-8' },
});
...
This works locally. Any idea what needs to be adjusted on CloudFront or Lambda to allow for streaming output?
Metadata
Metadata
Assignees
Labels
No labels