Layout Parsing
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>"
}Tool API
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.
POST
/
paas
/
v4
/
layout_parsing
Layout Parsing
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>"
}Body
application/json
Response
Business processing successful
Detailed layout information
Hide child attributes
Hide child attributes
Document basic information
Token usage statistics returned when the model call ends.
Hide child attributes
Hide child attributes
Was this page helpful?