GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • docs
  • DASHBOARD
  • PLAYGROUND
  • COMMUNITY
  • LOG IN
  • Guides and concepts
  • API Reference
  • Release Notes
  • LLMU
  • Cookbooks
  • Cohere Platform
  • Quickstart
  • Previous
  • Document Parsing - best practicesNext

This view

  • Original page
  • New address

GeezerVison is showing docs.cohere.com — Cohere Documentation

Skip to navigation
On this page
  • About the Parse API
  • Further Resources
This page is for version v2 API (default). For other versions, use one of these documentation indexes: - v2 API (default): https://docs.cohere.com/v2/llms.txt - v1 API: https://docs.cohere.com/v1/llms.txt

About the Parse API

Cohere’s Parse model converts unstructured enterprise documents (PDFs, images, slides) into structured Markdown output. It extracts text, tables, lists, forms, images, captions, and bounding box coordinates.

This quickstart guide shows you how to parse a document image with the Parse endpoint.

1

Setup

First, install the Cohere Python SDK with the following command.

pip install -U cohere

Next, import the library and create a client.

Cohere Platform
Private Deployment
SageMaker
PYTHON
import cohere
co = cohere.ClientV2(
"COHERE_API_KEY"
) # Get your free API key here: https://dashboard.cohere.com/api-keys
2

Prepare the Document

Parse accepts documents as base64-encoded data URIs. Convert your image to a data URI.

PYTHON
import base64
with open("document.png", "rb") as f:
b64 = base64.b64encode(f.read()).decode("utf-8")
data_uri = f"data:image/png;base64,{b64}"
3

Parse the Document

Pass the document to the Parse endpoint. By default, the response contains Markdown output.

Cohere Platform
Private Deployment
SageMaker
PYTHON
response = co.parse(
model="parse-v5.0",
document={"type": "image_url", "image_url": data_uri},
)
for page in response.pages:
print(page.markdown.content)
4

Blocks Output

To get structured content blocks, set output_format to "blocks". Each block has a type (e.g. text, table) with type-specific fields including bounding boxes for tables.

PYTHON
response = co.parse(
model="parse-v5.0",
document={"type": "image_url", "image_url": data_uri},
output_format="blocks",
)
for page in response.pages:
for block in page.blocks:
if block.type == "text":
print(block.text.content)
elif block.type == "table":
print(f"[Table] bbox={block.table.bounding_box}")
print(block.table.html)
print(block.table.description)
print()

Further Resources

  • Parse model documentation
  • SageMaker notebook
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.