DOCMIND_V2_ENDPOINT environment variable; limited daily free quota.DOCMIND_V2_ENDPOINT is configured, use V2 Free Mode.VariableDescriptionRequiredDOCMIND_V2_ENDPOINTV2 API service endpoint (domain or IP). Defaults to docmind.aliyuncs.comOptional
POP Mode automatically obtains credentials through the Alibaba Cloud default credential chain (environment variables, config files, ECS RAM roles, etc.) — no manual management needed.
bash
python scripts/docmind_parse.py <file_path_or_url> [options]
ParameterDescriptionDefault<file_path_or_url>Local file path or file URLRequired--modeInvocation mode: auto, v2, pop``auto``--enhancementEnhancement mode: VLM, LLM, DIGITAL, OCR, AUTONone--outputOutput format: markdown, json, html``markdown``--pagesPage range to parse, e.g. 1-5All--output-fileOutput file pathStdout--head-footParse headers and footersOff--user-promptCustom user promptNone--optionDocument parsing optionsNone--markdown-tableTable output format: html, markdownNone--markdown-imageImage output format: html, markdownNone--file-extFile extension (alternative to fileName)Auto-detected
bash
# Parse a URL (auto-select mode)
python scripts/docmind_parse.py https://example.com/doc.pdf
# Parse with VLM enhancement
python scripts/docmind_parse.py https://example.com/doc.pdf --enhancement VLM
# Parse the first 5 pages, output to a Markdown file
python scripts/docmind_parse.py ./report.pdf --pages 1-5 --output-file result.md
# Parse a local file via V2 mode (auto base64 encoding)
python scripts/docmind_parse.py ./contract.pdf --mode v2
# Parse with custom table/image output formats
python scripts/docmind_parse.py https://example.com/doc.pdf --markdown-table markdown --markdown-image html
# Parse headers and footers with a custom prompt
python scripts/docmind_parse.py https://example.com/doc.pdf --head-foot --user-prompt "Extract all footnotes"
# Force Alibaba Cloud POP mode
python scripts/docmind_parse.py ./contract.pdf --mode pop
Supports both URL and local file (base64) upload. The request body is organized into four blocks: Document, Processing, Output, and Notification.
POST {DOCMIND_V2_ENDPOINT}/skill/submit
Full request schema:
json
{
"document": {
"fileUrl": "https://example.com/doc.pdf",
"fileBase64": "<base64-encoded file content, alternative to fileUrl>",
"fileName": "doc.pdf",
"fileNameExtension": "pdf"
},
"processing": {
"enhancementMode": "VLM",
"pageIndex": "1-5",
"headFoot": false,
"userPrompt": "Custom prompt",
"option": "parsing-option"
},
"output": {
"outputFormat": ["markdown"],
"markdownTable": ["html"],
"markdownImage": ["html"],
"docExtraParameters": {"key": "value"},
"extraParameters": "audio-video-extra-params",
"ossConfig": {
"bucket": "my-bucket",
"endpoint": "oss-cn-hangzhou.aliyuncs.com",
"accessKeyId": "...",
"accessKeySecret": "...",
"securityToken": "..."
}
},
"notification": {
"enableEventCallback": false
}
}
document.fileUrlanddocument.fileBase64are mutually exclusive. When parsing a local file via V2 mode, the script automatically reads and base64-encodes the file.fileNameExtensionis auto-detected from the file extension when not explicitly provided.
Response:
json
{
"success": true,
"data": { "bizId": "docmind-20260519-xxxx" }
}
POST {DOCMIND_V2_ENDPOINT}/skill/query
json
{
"bizId": "docmind-20260519-xxxx",
"layoutStepSize": 100,
"layoutNum": 0
}
Response (on success):
json
{
"success": true,
"data": {
"status": "success",
"processing": 100.0,
"layouts": [ ... ]
}
}
Rate limiting: max 5 tasks per second per IP, global limit 20.
Three-step async workflow using the default credential chain to initialize the client:
SubmitDocParserJob / SubmitDocParserJobAdvanceQueryDocParserStatus (poll until success/fail)GetDocParserResult (incremental retrieval via LayoutNum + LayoutStepSize pagination)POP endpoint: docmind-api.cn-hangzhou.aliyuncs.com, API version: 2022-07-11
python
from alibabacloud_credentials.client import Client as CredClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_docmind_api20220711.client import Client as DocMindClient
cred = CredClient()
config = open_api_models.Config(
credential=cred,
endpoint="docmind-api.cn-hangzhou.aliyuncs.com",
user_agent="AlibabaCloud-Agent-Skills/alibabacloud-docmind-parse/" + os.environ.get("SKILL_SESSION_ID", "unknown")
)
client = DocMindClient(config)
ModeFree QuotaAfter ExhaustionV2 API DirectLimited daily quotaPrompt to activate Alibaba Cloud serviceAlibaba Cloud POP3,000 pages/monthAutomatic pay-as-you-go
When quota is exhausted, prompt the user to visit https://docmind.console.aliyun.com/doc-overview to activate the service.
Error CodeMeaningResolutionQuotaExhausted / ThrottlingQuota exhausted or rate-limitedPrompt to activate Alibaba Cloud serviceFileUrlLegalInvalid file URLVerify the URL is publicly accessibleInvalidFileFormatUnsupported file formatShow the list of supported formatsFileSizeExceededFile too largeV2 limit 5 MB, POP limit 150 MBOssAccessDeniedError / HTTP 403URL points to a private or restricted OSS resourceSee pre-validation rules below
Before invoking the script, the Agent MUST perform the following checks:
Local file path validation: If the input is a local file path, verify that the file exists and is readable before calling the script. If the file does not exist, stop immediately and ask the user to verify the path. The Agent must NEVER create, fabricate, or substitute a file to bypass a missing-file error.
Private URL detection: If the input is a URL and V2 mode returns OssAccessDeniedError or HTTP 403, the URL is likely private or requires authentication. In this case:
--mode v2 handles base64 encoding transparently).Network unreachable: If the script fails with a connection error (e.g. ConnectionError, ConnectionRefused), check that:
DOCMIND_V2_ENDPOINT (default docmind.aliyuncs.com) is reachable from the current environment.Each layout block's markdownContent field is concatenated; tables are embedded as HTML tables.
Raw layouts structured data, including type/ subType, text, markdownContent, pageNum, index, pos and other fields.
All outbound HTTP requests (V2 API and Alibaba Cloud POP SDK) set the following User-Agent header:
text
AlibabaCloud-Agent-Skills/alibabacloud-docmind-parse/{session-id}
The {session-id} segment is read from the SKILL_SESSION_ID environment variable at runtime. If the variable is not set, the value falls back to unknown.
ComponentValueUA templateAlibabaCloud-Agent-Skills/alibabacloud-docmind-parse/{session-id}session-id sourceSKILL_SESSION_ID env varFallbackunknownEnv var exampleexport SKILL_SESSION_ID=agent-abc123-session-xyz
All skill invocations sharing the same SKILL_SESSION_ID value are correlated as a single session in server-side logs.
bash
# POP mode
pip install "alibabacloud-docmind-api20220711>=1.0.0" \
"alibabacloud-credentials>=1.0.0" \
"alibabacloud-tea-openapi>=0.3.8" \
"alibabacloud-tea-util>=0.3.0" \
"alibabacloud-gateway-pop>=0.1.0"
# V2 mode
pip install "requests>=2.20.0"