PDF understanding enables the model to parse and comprehend PDF documents, extracting text and images for analysis. You can pass PDF files via URL or Base64 encoding.
PDF understanding enables the model to parse and comprehend PDF documents, extracting text and images from the document for analysis. You can pass a PDF file by URL or as Base64-encoded data through the OpenAI-compatible Chat Completions API or the DashScope API.
qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash
Run the following code to send a PDF file to the model.
Get a QwenCloud API key and configure it as an environment variable.
If you cannot provide a file URL, you can also pass the PDF file as a Base64-encoded string. When using
The file input is specified as an element in the
OpenAI-compatible format:
Billing involves the following:
To view the parsed PDF page count in the response, get it from
If a call fails, see Error messages.
PDF understanding is not supported through the Responses API at this time. If you pass a PDF using the Responses API, the request still returns HTTP 200, but the file is not delivered to the model.
Supported models
qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash
Quick start
Run the following code to send a PDF file to the model.
Get a QwenCloud API key and configure it as an environment variable.
- OpenAI compatible
- DashScope
Base64 input
If you cannot provide a file URL, you can also pass the PDF file as a Base64-encoded string. When using file_data, the filename field is required.
Base64 encoding increases the data size by about 1/3. For example, a 150 MB file becomes roughly 200 MB after encoding, which exceeds the request body size limit. For large files, pass the file by URL instead.
- OpenAI compatible
- DashScope
Python
Request parameters
The file input is specified as an element in the content array. The OpenAI-compatible protocol uses the type: "file" element, and the DashScope protocol uses an element containing file_url/file_data.
The URL field in the protocol only accepts a string. A list (array) of URLs is not supported.
| Parameter | Type | Required | Description |
|---|---|---|---|
file_url | string | One of the two required | The download URL of the PDF file. Mutually exclusive with file_data. |
file_data | string | One of the two required | Base64-encoded PDF input in the format data:application/pdf;base64,xxx. Mutually exclusive with file_url. |
filename | string | Conditionally required | The file name. Required when using file_data. |
file_format | string | No | The file format. Currently only pdf is supported. Defaults to pdf. |
Limits
| Item | Limit |
|---|---|
| Maximum file size | 150 MB |
| Maximum page count | 256 pages |
PDF parsing may take longer than a regular text request. The first-token timeout is up to 300 seconds. We recommend using streaming output to get results in real time and avoid long waits.
Billing
Billing involves the following:
- Model input tokens: Text and images parsed from the PDF are counted as input tokens, billed at the model's standard input token rate. For per-model input and output token prices, see Pricing.
- Document parsing fee: Charged per page of the PDF document parsed, corresponding to the metering item
document_parsing(pdf). $0.0033 per page.
View PDF page count
To view the parsed PDF page count in the response, get it from pdf_page_parser.count in the usage field. The two protocols behave slightly differently: