AI providers: BYOK, hosted & local
AI: /api/ai/*, /api/local/*
Content reviewed .
Bring Your Own Key (BYOK) document extraction separates the document review workspace from the AI inference engine. Instead of paying 20x software markups on OCR, you connect your provider account and run models at wholesale token cost. Dynamite Docs manages document intake, table alignment, schema inference, human reconciliation, and spreadsheet exports. Your provider account handles inference and bills your card directly.
Open this integration in the app or read the public API and webhook guide.
Why bundled OCR and single-vendor AI extraction cost 20x too much
- Legacy IDP platforms charge $0.05 to $0.50 per page. Most wrap the same underlying cloud vision models, add a 1,000% token markup, and force users into rigid coordinate-based templates that break on layout changes.
- Bundled single-model tools cannot adapt to document diversity. A clean vector PDF needs a fast deterministic code parser, while a crumpled receipt photo requires a multimodal vision model.
- Sending confidential invoices, patient records, or vendor tax IDs to an unvetted cloud provider creates severe compliance risks under GDPR, HIPAA, and client NDAs.
- Vendor lock-in leaves operations stranded. If a model vendor changes pricing, throttles throughput, or deprecates an endpoint, your document pipeline halts until developers rewrite integrations.
How BYOK document extraction works inside Dynamite Docs
01. Connect your API key in settings
Open Settings > AI & Processing in your workspace. Choose your provider from Google Gemini, Groq, Mistral, OpenAI, Anthropic, OpenRouter, or Custom Endpoint. Paste your secret key and click Verify & Save Key. The server runs an instant health check to discover available models and encrypts the key at rest using AES-256-GCM.
02. Configure active models and fallback routing
Select your default extraction model (such as Gemini 2.0 Flash for sub-second cost efficiency or Claude 3.5 Sonnet for dense financial reasoning). Set a fallback provider to guarantee continuous operation if a primary provider hits rate limits or experiences downtime.
03. Set data privacy and residency policies
Toggle Sensitive Documents Mode to automatically block external providers that permit model training. For strict regulatory compliance, enforce European data residency routes via Mistral AI or route confidential files to the local Ollama companion over a loopback connection.
04. Extract documents with zero platform markup
Upload invoices, bank statements, or receipts. Digital vector PDFs parse locally with code for free. Scans and photos route directly to your connected model. On Pro ($79/mo) and Scale ($199/mo) plans, BYOK extractions cost exactly 0 Processing Entitlements (PE). You pay only raw provider token rates.
Supported providers, endpoints, and architectural controls
Connect any modern multimodal or text LLM. Keys are encrypted with AES-256-GCM and used exclusively to route your authenticated requests:
- Google Gemini: Gemini 2.0 Flash (~$0.0002/page) and Gemini 1.5 Pro (2M token context)
- Groq Cloud: Llama 3.2 Vision at 300-500 tokens/sec on LPU hardware (600ms latency)
- Mistral AI: Pixtral 12B & Large with dedicated EU infrastructure and GDPR compliance
- OpenAI & Anthropic: GPT-4o, GPT-4o mini, and Claude 3.5 Sonnet for complex audit reconciliation
- Cloud Platforms: Azure OpenAI, Amazon Bedrock, Google Vertex AI, and OpenRouter gateways
- OpenAI-Compatible Endpoints: LiteLLM, vLLM, Ollama server, or internal private VPC endpoints
- Local Ollama Companion: 100% on-device extraction on port 8756 with zero cloud transmission
- Zero PE Consumption: Pro and Scale plans include unlimited BYOK runs at 0 PE per page
A realistic example
Realistic routing across a mixed batch of accounting documents:
| Document Type | Configured Route | Technical & Cost Rationale |
|---|---|---|
| Clean digital supplier invoice (PDF) | Deterministic Code Parser ($0) | Embedded text layer and table vectors allow instant client-side extraction with zero AI API calls. |
| Crumpled store receipt photo (JPG) | Groq Llama 3.2 Vision | Sub-second OCR parsing (600ms) extracts merchant, tax, and line items at $0.0004 per receipt. |
| 60-page historical bank statement (Scan) | Gemini 1.5 Pro | 2,000,000 token context window processes the entire transaction ledger in one prompt without row fragmentation. |
| Confidential executive agreement (PDF) | Local Ollama (llama3.2-vision) | Processed over local loopback (port 8756). Document bytes never leave your physical workstation. |
Request and response examples
Verify and store an encrypted provider key
POST /api/ai/keys
curl -X POST \
-H "Authorization: Bearer <clerk_token>" \
-H "Content-Type: application/json" \
-d '{
"provider": "groq",
"apiKey": "gsk_a8b9c0d1e2f3...",
"preferredModel": "llama-3.2-11b-vision-preview"
}' \
"https://app.dynamitedocs.com/api/ai/keys"
{
"success": true,
"provider": "groq",
"status": "connected",
"discoveredModels": [
"llama-3.2-11b-vision-preview",
"llama-3.2-90b-vision-preview"
],
"activeModel": "llama-3.2-11b-vision-preview",
"verifiedAt": "2026-09-15T15:00:00.000Z"
}
Run document extraction using connected BYOK provider
POST /api/v1/infer
curl -X POST \
-H "Authorization: Bearer dd_live_9f8e7d6c5b4a..." \
-F "file=@invoice_2026_09.pdf" \
-F "docType=Invoice" \
-F "provider=groq" \
-F "model=llama-3.2-11b-vision-preview" \
"https://app.dynamitedocs.com/api/v1/infer"
{
"id": "ext_9821af4e",
"docType": "Invoice",
"peCharged": 0,
"executionTimeMs": 740,
"provider": "groq",
"model": "llama-3.2-11b-vision-preview",
"columns": ["Item", "Qty", "Unit Price", "Total"],
"rows": [
["Server Hosting Q3", "1", "120.00", "120.00"],
["Bandwidth Allocation", "5", "15.00", "75.00"]
],
"metadata": {
"invoiceNumber": "INV-2026-882",
"subtotal": "195.00",
"tax": "17.55",
"total": "212.55"
}
}
What to validate before relying on it
Verify that the selected provider supports your document modality (multimodal vision vs text) and satisfies active data residency, zero-training, or local loopback policies before processing sensitive files.
Wholesale token economics, encryption architecture, and data residency
Document extraction costs are governed by raw model token consumption, not artificial software tiers. A standard 300 DPI invoice uses approximately 1,200 to 1,600 vision tokens. At Google Cloud published rate of $0.10 per million input tokens for Gemini 2.0 Flash, processing a full invoice page costs approximately $0.0002. Legacy Intelligent Document Processing software charges between $0.05 and $0.50 per page for coordinate OCR, representing a 250x to 2,500x markup on identical underlying compute.
Dynamite Docs Pro ($79/month) and Scale ($199/month) plans eliminate per-page software metering entirely. When you connect an approved provider key, BYOK extractions cost exactly 0 Processing Entitlements (PE). You can process 10,000 or 100,000 pages each month without incurring overage fees or platform lockouts, paying only your raw model token costs directly to Google, Groq, Mistral, OpenAI, or Anthropic. Free and Starter tiers can also connect provider keys within their shared monthly PE budget.
External credentials require strict cryptographic protection. Provider API keys are encrypted at rest with AES-256-GCM using keys managed server-side via BYOK_ENCRYPTION_KEY. Keys are decrypted in memory only for the millisecond window required to sign an outbound HTTPS request to the official provider endpoint. Secrets never land in client-side browser storage, browser network logs, or application crash dumps.
Under standard commercial developer terms from Google Cloud, Groq, Mistral, OpenAI, and Anthropic, data submitted through paid API endpoints is never used to train foundation models. This differs fundamentally from consumer chat apps that retain conversational data. For organizations bound by strict regulatory constraints, Sensitive Documents Mode blocks external providers, while European routes via Mistral keep data within EU boundaries.
When client contracts or healthcare regulations prohibit cloud transmission entirely, the local Ollama companion processes files on-device. The companion runs on port 8756 via an authenticated loopback connection to Ollama on port 11434. Document bytes, raster images, and extracted text never traverse the public internet, continuing to work even during internet outages.
Provider routing security guarantees and boundaries
Does
- Routes requests directly to your verified provider endpoint at wholesale cost with 0% software markup.
- Encrypts API keys at rest with AES-256-GCM and decrypts them in memory only for outbound requests.
- Provides automatic fallback routing to secondary providers during rate limits or service outages.
- Maintains identical schema structure, column names, and validation rules regardless of which AI model runs.
- Permits 100% on-device, air-gapped extraction via the local Ollama companion over loopback port 8756.
Does not
- Does not charge Processing Entitlements (PE) for BYOK runs on Pro or Scale subscription plans.
- Does not expose API keys to browser clients, frontend storage, or audit log exports.
- Does not permit third-party AI vendors to train foundation models on your uploaded documents.
- Does not force rigid coordinate templates that fail when suppliers modify their invoice layout.
Why provider choice and schema locking are non-negotiable
Modern document extraction belongs in a model-agnostic workspace. AI models evolve rapidly, with faster vision architectures and lower pricing launching every quarter. Tying your business operations to a proprietary, single-model tool leaves your workflows vulnerable to price increases and technical stagnation.
Dynamite Docs standardizes the input and output pipeline. Whether an extraction runs through Gemini 2.0 Flash, Groq Llama 3.2, Claude 3.5 Sonnet, or an on-premise Ollama model, your output columns, data validation checks, and spreadsheet formulas remain identical.
Take control of your data residency and operational margins. Connect your provider keys, configure routing policies to match your risk profile, and process documents at true wholesale cost.
Questions, answered
How do I generate an API key for document extraction?
Sign in to your provider developer console: Google AI Studio (aistudio.google.com/app/apikey), Groq Cloud (console.groq.com/keys), Mistral AI (console.mistral.ai/api-keys), OpenAI Platform (platform.openai.com/api-keys), or Anthropic (console.anthropic.com/settings/keys). Create a new secret key, copy the token, navigate to Settings > AI & Processing in Dynamite Docs, and click Verify & Save Key.
Does Dynamite Docs charge PE when I use my own API key?
On Pro ($79/month) and Scale ($199/month) plans, BYOK document extraction costs exactly 0 Processing Entitlements (PE). You can process unlimited pages with your own key without platform metering. On Free and Starter plans, BYOK extractions draw from your shared monthly PE allowance.
Do AI providers train their foundation models on my invoices?
When using commercial developer API keys from Google Cloud, OpenAI, Anthropic, Mistral, and Groq, data sent through API endpoints is not used to train foundation models under standard commercial terms of service. For complete air-gapped security, use the local Ollama companion.
How much does BYOK extraction cost compared to traditional OCR?
Traditional IDP software charges $0.05 to $0.50 per page. Using BYOK with Gemini 2.0 Flash costs roughly $0.0002 per page in raw tokens ($0.10 per million input tokens). Groq and Mistral offer similar fractions-of-a-cent pricing, cutting extraction costs by over 90%.
What happens when a provider hits an HTTP 429 rate limit?
Dynamite Docs includes automated exponential backoff retries. You can also configure a secondary fallback model in AI Settings. If your primary provider returns a 429 rate limit or 5xx outage, the system immediately reroutes the document to your backup provider.
Can I extract data completely offline without cloud transmission?
Yes. On Starter, Pro, and Scale tiers, you can run the local Ollama companion on your workstation. The companion executes models such as llama3.2-vision on port 8756 via an authenticated loopback connection. Document bytes never leave your machine.
Do column names change when switching between different AI models?
No. Dynamite Docs enforces strict schema locking. The workspace standardizes extracted JSON headers, date formats, and line item arrays so downstream integrations with Excel, CSV, Google Sheets, and accounting software never break.
Can BYOK vision models extract handwritten receipts and blurry smartphone photos?
Yes. Multimodal vision models such as Gemini 2.0 Flash, Claude 3.5 Sonnet, and GPT-4o excel at reading handwritten notes, skewed smartphone camera angles, and low-contrast receipt thermal paper that causes legacy OCR engines to fail.
Related integrations
Document workflows it feeds
Related integration articles
Open the integrations workspace, no payment details.