Supplier Invoice Image Upload Moderation: Multimodal Chat Classifies NSFW and Violence
Description and use
Invoice image moderation is performed via Infrai’s multimodal chat model, returning a strict JSON schema. Decisions are stored as raw model responses and normalized allow/hold/block statuses, enabling quick extraction control.
Problem
Support agents need quick, trustworthy safety decisions on supplier invoice images before extraction, but no dedicated image‑moderation endpoint exists in Infrai.
Outcome
The service now reliably classifies invoice images for NSFW and violence, with clear failure handling and policy versioning. Moderation latency is bounded, and raw responses are preserved for audit and future policy changes.
Workflow
- 1. Receive image URL and policy version from intake service.
- 2. Build a chat request with text prompt and image URL, specifying response_format as a strict JSON schema.
- 3. Send request to /v1/chat/completions with retry logic (max 4 attempts, 12‑second outer deadline).
- 4. Parse the JSON response; if malformed or missing, record failure class and route to review.
- 5. Store raw model response and normalized status (allow/hold/block).
- 6. If status is allow, proceed to extraction; if hold or block, halt extraction and notify reviewer.
Evidence
send the image and a brief application policy to a multimodal chat model, require a strict JSON result, then store both the raw model decision and a small internal status.
The following program is intentionally direct. It performs one complete REST call, sets an explicit method, reads credentials from the environment, caps the response at 1 MiB, surfaces non-success bodies, honors an integer Retry-After on HTTP 429, and stops after four attempts or a 12-second outer deadline.
- Record date: 2026-10-13T04:41:08.537Z