curl --request POST \
--url https://api.z.ai/api/paas/v4/layout_parsing \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-ocr",
"file": "https://cdn.bigmodel.cn/static/logo/introduction.png"
}
'import requests
url = "https://api.z.ai/api/paas/v4/layout_parsing"
payload = {
"model": "glm-ocr",
"file": "https://cdn.bigmodel.cn/static/logo/introduction.png"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'glm-ocr', file: 'https://cdn.bigmodel.cn/static/logo/introduction.png'})
};
fetch('https://api.z.ai/api/paas/v4/layout_parsing', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.z.ai/api/paas/v4/layout_parsing")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"glm-ocr\",\n \"file\": \"https://cdn.bigmodel.cn/static/logo/introduction.png\"\n}")
.asString();{
"id": "task_123456789",
"created": 1727156815,
"model": "GLM-OCR",
"md_results": "# Doc title\nThis is the document content...",
"layout_details": [
[
{
"index": 1,
"label": "text",
"bbox_2d": [
0.1,
0.1,
0.5,
0.3
],
"content": "This is the content of the element",
"height": 800,
"width": 600
}
]
],
"layout_visualization": [
"<string>"
],
"data_info": {
"num_pages": 5,
"pages": [
{
"width": 600,
"height": 800
}
]
},
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123
},
"total_tokens": 123
},
"request_id": "req_123456789"
}{
"code": 123,
"message": "<string>"
}Layout Parsing
Use the GLM-OCR model to parse the layout of documents and images and extract text content. Support OCR recognition of images and PDF documents, returning detailed layout information and visualization results.
curl --request POST \
--url https://api.z.ai/api/paas/v4/layout_parsing \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-ocr",
"file": "https://cdn.bigmodel.cn/static/logo/introduction.png"
}
'import requests
url = "https://api.z.ai/api/paas/v4/layout_parsing"
payload = {
"model": "glm-ocr",
"file": "https://cdn.bigmodel.cn/static/logo/introduction.png"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'glm-ocr', file: 'https://cdn.bigmodel.cn/static/logo/introduction.png'})
};
fetch('https://api.z.ai/api/paas/v4/layout_parsing', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.z.ai/api/paas/v4/layout_parsing")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"glm-ocr\",\n \"file\": \"https://cdn.bigmodel.cn/static/logo/introduction.png\"\n}")
.asString();{
"id": "task_123456789",
"created": 1727156815,
"model": "GLM-OCR",
"md_results": "# Doc title\nThis is the document content...",
"layout_details": [
[
{
"index": 1,
"label": "text",
"bbox_2d": [
0.1,
0.1,
0.5,
0.3
],
"content": "This is the content of the element",
"height": 800,
"width": 600
}
]
],
"layout_visualization": [
"<string>"
],
"data_info": {
"num_pages": 5,
"pages": [
{
"width": 600,
"height": 800
}
]
},
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123
},
"total_tokens": 123
},
"request_id": "req_123456789"
}{
"code": 123,
"message": "<string>"
}Authorizations
Body
Model code: glm-ocr
glm-ocr "glm-ocr"
Image or PDF document to be recognized, supports URL and base64. Supported image formats: PDF, JPG, PNG. Single image ≤10MB, PDF ≤50MB, maximum support 30 pages
"https://cdn.bigmodel.cn/static/logo/introduction.png"
Whether to return screenshot information
Whether to return detailed layout image result information
Start page number for parsing when PDF is provided
x >= 1End page number for parsing when PDF is provided
x >= 1Passed by the user side, needs to be unique; used to distinguish each request, 6–64 characters. If not provided by the user side, the platform will generate one by default.
6 - 64Unique ID for the end user, 6–128 characters. Avoid using sensitive information.
6 - 128Response
Business processing successful
Task ID
"task_123456789"
Request creation time, Unix timestamp in seconds
1727156815
Model name
"GLM-OCR"
Recognition result in Markdown format
"# Doc title\nThis is the document content..."
Detailed layout information
Hide child attributes
Hide child attributes
Element index
1
Element type: image for images, text for text content, formula for inline formulas, table for tables
image, text, formula, table "text"
Normalized element coordinates [x1,y1,x2,y2]
4 elements0 <= x <= 1[0.1, 0.1, 0.5, 0.3]
Element content (text / image URL / table HTML)
"This is the content of the element"
Page height
800
Page width
600
Recognition result image URLs
Document basic information
Token usage statistics returned when the model call ends.
Hide child attributes
Hide child attributes
Request ID
"req_123456789"
Was this page helpful?