import { createFlow, extract } from '@docloai/flows';
import { createVLMProvider } from '@docloai/providers-llm';
const provider = createVLMProvider({
provider: 'xai',
model: 'x-ai/grok-4.1',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
});
const techDocSchema = {
type: 'object',
properties: {
title: { type: 'string' },
version: { type: 'string' },
components: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
specifications: {
type: 'object',
additionalProperties: { type: 'string' }
}
}
}
},
requirements: {
type: 'array',
items: { type: 'string' }
}
}
};
const flow = createFlow()
.step('extract', extract({
provider,
schema: techDocSchema
}))
.build();
const result = await flow.run({
base64: 'data:application/pdf;base64,...'
});
console.log(result.output.components);