About Example Scenario
This example demonstrates a practical use case for Direct LLM Call: extracting structured information from a business document. We have a PDF invoice and need to extract key financial information in a type-safe, validated format. This scenario showcases:- Document processing with attachments
- Structured output using Pydantic models
- Simple, direct execution without agent complexity
- Type-safe data extraction
Direct LLM Call Configuration
Model Selection: We use"openai/gpt-4o" for its strong vision and reasoning capabilities, essential for document understanding.
Task Configuration:
- Description: Clear instruction for the LLM
- Attachments: PDF document passed as attachment for processing
- Response Format: Pydantic model (
InvoiceData) ensures validated, structured output with required fields
- Invoice number (string)
- Total amount (float)
- Issue date (string)
- List of line items with name and amount
Full Code
- Automatic PDF processing through attachments
- Type-safe structured output with Pydantic validation
- Clean, synchronous API for straightforward use cases
- Zero configuration for memory or tools
- Automatic MIME type detection for attachments

