The problem
Reading a PDF can give your agent text in the wrong order, with headings, columns, and tables mixed together. That can separate a number from its explanation or join unrelated sentences. The agent needs a tool that turns the document into readable text while keeping its structure.
How NativePort helps
NativePort uses Mistral’s document-reading service to turn a PDF into readable text while keeping useful headings and tables. Your agent can use that clearer version to summarize the document or answer questions about it. Keeping track of the original pages helps you check where the information came from.
Let your agent build it
You don’t need to write this code yourself. Copy the prompt and paste it into your agent. It will follow NativePort’s setup guide, help you use an existing account or create one, read this page, and ask what you’d like to do next.
View prompt
Help me use NativePort for this use case. 1. Read https://nativeport.ai/SKILL.md and follow its instructions to learn how to use NativePort. Save or update the skill if your environment supports it. 2. Check whether I already have a working NativePort connection or account. Reuse it if available. Otherwise, help me sign in or create an account by following the skill's setup instructions. Guide me through any steps that require me to use a browser, then help connect my agent. Keep credentials private. 3. Follow the skill to learn how to find the right tools, check their prices and instructions, and use them through NativePort. 4. Read this entire use-case page, including the instructions for agents inside the accordion: https://nativeport.ai/use-cases/pdf-to-markdown/ Once setup is complete and you have read the page, briefly explain what you can help me do and ask me what I would like to do next. Wait for my answer before implementing the example or running paid tools.
Instructions for the agents - You don't need to read this
Technical implementation
Use Python 3 with requests installed (python -m pip install requests). Set NATIVEPORT_API_KEY in your environment to your NativePort key. Run the snippets on your server, where your key stays private.
Set DOCUMENT_URL to an HTTPS URL the document service can fetch, such as a time-limited file link. The example reads page 0 (the first page). Select only pages you need, up to 100 per request; split longer documents into batches. Send the URL, not inline file bytes.
import os
import requests
BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}
payload = {
"document": {"type": "document_url", "document_url": os.environ["DOCUMENT_URL"]},
"pages": [0],
}
response = requests.post(BASE + "/mistral/v1/ocr", headers=HEADERS,
json=payload, timeout=120)
response.raise_for_status()
result = response.json()
from pathlib import Path
markdown = "\n\n".join(
f"<!-- Source page {page['index'] + 1} -->\n{page['markdown']}"
for page in result["pages"]
)
Path("document.md").write_text(markdown, encoding="utf-8")Chunk the Markdown by headings or page boundaries before indexing a long document. Keep the source URL and page numbers with each chunk. Rendering quality depends on the original layout. See the Mistral request policy for document URLs, page selection, and accepted options. OCR returns recognized content; check unclear scans against the source.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| Mistral — OCR | $0.00422 / call (1 page) |
Prices in USD. Usage-based tools have no fixed per-call price. View pricing.