Ask about a PDF
Send a PDF to a model and ask questions about its text, tables and images
Some models can read a PDF directly, including its text, tables and images. Send the file in the request with your question.
Choose a model
Use a model whose Inputs include PDF on its model page, such as claude-sonnet-5 or gemini-3.6-flash. These examples use claude-sonnet-5.
Cloud models only: every model that accepts PDFs is a cloud model, approved for Open data only. You need a key from a team with cloud models enabled; a default personal key cannot use them. For a scanned document with sensitive data, use OCR with a model hosted at UF instead.
Send a PDF
These examples read document.pdf from the current folder. The Python and JavaScript examples need the openai package from OpenAI-compatible SDKs.
PDF_B64=$(base64 < document.pdf | tr -d '\n')
curl "$NAVIGATOR_API_BASE_URL/chat/completions" \
--header "Authorization: Bearer $NAVIGATOR_TOOLKIT_API_KEY" \
--header "Content-Type: application/json" \
--data @- <<EOF
{
"model": "claude-sonnet-5",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Summarize this document in five bullet points."},
{"type": "file", "file": {"filename": "document.pdf", "file_data": "data:application/pdf;base64,$PDF_B64"}}
]
}]
}
EOFThe command works on macOS and Linux.
Tips
- Every page counts toward the model's context window and cost. For long documents, send only the pages you need.
- Ask about specific sections, tables or figures for the most reliable answers. Check them against the original.
- A PDF with selectable text can also be converted to text first and sent as a normal message, which works with any text model.
- If a request fails with a format error, confirm the model's inputs include PDF.