Extract structured data from documents with qwen-doc-turbo: information extraction, content moderation, classification, and summarization.
Document mining models are designed for information extraction, content moderation, classification, and summarization. Compared with general-purpose chat models,
Explicit cache is supported. Cache writes cost $0.109 per 1M tokens and cache hits cost $0.009 per 1M tokens.
You can pass document content to
Pass public file URLs and use a prompt to constrain the output format. The following example extracts product information from two product manuals as a JSON array.
Upload a file through the OpenAI-compatible Files API to get a
Put
If the file is still being parsed, the API returns
You can also pass document content as a string. To keep the model from confusing the role instruction with the document content, always put the role instruction in the first system message.
The model usually returns JSON, but it may wrap the output in a Markdown code fence. Strip the fence before calling
Where are uploaded files stored?
Files uploaded through the OpenAI-compatible Files API are stored in your QwenCloud account storage at no cost. See Files API to manage them.
Can a file ID be reused with other models?
File IDs can be used with document mining and with Batch calls.
Does file parsing cost anything?
No. Document parsing is free.
How do I know a file has finished parsing?
Try a chat request with the file ID. If parsing is still in progress, the API returns
qwen-doc-turbo returns well-formed structured output, such as JSON, quickly and precisely, and extracts information more accurately.
Supported regions: China North 2 (Beijing) only. Use an API key created in that region and https://cn-beijing.maas.qwencloudapi.com. See Regions and endpoints.
Supported models
| Model | Context window | Max input | Max output | Input cost (per 1M tokens) | Output cost (per 1M tokens) |
|---|---|---|---|---|---|
qwen-doc-turbo | 262,144 | 253,952 | 8,192 | $0.087 | $0.144 |
Input methods
You can pass document content to qwen-doc-turbo in three ways. For file size and type limits, see Limitations.
| File URL (recommended) | File ID | Plain text | |
|---|---|---|---|
| Source | Public URL | Local file (upload first) | String in the request |
| Input limit | Up to 10 files, up to 253k tokens | One file, up to 253k tokens | Up to 9,000 tokens |
| API compatibility | DashScope only | Upload: OpenAI compatible. Chat: OpenAI compatible and DashScope | OpenAI compatible and DashScope |
| Advantages | No upload, batch calls | Reuse without re-uploading | No file management |
Pass files by URL
Pass public file URLs and use a prompt to constrain the output format. The following example extracts product information from two product manuals as a JSON array.
Passing files by URL is supported only over the DashScope protocol. Use the DashScope Python SDK or a direct HTTP call such as curl.
file_parsing_strategy controls how files are parsed:
| Value | Behavior |
|---|---|
auto | The system decides based on file content. |
text_only | Parses text only. |
text_and_images | Parses both text and images. Takes longer. |
Pass files by file ID
Upload a file through the OpenAI-compatible Files API to get a file_id, then reference it in a system message.
Upload a file
Chat with the file
Put fileid://<FILE_ID> in a system message. The first system message sets the assistant role, and the user message contains the question about the file.
File parsing in progress, please try again later. Wait and retry. A successful response means the file is ready.
Pass plain text
You can also pass document content as a string. To keep the model from confusing the role instruction with the document content, always put the role instruction in the first system message.
Because of request body size limits, use a file URL or file ID when the content exceeds 9,000 tokens.
Parse the response
The model usually returns JSON, but it may wrap the output in a Markdown code fence. Strip the fence before calling json.loads():
Limitations
- File URL (
doc_url): Supported only over the DashScope protocol. Up to 10 public URLs per request. - File ID: Upload and manage files with the OpenAI-compatible SDK only. One file per request. Each file can be up to 150 MB. Each account can store up to 10,000 files and 100 GB in total, with no expiry. Use the Files API to delete files and free quota.
- Supported formats: TXT, DOC, DOCX, PDF, XLS, XLSX, MD, PPT, PPTX, JPG, JPEG, PNG, GIF, BMP.
- Input: The context window is 262,144 tokens when content is passed by
doc_urlor file ID. A single plain-text message is limited to 9,000 tokens. - Output: Up to 8,192 tokens.
FAQ
Where are uploaded files stored?
Files uploaded through the OpenAI-compatible Files API are stored in your QwenCloud account storage at no cost. See Files API to manage them.
Can a file ID be reused with other models?
File IDs can be used with document mining and with Batch calls.
Does file parsing cost anything?
No. Document parsing is free.
How do I know a file has finished parsing?
Try a chat request with the file ID. If parsing is still in progress, the API returns File parsing in progress, please try again later. Retry after a short wait.