Doc2X API v2 Image Interface Documentation
From input to local files
- Prepare a readable JPG/PNG and confirm it may be processed by the Open Platform.
- Use the synchronous route to wait for one response, or the async route to retain an ID and check later. Both take raw binary, not multipart/form-data.
- Save async
data.uid, then GET status every 1–3 seconds with a total deadline. Wait forprocessing; inspectdetailforfailed; handle a non-success outercodeseparately. Do not poll by repeating POST. - On success, save
data.result, pagemd, and the optionalconvert_zipimage archive. The archive may be absent; response illustrations below do not contain a fabricated ZIP. - Check text, formulas, tables, and image paths. API results are temporary, approximately 24 hours. A local timeout does not cancel remote processing: query the original ID before resubmitting.
See PDF API authentication and errors. The image API limit is 7 MiB; the CLI's 3 MiB limit is a separate route. HTTP 200 is not a quality check, and image OCR is not the image-translation editor.
Basic Information
URL: https://v2.doc2x.noedgeai.com
Please access the API interface directly. Regions outside mainland China may experience significant network fluctuations, leading to severe file upload interruptions.
Check current account quota and rate limits on the Open Platform before batch work. The historical “30 images/30s” statement is not a guaranteed concurrency allowance for every account. Submit sequentially, preserve task IDs, and control the queue using returned states.
Authorization
Get an API Key from the Open Platform and check quota. YOUR_DOC2X_API_KEY is a placeholder, not a working credential.
Add to HTTP request headers:
Authorization: Bearer YOUR_DOC2X_API_KEYPOST /api/v2/parse/img/layout Image Layout
Image OCR interface with layout recognition, effects consistent with /parse/pdf, supports parsing and extraction of text, formulas, multi-column, tables, and images (mainly applicable to document images and document-like images).
This interface is a synchronous call interface.
Image size requirement: <= 7 MiB (7,340,032 bytes)
Pricing method: 1 image = 1 PDF page parsing (1:1), will consume generic parsing pages equally
Request Parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| body | body | binary | Yes | Request body is img(jpg/png) binary, max 7 MiB (7,340,032 bytes) |
Request Example
curl -X POST 'https://v2.doc2x.noedgeai.com/api/v2/parse/img/layout' \
--header 'Authorization: Bearer YOUR_DOC2X_API_KEY' \
--data-binary '@test.jpg'Note: --data-binary is not formdata, but written in binary form to the body. Python code example:
import requests
url = 'https://v2.doc2x.noedgeai.com/api/v2/parse/img/layout'
headers = {'Authorization': 'Bearer YOUR_DOC2X_API_KEY'}
with open('test.jpg', 'rb') as file:
response = requests.post(url, headers=headers, data=file, timeout=(10, 90))
response.raise_for_status() # use data
print(response.text)Response Example
{
"code": "success",
"data": {
"convert_zip": null,
"result": {
"pages": [
{
"page_width": 1000,
"page_height": 1000,
"md": "123456789"
}
]
},
"uid": "01940000-0000-0000-0000-111111111"
}
}File Structure After convert_zip Extraction
.
|--images # Image resource files
|--example1.jpg
|--example2.jpgPOST /api/v2/async/parse/img/layout Asynchronous Image Layout Task Submission
Image OCR interface with layout recognition, effects consistent with /parse/pdf, supports parsing and extraction of text, formulas, multi-column, tables, and images (mainly applicable to document images and document-like images).
This interface is an asynchronous call interface.
Image size requirement: <= 7 MiB (7,340,032 bytes)
Pricing method: 1 image = 1 PDF page parsing (1:1), will consume generic parsing pages equally
Asynchronous Image Request Parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| body | body | binary | Yes | Request body is img(jpg/png) binary, max 7 MiB (7,340,032 bytes) |
Asynchronous Image Request Example
curl -X POST 'https://v2.doc2x.noedgeai.com/api/v2/async/parse/img/layout' \
--header 'Authorization: Bearer YOUR_DOC2X_API_KEY' \
--data-binary '@test.jpg'Note: --data-binary is not formdata, but written in binary form to the body. Python code example:
import requests
url = 'https://v2.doc2x.noedgeai.com/api/v2/async/parse/img/layout'
headers = {'Authorization': 'Bearer YOUR_DOC2X_API_KEY'}
with open('test.jpg', 'rb') as file:
response = requests.post(url, headers=headers, data=file, timeout=(10, 90))
response.raise_for_status() # use data
print(response.text)Asynchronous Image Response Example
{
"code": "success",
"data": {
"uid": "01940000-0000-0000-0000-111111111"
}
}GET /api/v2/parse/img/layout/status Asynchronous Image Layout Processing Status
Asynchronous Image Processing Status Request Parameters
Request Headers
| Name | Description | Example Value |
|---|---|---|
| Authorization | Api key | Bearer YOUR_DOC2X_API_KEY |
Request Body
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| uid | query | string | Yes | Asynchronous task id |
Asynchronous Image Processing Status Request Example
curl --request GET 'https://v2.doc2x.noedgeai.com/api/v2/parse/img/layout/status?uid=01920000-0000-0000-0000-000000000000' \
--header 'Authorization: Bearer YOUR_DOC2X_API_KEY'Asynchronous Image Processing Status Response Examples
Processing Completed
{
"code": "success",
"data": {
"status": "success",
"result": {
"pages": [
{
"url": "01952205-b26f-7930-93c1-103c88156729_0.jpg",
"page_idx": 0,
"page_width": 1080,
"page_height": 4322,
"md": "<!-- Media -->\n\n<img src=\"01952205-b26f-7930-93c1-103c88156729_0_0_59_1080_4221_0.jpg\"/>\n\n<!-- Media -->"
}
]
},
"convert_zip": null
}
}Failed Processing
{
"code": "parse_error",
"msg": "Parse error"
}Processing
{
"code": "success",
"data": {
"status": "processing"
}
}Asynchronous Task convert_zip File Structure After Extraction
.
|--images # Image resource files
|--example1.jpg
|--example2.jpgSave Markdown and image resources
Save the successful synchronous response or completed async status response as image-response.json. This Python 3.10+ example reads local files only. Save it as save_image_result.py and run python save_image_result.py.
import base64
import io
import json
import zipfile
from pathlib import Path
def save_image_response(body, output_dir):
if body.get("code") != "success":
raise ValueError(f"API error: {body.get('code')}")
data = body["data"]
if "status" in data and data["status"] != "success":
raise ValueError(f"Not a completed result: {data['status']}")
result = data["result"]
encoded = data.get("convert_zip")
archive = base64.b64decode(encoded, validate=True) if encoded else None
if archive is not None and not zipfile.is_zipfile(io.BytesIO(archive)):
raise ValueError("convert_zip is not a ZIP; retain response and check the service format")
out = Path(output_dir)
out.mkdir(exist_ok=False)
(out / "result.json").write_text(
json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
(out / "result.md").write_text("\n\n".join(
page.get("md", "") for page in result.get("pages", [])), encoding="utf-8")
if archive is not None:
(out / "images.zip").write_bytes(archive)
return out
if __name__ == "__main__":
body = json.loads(Path("image-response.json").read_text(encoding="utf-8"))
print(save_image_response(body, "image-output"))Open image-output/result.md. When present, inspect image-output/images.zip with unzip -l, then extract into a new directory and preserve the paths referenced by Markdown. An archive containing images does not prove every reference is complete. Rendered tables are not XLSX export evidence.
| Symptom | Action |
|---|---|
| 401/403, quota error, or 429 | Check Open Platform Key/quota/rate limits and reduce queue concurrency; do not substitute a desktop token. |
| Invalid image/size | Check actual JPG/PNG data and the 7 MiB limit; convert or reduce locally first. |
| Failed/expired task | Retain uid/detail and check local backups; avoid endless creation retries. |
| Invalid Base64/ZIP | Retain a redacted error and original response; verify the service format before extracting. |
| Missing Markdown images | Compare references with extracted files and preserve relative resource paths. |