Skip to content

docs(genapi): added ocr models#6419

Open
firdevs-a wants to merge 3 commits intomainfrom
MTA-7061
Open

docs(genapi): added ocr models#6419
firdevs-a wants to merge 3 commits intomainfrom
MTA-7061

Conversation

@firdevs-a
Copy link
Copy Markdown
Collaborator

Your checklist for this pull request

Description

Please describe what you added or changed.

@firdevs-a firdevs-a requested a review from fpagny April 15, 2026 08:26
@firdevs-a firdevs-a self-assigned this Apr 15, 2026
@firdevs-a firdevs-a requested review from a team as code owners April 15, 2026 08:26
@firdevs-a firdevs-a added status: tech review Waiting for technical review status: doc review Waiting for doc team review do not merge PR that shouldn't be merged before a specific date (eg release) labels Apr 15, 2026

```python
from mistralai.client import Mistral
import os
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
import os

Not needed if suggestion is to write the API Key directly, without using an environment variable.

api_key="<SCW_SECRET_KEY>" # Your unique API secret key from Scaleway
)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note that this snippet requires `mistralai >= 2.0.0`. For `mistralai <= 1.12.4` (also named `v1`), replace `from mistralai.client import Mistral` with `from mistralai import Mistral`.


<Message type="tip">
You can replace `FILE_URL` with the URL of any publicly accessible PDF or image file.
The input file or image must be stored in Scaleway Object Storage and referenced by its URL.
Copy link
Copy Markdown
Contributor

@fpagny fpagny Apr 16, 2026

Choose a reason for hiding this comment

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

Suggested change
The input file or image must be stored in Scaleway Object Storage and referenced by its URL.
You can for instance provide a file from Object Storage using an [Object Storage pre-signed URL](https://www.scaleway.com/en/docs/object-storage/how-to/access-objects-via-https/).

You can replace `FILE_URL` with the URL of any publicly accessible PDF or image file.
The input file or image must be stored in Scaleway Object Storage and referenced by its URL.
</Message>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Alternatively, you can also provide a local PDF file encoded in Base64 format.
```python
import base64
FILE_PATH = "path/to/your/file.pdf"
MODEL = "mistral-ocr-2512"
with open(FILE_PATH, "rb") as file:
file_content = file.read()
encoded_file= base64.b64encode(file_content).decode("utf-8")
res = mistral.ocr.process(
model=MODEL,
document={
"document_url": f"data:application/pdf;base64,{encoded_file}",
"type": "document_url",
}
)
filename = FILE_PATH.split("/")[-1].split(".")[0]
with open(f"{filename}.md", "w") as f:
for page in res.pages:
f.write(page.markdown)
# Print the generated response
print(f"File processed. Result markdown file stored in: {filename}.md")
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge PR that shouldn't be merged before a specific date (eg release) status: doc review Waiting for doc team review status: tech review Waiting for technical review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants