Infer Schema from File
Analyze a file and infer a JSON Schema from its contents.
Accepts a file via multipart form upload and uses Gemini to analyze the document, returning a description of its contents, an inferred JSON Schema capturing all extractable fields, and document classification metadata.
The returned schema is designed to be reusable across many similar documents of the same type, not just the specific file uploaded. It can be used directly as the outputSchema when creating a Transform function.
The endpoint also detects whether the file contains multiple bundled documents and classifies the content nature (textual, visual, audio, video, or mixed).
Supported file types
PDF, PNG, JPEG, HEIC, HEIF, WebP, CSV, XLS, XLSX, DOCX, JSON, HTML, XML, EML, plain text, WAV, MP3, M4A, MP4.
File size limit
Maximum file size is 20 MB.
Examples
Using curl:
curl -X POST https://api.bem.ai/v3/infer-schema \
-H "x-api-key: YOUR_API_KEY" \
-F "file=@invoice.pdf"
Using the Bem CLI:
bem infer-schema create --file @invoice.pdf
Response
The request has succeeded.