A FastAPI-based web service that performs optical character recognition using the chandra-ocr library and integrates transformer models for enhanced text processing.
0
stars
0
commits
Python
primary language
Apr 18, 2026
updated
An OpenAI-compatible API for document layout analysis using the Chandra OCR 2 model.
Chandra OCR 2 is a state-of-the-art document understanding model that performs layout analysis on document images. This API provides an OpenAI-compatible interface for processing document images and extracting layout information including bounding boxes, categories, and text content.
git clone <repository-url>
cd chandr
uv sync
# The model will be automatically downloaded on first run
# Model: datalab-to/chandra-ocr-2
Run the following command to start the API server:
uv run main
The server will start on http://0.0.0.0:8000.
GET /health
Returns the health status of the API.
GET /v1/models
Returns a list of available models.
POST /v1/chat/completions
Processes a document image and returns layout analysis.
Request Body:
{
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,..."
}
}
]
}
],
"max_tokens": 24000
}
Response:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "chandra-ocr-2",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
}
]
}
],
"max_tokens": 24000
}'
The API returns layout analysis results in markdown format, including:
[x1, y1, x2, y2]This project is licensed under the MIT License.
Python
100.0%
A FastAPI-based web service that performs optical character recognition using the chandra-ocr library and integrates transformer models for enhanced text processing.
0
stars
0
commits
Python
primary language
Apr 18, 2026
updated
An OpenAI-compatible API for document layout analysis using the Chandra OCR 2 model.
Chandra OCR 2 is a state-of-the-art document understanding model that performs layout analysis on document images. This API provides an OpenAI-compatible interface for processing document images and extracting layout information including bounding boxes, categories, and text content.
git clone <repository-url>
cd chandr
uv sync
# The model will be automatically downloaded on first run
# Model: datalab-to/chandra-ocr-2
Run the following command to start the API server:
uv run main
The server will start on http://0.0.0.0:8000.
GET /health
Returns the health status of the API.
GET /v1/models
Returns a list of available models.
POST /v1/chat/completions
Processes a document image and returns layout analysis.
Request Body:
{
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,..."
}
}
]
}
],
"max_tokens": 24000
}
Response:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "chandra-ocr-2",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
}
]
}
],
"max_tokens": 24000
}'
The API returns layout analysis results in markdown format, including:
[x1, y1, x2, y2]This project is licensed under the MIT License.
Python
100.0%