Spaces:
Build error
Build error
File size: 667 Bytes
1a5cd30 4e071a3 75fefa7 4e071a3 75fefa7 4e071a3 75fefa7 1a5cd30 4e071a3 1a5cd30 75fefa7 1a5cd30 4e071a3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import { streamText } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';
// Create an OpenAI API client (that's edge friendly!)
const customOpenAI = createOpenAI({
apiKey: process.env.HELMHOLTZ_API_KEY || '',
baseURL: 'https://api.helmholtz-blablador.fz-juelich.de/v1',
});
// IMPORTANT! Set the runtime to edge
export const runtime = 'edge';
export async function POST(req: Request) {
const { prompt, model } = await req.json();
const result = await streamText({
model: customOpenAI(model || 'alias-code'),
messages: [
{
role: 'user',
content: prompt,
},
],
});
return result.toTextStreamResponse();
}
|