import { createFlow, extract } from '@docloai/flows';
import { createVLMProvider } from '@docloai/providers-llm';
const provider = createVLMProvider({
provider: 'google',
model: 'google/gemini-2.5-flash-preview-09-2025',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
});
const reportSchema = {
type: 'object',
properties: {
title: { type: 'string' },
author: { type: 'string' },
date: { type: 'string' },
executiveSummary: { type: 'string' },
sections: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
content: { type: 'string' },
pageNumber: { type: 'number' }
}
}
},
keyFindings: {
type: 'array',
items: { type: 'string' }
}
}
};
const flow = createFlow()
.step('extract', extract({
provider,
schema: reportSchema
}))
.build();
// Process a 200-page annual report
const result = await flow.run({
base64: 'data:application/pdf;base64,...'
});
console.log(`Found ${result.output.sections.length} sections`);
console.log('Key findings:', result.output.keyFindings);