Back to prompt library
AI SDK Route Handler Implementation
Linked challenge: AI SDK & Bolt.new Citizen LifeSG Workflow Automation
Prompt source
implementation15 lines2 sectionsNo variables0 checklist items
import { generateObject } from 'ai';
import { openai } from '@ai-sdk/openai';
import { z } from 'zod';
export async function POST(req: Request) {
const { documentText } = await req.json();
const result = await generateObject({
model: openai('gpt-4o'),
schema: z.object({
eligible: z.boolean(),
extracted_nric: z.string(),
}),
prompt: `Analyze this LifeSG claim: ${documentText}`
});
return Response.json(result.object);
}