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Привет!Hello!Bonjour!Merhaba!Ciao!Hello!Ola!בר מולדSalam! |
Recognizing tilted images![]() | IntroductionThis product is made of Korean imported fiber. It does not shrink, deform, mold, breed bacteria, or damage item surfaces. It features true oil non-stick performance, strong water absorption, water immersion resistance, easy cleaning, non-toxicity, no residue, and quick drying.Shop owner experience: Stainless steel, ceramics, bathtubs, and overall bathrooms mostly have white, smooth surfaces. Surface stains are difficult to remove with other cleaning cloths, and cloths that are too sharp can easily leave scratches. With this simulated loofah cloth, dip it in a small amount of neutral detergent, rub out foam, and these surface stains can be easily wiped clean.6941990612023Item No.: 2023 |
Locating text positions![]() The High-precision recognition task supports the text locating feature. | Visualized locating results![]() For more information, see the FAQ to draw the bounding boxes of each line of text on the original image. |
Model selection
Qwen-OCR provides the following models. Select one based on your business requirements:
- Qwen3.5-OCR: Built on the Qwen3.5 architecture, with comprehensive upgrades in document parsing, text locating, and key information extraction. Supports multi-turn conversations and PDF document parsing. Delivers significantly improved performance in extracting information from business certificates (ID cards, driver's licenses, etc.). For the supported certificate and receipt types, see Supported certificate and receipt types. Includes the
qwen3.5-ocrmodel. - Qwen-VL-OCR: Built on the Qwen3-VL architecture, supports built-in tasks such as document parsing, text locating (high-precision recognition), information extraction, table parsing, formula recognition, general text recognition, and multilingual recognition, and supports image rotation correction. Includes the
qwen-vl-ocr(stable) andqwen-vl-ocr-2025-11-20models. - Early versions (not recommended): Their features and performance are inferior to the new versions. We recommend migrating to
qwen3.5-ocr. Includes theqwen-vl-ocr-2024-10-28model.
The qwen-vl-ocr model's max_tokens` parameter (Maximum Output) defaults to 4096. To increase this parameter to the 4097~8192 range, contact your business manager to apply and provide: the Alibaba Cloud account ID, image types (document images, e-commerce images, contracts, etc.), model name, expected QPS and total daily requests, and the proportion of requests with output lengths exceeding 4096.
Preparations
- You have obtained an API Key and configured the API Key in environment variables.
-
If you use the OpenAI SDK or DashScope SDK, install the latest SDK version first. The minimum DashScope Python SDK version is 1.22.2, and the minimum Java SDK version is 2.21.8.
-
DashScope SDK
- Advantages: Supports all advanced features such as image rotation correction and built-in OCR tasks, with complete functionality and simple calls.
- Applicable Scenario: Projects that require the full feature set.
-
OpenAI-compatible SDK
- Advantages: Projects that already use the OpenAI SDK or ecosystem tools can migrate quickly.
- Limitations: Advanced features (image rotation correction and built-in OCR tasks) do not support direct calls through parameters. You must manually construct a Prompt for impersonation and parse the output results yourself.
- Applicable Scenario: Projects with existing OpenAI integrations that do not rely on DashScope-specific advanced features.
-
DashScope SDK
QuickStart
The following example extracts key information from a train ticket image (URL) and returns it in JSON format. To pass in local files, see How to pass in local files; for image specification requirements, see Image limits.
- OpenAI-compatible-Chat
- OpenAI-compatible-Response
- DashScope
Example response
Example response
Calling built-in tasks
To simplify calls in specific scenarios, the models (except qwen-vl-ocr-2024-10-28) have a variety of tasks built in.
Call Method:
- DashScope SDK: Set the
ocr_optionsparameter to call built-in tasks. Sinceqwen3.5-ocr, customized tasks are used in combination with user-defined Prompts (no longer forcibly overridden), and customized task results are returned through theocr_resultfield. Earlier versions use a fixedPromptinternally. - OpenAI-compatible SDK: You must manually pass in the
Promptspecified for the task.
task values, the specified Prompt, output format, and examples for each built-in task:
- High-precision recognition
- Information extraction
- Table parsing
- Document parsing
- Formula recognition
- General text recognition
- Multilingual recognition
qwen-vl-ocr-2025-11-20 or later versions, or the latest model, which supports:- Text content recognition (extracting text)
- Text position detection (locating text lines and outputting coordinates)
After obtaining the text bounding box coordinates, you can refer to the FAQ to draw the detection boxes onto the original image.
| Value of task | Specified prompt | Output format and example |
|---|---|---|
advanced_recognition | Locates all text lines and returns the coordinate results as rotated rectangles ([cx, cy, width, height, angle]). |
|
Example response
Example response
PDF document parsing
qwen3.5-ocr supports passing PDF files directly for document parsing through the Response API, so there is no need to manually split the PDF into images, and the output length is not limited by the model's maximum output length, so long documents can be parsed in full. Only Response API calls are supported; Chat API is not supported. PDF file limits: no more than 100 MB; the page limit depends on the task in ocr_options — up to 50 pages when it is set to document_parsing, and up to 10 pages when task is not set or is set to another task.
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:
- Public URLs and local paths: a single image must not exceed
20MBforqwen3.5-ocr, and10MBfor other versions. - Base64 encoding: the encoded string must not exceed
10MB.
See also: How do I compress an image or video to the required size? .
- Public URLs and local paths: a single image must not exceed
Model limits
-
System Message: Qwen-OCR does not support custom
System Message. The model uses a fixedSystem Messageinternally, and all instructions must be passed in through theUser Message. -
Multi-turn: Multi-turn conversations are supported starting from
qwen3.5-ocr, and you can ask pure text follow-up questions without passing in an image URL.qwen-vl-ocr-2025-11-20and earlier versions only process the latest message and do not retain context. - Hallucination risk: When the text in the image is too small or the resolution is low, the model may produce hallucinations. For questions not related to text extraction, the accuracy of the model is not guaranteed.
-
Cannot process 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, andqwen-vl-ocr-2025-11-20, 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 limits: For the rate limit rules of Qwen-OCR models, see Rate limits
- Free quota (Singapore region only): Within 90 days from the date of activating Model Studio or of the model application being approved, Qwen-OCR provides a free quota of 1 million tokens.
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: ensures that details remain recognizable after small images are enlarged. Keep the default value.max_pixels: prevents oversized images from consuming too many tokens. The default value works for most scenarios. If small text is not recognized clearly, you can increasemax_pixelsappropriately, but this increases token consumption.
-
Ensure that input images are clear, evenly lit, and not overly compressed:
- Result verification: Model recognition results may contain errors. For critical business scenarios, it is recommended to add a manual review step or introduce format verification rules (such as ID card number or bank card number verification).
- Batch calls: For large-scale, non-real-time scenarios, you can use the Batch API to process batch tasks asynchronously to reduce call costs.
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. We recommend using Alibaba Cloud 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 a custom Prompt contains a complete HTML structure (for example, <html><body>...</body></html>), the model may follow that structure and return the OCR results in HTML format instead of plain text, in which case the returned content may appear to be empty or to contain front-end tags. Including only simple tags (for example, a single <br>) does not trigger this behavior.To resolve this issue, use one of the following methods:- Check whether the Prompt contains a complete HTML tag structure. If so, retry with plain text instructions. For example, change
<html><body>请提取图片中的所有文字</body></html>toPlease extract all text from the image. - If you are not sure whether the Prompt affects the output format, you can omit the
textfield and use the model's default Prompt. - Switch to the
qwen3.7-plusmodel, which still returns plain text results when given the same Prompt with an HTML structure.



