Document Processing
Extract and classify documents at volume.
Run vision-capable models over scans and PDFs in large batches, pace requests against provider quotas, and track cost per job.
Vision models, at volume, with a cost number.
Restrict keys to vision endpoints, pace batch runs, and track spend per job behind one key.
Vision-capable models, by access
Restrict virtual keys to vision endpoints so requests to text-only models are blocked before dispatch.
- PII masking for tax IDs, SSNs, bank accounts, and card numbers
- Guardrails read text only, never the image itself
Built for high-volume batches
Per-key RPM and TPM limits pace a batch against provider quotas, and caching skips repeat pages.
- RPM/TPM ceilings per key, team, and org
- A 429 names the ceiling that tripped in x-nr-limit-source
Cost and usage tracking per job
Tag batch runs with a job-id metadata attribute to measure cost per document inside budget caps.
Explore budget trackingFailover for long batch runs
A 429, 503, or a provider that sends no first byte in time moves the page to your next fallback model.
Explore failover chainsOne standard request per document.
Each page is a chat completion on the same client; run it in your batch loop.
pip install openai| 1 | # Cache: enabled (org default). Pass nrouter_cache: false to skip. |
| 2 | from openai import OpenAI |
| 3 | import os |
| 4 |
|
| 5 | client = OpenAI( |
| 6 | api_key=os.environ["NROUTER_API_KEY"], |
| 7 | base_url="https://api.nrouter.ai/v1", |
| 8 | ) |
| 9 |
|
| 10 | response = client.chat.completions.create( |
| 11 | model="gpt-5.4-mini", |
| 12 | temperature=1, |
| 13 | max_completion_tokens=1024, |
| 14 | messages=[ |
| 15 | {"role": "user", "content": "Hello! What models do you support?"}, |
| 16 | ], |
| 17 | extra_body={ |
| 18 | # "nrouter_cache": False, # Uncomment to skip cache |
| 19 | }, |
| 20 | ) |
| 21 |
|
| 22 | print(response.choices[0].message.content) |
FAQs
Does nRouter support vision-capable models for document work?
Yes. The model catalog marks vision-capable models, and per-key model access keeps batch workloads restricted to tested vision models. Requests to text-only models are blocked before dispatch, avoiding wasted inference attempts.
Can I run large batches of documents without hitting provider rate limits?
Yes. Each document is processed through standard OpenAI-compatible endpoints. Per-key RPM and TPM limits pace the batch loop against upstream provider limits, and if a provider still throttles a request, failover moves it to the next provider in your chain rather than failing the document.
How does tier routing reduce document processing costs?
Send high-volume standard receipts and straightforward invoices to fast, low-cost multimodal models, and only dense legal contracts and handwritten tables to heavy reasoning models, so the expensive tier only sees the documents that need it.
How do inline guardrails protect confidential financial and personal records?
Before document text reaches external providers, inline guardrails scan it and mask tax IDs, social security numbers, bank account numbers, and credit card numbers, so the values are redacted before dispatch rather than after. Guardrails inspect text only, not images, so send extracted text when it carries sensitive values.
What happens if a provider degrades in the middle of an overnight batch run?
When a provider returns 429 or 503 or sends no first byte in time, the request moves to the next model in your fallback list. The batch continues without a manual restart, and each fallback is recorded in the request log.