DocsRouterDocsRouter

API Overview

Concepts, authentication, limits, and SDK setup for the DocsRouter API

API Overview

The DocsRouter API is fully compatible with OpenAI and OpenRouter SDKs. You can use existing SDKs by simply changing the base URL. The API also provides DocsRouter-specific extensions for enhanced OCR functionality.

Base URL

All API requests should be made to the following base URL:

https://api.docsrouter.com/v1

For testing and development, you can also use:

https://api.docsrouter.com/v1  (Production)

Authentication

All API requests (except /v1/models and /v1/health) require authentication via the Authorization header using a Bearer token:

Authorization: Bearer YOUR_API_KEY

Obtaining an API Key

  1. Sign up at docsrouter.com
  2. Navigate to Dashboard → API Keys
  3. Click Create New Key
  4. Copy and securely store your key (it's only shown once)

Security Best Practices:

  • Never expose API keys in client-side code or public repositories
  • Use environment variables to store keys
  • Rotate keys periodically
  • Use separate keys for development and production

SDK Compatibility

DocsRouter works with any OpenAI-compatible SDK. Here are examples for popular languages:

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://api.docsrouter.com/v1",
    api_key="YOUR_DOCSROUTER_API_KEY",
)

response = client.chat.completions.create(
    model="google/gemini-2.0-flash-001",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Extract all text from this document"},
            {"type": "image_url", "image_url": {"url": "https://example.com/invoice.png"}}
        ]
    }]
)

print(response.choices[0].message.content)

JavaScript/TypeScript

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.docsrouter.com/v1',
  apiKey: 'YOUR_DOCSROUTER_API_KEY',
});

const response = await client.chat.completions.create({
  model: 'google/gemini-2.0-flash-001',
  messages: [{
    role: 'user',
    content: [
      { type: 'text', text: 'Extract all text from this document' },
      { type: 'image_url', image_url: { url: 'https://example.com/invoice.png' } }
    ]
  }]
});

console.log(response.choices[0].message.content);

cURL

curl -X POST https://api.docsrouter.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-2.0-flash-001",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "Extract all text"},
        {"type": "image_url", "image_url": {"url": "https://example.com/doc.png"}}
      ]
    }]
  }'

Other SDKs

DocsRouter is compatible with:

  • LangChain - Use the OpenAI integration with custom base URL
  • LlamaIndex - Configure OpenAI LLM with DocsRouter endpoint
  • Vercel AI SDK - Use OpenAI provider with custom configuration
  • Any OpenAI-compatible library - Just change the base URL

Response Format

All responses follow the OpenAI standard format with DocsRouter extensions:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1734567890,
  "model": "google/gemini-2.0-flash-001",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "INVOICE #001\nDate: December 15, 2024\n..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 150,
    "total_tokens": 1350
  },
  "docsrouter": {
    "confidence": 95,
    "detected_language": "en",
    "pages_processed": 1,
    "tables_detected": 2,
    "provider": "openrouter",
    "provider_cost_cents": 1.2,
    "platform_fee_cents": 0.4,
    "total_cost_cents": 1.6,
    "processing_time_ms": 1850
  }
}

DocsRouter Extensions

The docsrouter object in responses contains OCR-specific metadata:

FieldTypeDescription
confidencenumberOCR confidence score (0-100)
detected_languagestringISO 639-1 language code
pages_processednumberNumber of pages/images processed
tables_detectednumberNumber of tables found
tablesarrayExtracted table data (if enabled)
providerstringUpstream provider used
provider_cost_centsnumberCost charged by provider
platform_fee_centsnumberDocsRouter platform fee
total_cost_centsnumberTotal cost for the request
processing_time_msnumberProcessing time in milliseconds

Endpoints Overview

Core Endpoints

MethodEndpointAuthDescription
POST/v1/chat/completionsRequiredOpenAI-compatible OCR ⭐ Recommended
POST/v1/ocrRequiredNative OCR endpoint
GET/v1/modelsOptionalList available models
GET/v1/models/{id}OptionalGet specific model details

Management Endpoints

MethodEndpointAuthDescription
GET/v1/api-keysRequiredList API keys
POST/v1/api-keysRequiredCreate new API key
DELETE/v1/api-keys/{id}RequiredRevoke API key
GET/v1/usageRequiredGet usage logs
GET/v1/usage/summaryRequiredGet usage summary
GET/v1/accountRequiredGet account details
GET/v1/account/balanceRequiredGet account balance

Utility Endpoints

MethodEndpointAuthDescription
GET/v1/healthNoneCheck API status
GET/v1/models/statsOptionalGet model statistics
GET/v1/models/recommendedOptionalGet recommended models

Rate Limits

The API implements rate limiting to ensure fair usage and system stability:

TierRequests/MinuteRequests/DayConcurrent
Free101002
Starter601,0005
Pro30010,00020
EnterpriseCustomCustomCustom

Rate Limit Headers

Every response includes rate limit information:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1734567890
HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets
Retry-AfterSeconds to wait (only on 429 responses)

Request Limits

LimitValue
Maximum request body size50 MB
Maximum image size20 MB
Maximum PDF size50 MB
Maximum pages per PDF100
Maximum images per request10
Request timeout120 seconds

Supported File Formats

Images

FormatMIME TypeNotes
PNGimage/pngRecommended for documents
JPEGimage/jpegGood for photos
WebPimage/webpEfficient compression
GIFimage/gifFirst frame only
TIFFimage/tiffHigh-quality scans
BMPimage/bmpUncompressed

Documents

FormatMIME TypeNotes
PDFapplication/pdfUse mistral-ocr engine for scanned PDFs

Pricing

DocsRouter pricing is 5% above OpenRouter rates, covering our unified API, OCR extensions, and platform services.

Per-Request Costs

Costs are calculated based on:

  1. Input tokens - Text and image tokens sent to the model
  2. Output tokens - Generated text tokens
  3. PDF processing - Additional fee for PDF engine (if used)
  4. Document conversion - Additional fee for office documents (if needed)

PDF Engine Pricing

EngineCostBest For
pdf-textFreeDigital PDFs with selectable text
mistral-ocr$0.105/1,000 pagesScanned documents, images in PDFs
nativeModel token costModels with native PDF support

Document Conversion Pricing

For office documents (DOCX, PPTX, DOC, ODT, RTF, TXT) that need to be converted to images before processing with Vision LLMs:

Document TypeEstimated CostNotes
Simple documents~1-2¢DOCX, DOC, TXT, RTF
Presentations~1-3¢PPTX (10-50 slides)
Complex documents~2-5¢Large documents with many pages

Minimum charge: 1¢ per conversion

Tip: Mistral OCR (mistral-ocr-latest) natively supports DOCX and PPTX without conversion fees. Use it for the most cost-effective office document processing.

Cost Transparency

Every response includes detailed cost breakdown:

{
  "docsrouter": {
    "provider_cost_cents": 1.2,
    "platform_fee_cents": 0.4,
    "conversion_cost_cents": 1.0,
    "total_cost_cents": 2.6
  }
}

Versioning

The API is versioned via the URL path (/v1/). We maintain backward compatibility within major versions.

  • v1 (current) - Stable, production-ready
  • Breaking changes will be announced 90 days in advance
  • Deprecation notices are included in response headers

Support

On this page