Qwen-OCR is a visual understanding model that extracts text and structured data from images — scanned documents, tables, receipts, and more. It handles multiple languages and supports advanced OCR tasks: information extraction, table parsing, formula recognition, and document parsing.
Examples
| Input image | Recognition result |
|---|---|
Recognize multiple languages![]() | INTERNATIONALMOTHER LANGUAGEDAYПривет!你好!Bonjour!Merhaba!Ciao!Hello!Ola!בר מולדSalam! |
Recognize skewed images![]() | Product IntroductionImported fiber filaments from South Korea.6941990612023Item No.: 2023 |
Locate text position![]() high-precision recognition task supports text localization. | Visualization of localization![]() See the FAQ on how to draw the bounding box of each text line onto the original image. |
Model selection
Qwen-OCR provides the following models. Choose based on your business requirements:
- Qwen3.5-OCR: Built on the Qwen3.5 architecture, with comprehensive upgrades in document parsing, text localization, and key information extraction. Supports multi-turn conversations and PDF document parsing. Significantly improved in extracting information from business certificates (such as ID cards and driver's licenses). For supported certificate types, see Supported certificate and document types. Includes the
qwen3.5-ocrmodel. - Qwen-VL-OCR: Built on the Qwen3-VL architecture. Supports built-in tasks including document parsing, text localization (high-precision recognition), information extraction, table parsing, formula recognition, general text recognition, and multilingual recognition. Also supports image rotation correction. Includes
qwen-vl-ocr(stable),qwen-vl-ocr-latest(latest),qwen-vl-ocr-2025-11-20, andqwen-vl-ocr-2025-08-28models. - Early versions (not recommended): These versions are inferior to newer models in both features and performance. We recommend migrating to
qwen3.5-ocr. Includesqwen-vl-ocr-2025-04-13andqwen-vl-ocr-2024-10-28models.
Online experience: Visit Model Studio console, select the target region in the upper-right corner, and go to Vision Models to try Qwen-OCR models.qwen-vl-ocr, qwen-vl-ocr-2025-04-13, and qwen-vl-ocr-2025-08-28models, themax_tokensparameter (maximum output length) defaults to 4096. To increase this value to a range of 4097 to 8192, contact your commercial manager and provide the following information: your Alibaba Cloud account ID, image type (such as document images, e-commerce images, or contracts), model name, estimated Queries Per Second (QPS) and total daily requests, and the percentage of requests where the model output length exceeds 4096 tokens.
Preparations
- Create an API key and set it as an environment variable.
-
If you use the OpenAI SDK or DashScope SDK, install the latest SDK version. Minimum versions: DashScope Python SDK 1.22.2, Java SDK 2.21.8.
-
DashScope SDK
- Advantages: Full access to advanced features — image rotation correction, built-in OCR tasks — with a simple API.
- Best for: Projects that need the complete feature set.
-
OpenAI-compatible SDK
- Advantages: Drop-in replacement for existing OpenAI SDK integrations.
- Limitations: Advanced features such as image rotation correction and built-in OCR tasks are not directly exposed as parameters. Simulate them by crafting prompts and parsing the output.
- Best for: Projects already using OpenAI that don't need DashScope-exclusive features.
-
DashScope SDK
Getting started
The following example extracts structured fields from a train ticket image (URL) and returns the results as JSON. For local files, see how to pass a local file. For input constraints, see image limitations.
- OpenAI compatible-Chat
- OpenAI compatible-Response
- DashScope
Example response
Example response
Call built-in tasks
Models (except qwen-vl-ocr-2024-10-28) ship with built-in tasks for common OCR scenarios.
How to call a built-in task:
- DashScope SDK: Set the
ocr_optionsparameter to call built-in tasks. Starting fromqwen3.5-ocr, built-in tasks work together with your custom Prompt (no longer overriding it), and built-in task results are returned in theocr_resultfield. Earlier models use a fixed internalPrompt. - OpenAI-compatible SDK: Pass the task-specific
Promptmanually in your message.
task value, a fixed Prompt, an output format, and an example output:
- High-precision recognition
- Information extraction
- Table parsing
- Document parsing
- Formula recognition
- General text recognition
- Multilingual recognition
qwen-vl-ocr-2025-08-28 or the latest version (recommended). Features:- Recognizes and extracts text content.
- Detects the position of text by locating text lines and outputting their coordinates.
To draw bounding boxes on the original image using the returned coordinates, see the FAQ .
| Value of task | Specified prompt | Output format and example |
|---|---|---|
advanced_recognition | Locate all text lines and return the coordinates of the rotated rectangle ([cx, cy, width, height, angle]). |
|
Example response
Example response
PDF document parsing
qwen3.5-ocr supports passing PDF files directly through the Response API for document parsing, without manually splitting the PDF into images. The output length is not limited by the model's maximum output length, enabling complete parsing of long documents. Only the Response API is supported; the Chat API is not supported. PDF file limits: up to 10 pages and no more than 100 MB.
The following examples use the Response API to pass PDF files for document parsing.
For earlier models (qwen-vl-ocr-2025-11-20and before) that do not support the Response API, use an image processing library such asPython'spdf2imageto convert each PDF page to an image, and then use the multi-image input method for page-by-page recognition.
For more usages of the OpenAI Responses API (such as retrieving and managing completed model responses), see OpenAI compatible - Responses.
Pass a local file (Base64 encoding or file path)
Upload local files using Base64 encoding or a direct file path. Select the method based on file size and SDK type — see How to select a file upload method. Both methods must meet the file requirements in Image limits.
- Use Base64 encoding
- Use file path
Steps to pass a Base64-encoded string
Steps to pass a Base64-encoded string
-
Encode the file: Convert the local image to a Base64-encoded string.
Example code for converting an image to a Base64-encoded string
-
Construct a Data URL in the following format:
data:[MIME_type];base64,{base64_image}.- Replace
MIME_typewith the actual media type. Make sure that the type matches theMIME Typevalue in the Image limits table, such asimage/jpegorimage/png. base64_imageis the Base64-encoded string generated in the previous step.
- Replace
-
Call the model: Pass the
Data URLusing theimageorimage_urlparameter to call the model.
- Pass a file path
- Pass a Base64-encoded string
Passing a file path is supported only for calls made with the DashScope Python and Java SDKs. This method is not supported for DashScope HTTP or OpenAI-compatible methods.
More usages
Limitations
Image limits
- Dimensions and aspect ratio: The image width and height must both be greater than 10 pixels. The aspect ratio must not exceed 200:1 or 1:200.
- Total pixels: The model automatically scales images, so there is no strict limit on the total number of pixels. However, an image cannot exceed 15.68 million pixels.
-
Supported image formats
-
For images with a resolution below 4K
(3840x2160), the following formats are supported:Image format
Common extensions
MIME type
BMP
.bmp
image/bmp
JPEG
.jpe, .jpeg, .jpg
image/jpeg
PNG
.png
image/png
TIFF
.tif, .tiff
image/tiff
WEBP
.webp
image/webp
HEIC
.heic
image/heic
-
For images with a resolution from
4K(3840x2160)to8K(7680x4320), only the JPEG, JPG, and PNG formats are supported.
-
For images with a resolution below 4K
-
Image size:
- If you provide an image using a public URL or a local path:
qwen3.5-ocrsupports images up to20 MB; other versions support up to10 MB. - If you provide the data in Base64 encoding, the encoded string cannot exceed
10 MB.
See also: How do I compress an image or video to the required size? .
- If you provide an image using a public URL or a local path:
Model limits
-
System message: Qwen-OCR uses a fixed internal
System Messageand does not accept a custom one. Pass all instructions in theUser Message. -
Multi-turn conversations: Starting from
qwen3.5-ocr, multi-turn conversations are supported — you can send follow-up text messages without an image URL.qwen-vl-ocr-2025-11-20and earlier versions process only the most recent message and do not retain context. - Hallucination risk: The model may hallucinate if text in an image is too small or has a low resolution. Additionally, the accuracy of answers to questions not related to text extraction is not guaranteed.
-
Error processing text files:
- For files that contain image data, follow the recommendations in Going live to transform them into an image sequence before processing.
- For files with plain text or structured data, use Qwen-Long, a model that can parse long text.
Supported certificate and document types
The information extraction task supports structured data extraction from the following certificates, receipts, and permits.
- Passports and travel documents: Chinese passport, Macau passport, Mainland Travel Permit for Hong Kong and Macau Residents, Mainland Travel Permit for Taiwan Residents, and Home Return Permit for Hong Kong and Macau Residents.
- Vehicle documents and sales invoices: driver's license, vehicle nameplate, vehicle certificate of conformity, vehicle registration certificate, motor vehicle sales invoice, and used vehicle sales invoice.
- Invoices and tax receipts: VAT ordinary invoice (roll), fixed-amount special invoice, general machine-printed invoice, tax payment certificate, and central non-tax revenue receipt.
- Transportation receipts: 12306 high-speed rail ticket, train ticket, boat ticket, expressway toll receipt, and expressway machine-printed invoice.
- Financial cards and receipts: credit card, electronic bank acceptance bill, payment receipt, and social security card.
- Business licenses and permits: business license, food business license, food production license, pharmaceutical business license, and medical device business license.
- Real estate certificate: real estate ownership certificate.
- International ID cards: Hong Kong ID, Macau ID, Indonesian ID, Thai ID, Vietnamese ID, Malaysian ID, Philippine ID, Indian ID, Turkish ID, Pakistani ID, Mexican ID, UK ID, and US ID.
- International passports and driver's licenses: Indian passport, Singapore passport, Thai passport, US passport, Australian passport, UAE passport, Philippine driver's license, Japanese driver's license, and US driver's license.
Billing and rate limiting
-
Billing: Qwen-OCR is a multimodal model. The total cost is calculated as follows: (Number of input tokens × Unit price for input) + (Number of output tokens × Unit price for output). View bills or top up your account in the Expenses and Costs console.
-
Calculating image tokens: Use the following code to estimate image token usage. Actual billing is based on the API response.
Example code for estimating image tokens
Formula: Image tokens =(h_bar * w_bar) / token_pixels + 2.-
h_bar * w_barrepresents the dimensions of the scaled image. The model pre-processes the image by scaling it to a specific pixel limit. This limit depends on the value of themax_pixelsparameter. -
token_pixelsrepresents the pixel value perToken.- For
qwen3.5-ocr,qwen-vl-ocr,qwen-vl-ocr-2025-11-20, andqwen-vl-ocr-latest, this value is fixed at32*32(which is1024). - For other models, this value is fixed at
28*28(which is784).
- For
-
-
Calculating image tokens: Use the following code to estimate image token usage. Actual billing is based on the API response.
- Rate limiting: For the rate limits for Qwen-OCR, see Rate limiting.
- Free quota (Singapore only): Qwen-OCR provides a free quota of 1 million tokens. This quota is valid for 90 days, starting from the date you activate Model Studio or your request to use the model is approved.
Going live
-
Image pre-processing:
-
Ensure that input images are clear, evenly lit, and not overly compressed:
- Store and transmit images in a lossless format (e.g., PNG) to avoid information loss.
- To improve image definition, use denoising algorithms, such as mean or median filtering, to smooth noisy images.
- To correct uneven lighting, use algorithms such as adaptive histogram equalization to adjust brightness and contrast.
-
Skewed images: Set
enable_rotate: truein the DashScope SDK to correct rotation before recognition. -
Very small or very large images: Use
min_pixelsandmax_pixelsto control image scaling.min_pixels: Enlarges small images to improve detail. Keep the default.max_pixels: Prevents oversized images from consuming too many tokens. The default handles most cases. Increase it when small text is missed — this raises token usage.
-
Ensure that input images are clear, evenly lit, and not overly compressed:
- Result validation: The model's recognition results may contain errors. For critical business operations, implement a manual review process or add validation rules to verify the accuracy of the model's output. For example, use format validation for ID card and bank card numbers.
- Batch processing: For high-volume, non-real-time workloads, use the Batch API to process jobs asynchronously at lower cost.
FAQ
How to choose a file upload method?
How to choose a file upload method?
Type | Specifications | DashScope SDK (Python, Java) | OpenAI compatible / DashScope HTTP |
|---|---|---|---|
Image | Greater than 7 MB and less than 10 MB | Pass the local path | Only public URLs are supported. Use Object Storage Service. |
Less than 7 MB | Pass the local path | Base64 encoding |
Base64 encoding increases the data size. The original file size must be less than 7 MB.
Using a local path or Base64 encoding helps prevent server-side download timeouts and improves stability.
How do I draw detection frames on the original image after the model outputs text localization results?
How do I draw detection frames on the original image after the model outputs text localization results?
The response is empty or contains frontend-style tags after I pass a custom Prompt. What do I do?
The response is empty or contains frontend-style tags after I pass a custom Prompt. What do I do?
qwen3.5-ocr, if your custom Prompt contains a complete HTML structure, such as <html><body>...</body></html>, the model may follow that structure and return the OCR result in HTML format instead of plain text. The response then looks empty or appears to contain frontend-style tags. A simple tag, such as a single <br>, does not trigger this behavior.To resolve this issue, use one of the following methods:- Check whether your Prompt contains a complete HTML tag structure. If it does, replace it with a plain text instruction and try again. For example, change
<html><body>Extract all text from the image</body></html>toExtract all text from the image. - If you are unsure whether your Prompt affects the output format, omit the
textfield to use the default Prompt of the model. - Use the
qwen3.7-plusmodel instead. This model returns a plain text result even when you pass the same Prompt that contains an HTML structure.



