DocsRouter
Api

Chat Completions

Early-access OpenAI-style endpoint for document OCR

Chat Completions

POST /v1/chat/completions accepts an OpenAI-style messages payload for image and file prompts. For the simplest current OCR contract, use POST /v1/ocr.

Early access

Compatibility covers the documented request shape; it is not a guarantee that every OpenAI SDK feature or parameter is supported. Test your specific client and payload.

Endpoint

POST https://api.docsrouter.com/v1/chat/completions

All requests require a bearer API key.

Image request

{
  "model": "google/gemini-2.5-flash",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Extract all text from this document"},
        {
          "type": "image_url",
          "image_url": {"url": "https://example.com/invoice.png"}
        }
      ]
    }
  ]
}

Use an ID returned by GET /v1/models. The catalog is limited to the same six curated vision models described on Models.

PDF request

{
  "model": "google/gemini-2.5-flash",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Extract all text from this PDF"},
        {
          "type": "file",
          "file": {
            "filename": "document.pdf",
            "file_data": "https://example.com/document.pdf"
          }
        }
      ]
    }
  ],
  "plugins": [
    {
      "id": "file-parser",
      "pdf": {"engine": "mistral-ocr"}
    }
  ]
}

The dedicated Mistral OCR parser has a direct provider rate of $2 per 1,000 pages before DocsRouter's 5% platform fee. Minimum charges and rounding can affect the amount billed for small requests.

Response

The endpoint returns an OpenAI-style chat.completion object with token usage and, when available, DocsRouter cost metadata.

{
  "id": "chatcmpl_123",
  "object": "chat.completion",
  "model": "google/gemini-2.5-flash",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "Extracted text"},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1200,
    "completion_tokens": 150,
    "total_tokens": 1350
  }
}

Provider-generated fields such as confidence can be absent. They are not DocsRouter benchmark scores and do not trigger an automatic retry or model fallback.

Reliability boundaries

  • DocsRouter does not cache extraction results for duplicate documents.
  • DocsRouter does not automatically retry through a second model based on confidence.
  • No model has a published DocsRouter accuracy or latency guarantee.
  • Validate structured data in your application before taking consequential action.

For transparent static routing policies and multi-page page-level output, use the Native OCR endpoint.

On this page