Supplier Invoice Routing: One Compatible API Across OpenAI, Claude, and Gemini
Description and use
A unified approach to supplier invoice extraction uses a single OpenAI‑compatible API, enabling dynamic model selection based on latency and quality, simplifying code and speeding processing.
Problem
Integrating multiple LLM providers for supplier invoice extraction required separate handlers, credentials, and response mappings, leading to code duplication and maintenance overhead.
Outcome
The unified API approach reduced backend complexity, enabled dynamic model selection based on latency vs. quality, and streamlined error handling and human escalation.
Workflow
- 1. Configure INFRAI_MODEL to a verified model ID from the Infrai catalog.
- 2. Send invoice text to the Infrai chat completions endpoint with a system prompt that specifies the six fields and JSON output.
- 3. Receive JSON response and perform local validation (JSON schema, type checks, arithmetic consistency).
- 4. If validation passes, accept the record; otherwise, retry with a higher‑quality model or enqueue for human review.
Evidence
Put supplier‑invoice extraction behind one OpenAI‑compatible Chat Completions request, then route by an explicit quality‑versus‑latency policy.
Before, the route is a vendor switch statement spread across handlers, with separate credentials and response mappings. After, the route selects a model string and calls one extraction function.
The contract stays put while the provider behind the capability moves.
- Record date: 2026-10-04T22:40:54.170Z