Skip to content

feat: Add /ocr endpoint OpenAPI spec - #149

Open
akhilmmenon wants to merge 1 commit into
masterfrom
feat/native-ocr-endpoint
Open

feat: Add /ocr endpoint OpenAPI spec#149
akhilmmenon wants to merge 1 commit into
masterfrom
feat/native-ocr-endpoint

Conversation

@akhilmmenon

@akhilmmenon akhilmmenon commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds the /ocr endpoint definition to the OpenAPI spec for document text extraction
  • New OCR tag with description
  • Request schema (CreateOcrRequest): model, document (type/url), include_image_base64, image_limit, image_min_size, pages
  • Response schema (CreateOcrResponse): pages array with OcrPage items (index, markdown, images), model, usage_info
  • Code samples for cURL, Python, and JavaScript (Default + Self-Hosted variants)

Supported Providers

  • Mistral AI: mistral-ocr-latest, mistral-ocr-4-0
  • Azure AI Foundry: mistral-ocr-4-0, mistral-document-ai-2505, mistral-document-ai-2512

Test plan

  • Validated spec renders correctly in Swagger Editor
  • OpenAPI spec renders in docs.portkey.ai

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the project’s OpenAPI specification by adding a new /ocr endpoint for document OCR (PDFs/images), including new OCR tagging, request/response schemas, and multi-language code samples.

Changes:

  • Added OCR tag metadata to the top-level tag list.
  • Added POST /ocr path with security requirements and code samples (Default + Self-Hosted).
  • Added CreateOcrRequest, CreateOcrResponse, and OcrPage schemas under components.schemas.
Suppressed comments (3)

openapi.yaml:3673

  • The Self-Hosted JavaScript SDK sample also uses client.post('/v1/ocr', ...). For consistency with other self-hosted SDK samples (which set baseURL and use unversioned paths like /rerank), this should be /ocr.
    openapi.yaml:3606
  • The JavaScript SDK sample uses client.post('/v1/ocr', ...), but other SDK samples in this spec call client.post without the /v1 prefix (e.g., /rerank). Using /v1/ocr here is inconsistent and likely to break when the SDK already handles the versioned base path.
    openapi.yaml:3649
  • The Self-Hosted Python SDK sample also uses client.post("/v1/ocr", ...). For consistency with other self-hosted SDK samples (which pass base_url and use unversioned paths like /rerank), this should be /ocr.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openapi.yaml
Comment on lines +24981 to +24999
document:
description: The document to process. Specify either a URL or base64-encoded content.
type: object
properties:
type:
description: The type of document source.
type: string
enum: [document_url, image_url, base64]
example: "document_url"
document_url:
description: URL of the document to process. Can be an HTTPS URL or a base64 data URI (e.g. `data:application/pdf;base64,...`).
type: string
example: "https://example.com/document.pdf"
image_url:
description: URL of an image to process.
type: string
required:
- type
include_image_base64:
Comment thread openapi.yaml
Comment on lines +3580 to +3590
response = client.post(
"/v1/ocr",
body={
"model": "mistral-ocr-latest",
"document": {
"type": "document_url",
"document_url": "https://example.com/document.pdf"
},
"include_image_base64": True
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants