Conversation
jcirinosclwy
approved these changes
Apr 15, 2026
bene2k1
approved these changes
Apr 15, 2026
fpagny
reviewed
Apr 16, 2026
|
|
||
| ```python | ||
| from mistralai.client import Mistral | ||
| import os |
Contributor
There was a problem hiding this comment.
Suggested change
| import os |
Not needed if suggestion is to write the API Key directly, without using an environment variable.
fpagny
reviewed
Apr 16, 2026
| api_key="<SCW_SECRET_KEY>" # Your unique API secret key from Scaleway | ||
| ) | ||
| ``` | ||
|
|
Contributor
There was a problem hiding this comment.
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`. |
fpagny
reviewed
Apr 16, 2026
|
|
||
| <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. |
Contributor
There was a problem hiding this comment.
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/). |
fpagny
reviewed
Apr 16, 2026
| 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> | ||
|
|
Contributor
There was a problem hiding this comment.
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") | |
| ``` |
Loic-kd
approved these changes
Apr 17, 2026
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.
Your checklist for this pull request
Description
Please describe what you added or changed.