LLM Extraction
When built-in extractors and heuristics fail, AgentInbox can use GPT-4o-mini to read and extract data from emails. This is the final stage of the universal extraction pipeline.
How It Works
The LLM receives the email subject, body text, and requested extraction type. It returns the extracted value and a confidence score.
LLM Prompt Structure
- Subject: Email subject line
- Body: Plain text content (HTML stripped)
- Type: The requested extraction type (otp, magic_link, etc.)
- Output: Extracted value and confidence score (0-1)
Feature Flag
LLM extraction is enabled by default but can be disabled per-request or at the account level.
typescript
const extraction = await client.extractions.create({ messageId: "msg_456", type: "otp", useLlm: true, // Explicitly enable LLM});python
extraction = client.extractions.create( message_id="msg_456", type="otp", use_llm=True, # Explicitly enable LLM)To disable LLM extraction for your entire account, go to Settings > Extraction in the dashboard and toggle LLM Fallback off.
Cost
LLM extraction incurs a small additional cost per request due to OpenAI API usage.
- Free tier: 50 LLM extractions per month included
- Pro tier: 500 LLM extractions per month included
- Overage: $0.005 per LLM extraction after included limit
- Built-in extractors: Always free, no limit
Watch your usage
LLM extraction costs can add up in high-volume workflows. Use built-in extractors when possible and only enable LLM fallback for edge cases.
Latency
LLM extraction is slower than built-in extractors due to the round-trip to OpenAI.
- Built-in: 10-50ms
- LLM: 500-2000ms
When to Use LLM
- Non-standard email formats that built-in extractors don't handle
- Complex multi-step instructions where the data is embedded in narrative text
- Rare extraction types not covered by the 8 built-in types
- When confidence from built-in extractors is below your threshold
Best practice
Start with built-in extractors. Only enable LLM fallback when you encounter emails that pattern matching cannot handle.