PDF支持
使用 AI 模型发送和分析 PDF 文档。
OneRoute 支持将 PDF 文档发送给 AI 模型进行分析、摘要和问答。此功能适用于 Chat Completions 端点。
工作原理
PDF 文档作为消息内容的一部分发送,使用 base64 编码或 URL。然后 AI 模型可以分析文档并回答有关其内容的问题。
Chat Completions API
使用 input_file 内容类型发送 PDF。您可以将 PDF 作为 base64 编码数据或 URL 提供。
使用 Base64 编码的 PDF
curl https://gw.1route.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ONEROUTE_API_KEY" \
-d '{
"model": "anthropic/claude-sonnet-4-20250514",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize this PDF"
},
{
"type": "input_file",
"filename": "document.pdf",
"file_data": "data:application/pdf;base64,JVBERi0="
}
]
}
]
}'
使用 PDF URL
curl https://gw.1route.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ONEROUTE_API_KEY" \
-d '{
"model": "anthropic/claude-sonnet-4-20250514",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize this PDF"
},
{
"type": "input_file",
"filename": "document.pdf",
"file_data": "https://example.com/document.pdf"
}
]
}
]
}'
参数
type:必须为"input_file"filename:PDF 文件的名称(例如"document.pdf")file_data:base64 编码的 PDF 内容或 PDF 文件的 URL