OCR

Perform OCR

Extracts text and content from documents or images using optical character recognition. Supports PDF URLs, base64-encoded documents, and image URLs.

POST
/v1/ocr
AuthorizationBearer <token>

Bearer token authentication. Use your MPilot virtual-key JWT or admin JWT. Virtual keys (prefixed with sk-bf-) can also be passed here.

In: header

modelstring

Model in provider/model format

id?string

Optional unique identifier for the request

documentOCRDocument
fallbacks?array<string>

Fallback models in provider/model format

include_image_base64?boolean

Whether to include base64-encoded images in the response

pages?array<integer>

Specific page indices to process (0-based)

image_limit?integer

Maximum number of images to extract per page

Range1 <= value
image_min_size?integer

Minimum image size in pixels to extract

Range1 <= value
table_format?string

Format for extracted tables (e.g., "markdown", "html")

extract_header?boolean

Whether to extract page headers

extract_footer?boolean

Whether to extract page footers

confidence_scores_granularity?string

Granularity of confidence scores to include in the response

Value in"page" | "block" | "word" | "document"
bbox_annotation_format?

Format for bounding box annotations. Supports text, json_object, and json_schema modes.

document_annotation_format?

Format for document-level annotations. Supports text, json_object, and json_schema modes.

document_annotation_prompt?string

Custom prompt for document annotation

Response Body

curl -X POST "https://loading/{AI_GATEWAY_URL}/v1/ocr" \  -H "Content-Type: application/json" \  -d '{    "model": "mistral/mistral-ocr-latest",    "document": {      "type": "document_url"    }  }'
{
  "model": "string",
  "pages": [
    {
      "index": 0,
      "markdown": "string",
      "images": [
        {
          "id": "string",
          "top_left_x": 0,
          "top_left_y": 0,
          "bottom_right_x": 0,
          "bottom_right_y": 0,
          "image_base64": "string"
        }
      ],
      "dimensions": {
        "dpi": 0,
        "height": 0,
        "width": 0
      },
      "tables": [
        {}
      ],
      "header": "string",
      "footer": "string",
      "confidence_scores": {
        "average_page_confidence_score": 0,
        "minimum_page_confidence_score": 0,
        "word_confidence_scores": [
          0
        ]
      }
    }
  ],
  "usage_info": {
    "pages_processed": 0,
    "doc_size_bytes": 0
  },
  "document_annotation": "string",
  "extra_fields": {
    "request_type": "string",
    "provider": "openai",
    "model_requested": "string",
    "model_deployment": "string",
    "latency": 0,
    "chunk_index": 0,
    "raw_request": {},
    "raw_response": {},
    "cache_debug": {
      "cache_hit": true,
      "cache_id": "string",
      "hit_type": "string",
      "requested_provider": "string",
      "requested_model": "string",
      "provider_used": "string",
      "model_used": "string",
      "input_tokens": 0,
      "threshold": 0,
      "similarity": 0
    }
  }
}
{
  "event_id": "string",
  "type": "string",
  "is_bifrost_error": true,
  "status_code": 0,
  "error": {
    "type": "string",
    "code": "string",
    "message": "string",
    "param": "string",
    "event_id": "string"
  },
  "extra_fields": {
    "provider": "openai",
    "model_requested": "string",
    "request_type": "string"
  }
}
{
  "event_id": "string",
  "type": "string",
  "is_bifrost_error": true,
  "status_code": 0,
  "error": {
    "type": "string",
    "code": "string",
    "message": "string",
    "param": "string",
    "event_id": "string"
  },
  "extra_fields": {
    "provider": "openai",
    "model_requested": "string",
    "request_type": "string"
  }
}
On this page

On this page

No Headings