Supplier Invoice Routing: One Compatible API Across OpenAI, Claude, and Gemini
Описание и применение
Унифицированный подход к извлечению данных из счетов поставщиков использует один совместимый с OpenAI API, позволяя динамически выбирать модели по критериям латентности и качества, упрощая код и ускоряя обработку.
Задача
Integrating multiple LLM providers for supplier invoice extraction required separate handlers, credentials, and response mappings, leading to code duplication and maintenance overhead.
Результат
The unified API approach reduced backend complexity, enabled dynamic model selection based on latency vs. quality, and streamlined error handling and human escalation.
Рабочий процесс
- 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.
Доказательства
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.
- Дата записи: 2026-10-04T22:40:54.170Z