feat: Add /ocr endpoint OpenAPI spec - #149
Open
akhilmmenon wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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
OCRtag metadata to the top-level tag list. - Added
POST /ocrpath with security requirements and code samples (Default + Self-Hosted). - Added
CreateOcrRequest,CreateOcrResponse, andOcrPageschemas undercomponents.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 setbaseURLand 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 callclient.postwithout the/v1prefix (e.g.,/rerank). Using/v1/ocrhere 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 passbase_urland use unversioned paths like/rerank), this should be/ocr.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 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 | ||
| } | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/ocrendpoint definition to the OpenAPI spec for document text extractionOCRtag with descriptionCreateOcrRequest):model,document(type/url),include_image_base64,image_limit,image_min_size,pagesCreateOcrResponse):pagesarray withOcrPageitems (index, markdown, images),model,usage_infoSupported Providers
mistral-ocr-latest,mistral-ocr-4-0mistral-ocr-4-0,mistral-document-ai-2505,mistral-document-ai-2512Test plan