The AlphaEdge OCR API lets you extract text from documents, images and PDFs. This feature is optimized for high performance and accuracy.
This page guides you through using the OCR API, from the basics to advanced use cases.
Optical character recognition to extract text from documents and images
The AlphaEdge OCR API lets you extract text from documents, images and PDFs. This feature is optimized for high performance and accuracy.
This page guides you through using the OCR API, from the basics to advanced use cases.
Here is a minimal example to get started with the OCR API:
import requests
url = "https://api-endpoints.alphaedge-ai.com/models/alpha-digit-max/ocr"
headers = {"X-API-Key": "TA_CLE"}
with open("/chemin/image.png", "rb") as f:
files = {"image": ("image.png", f, "image/png")}
r = requests.post(url, headers=headers, files=files, timeout=300)
print(r.status_code)
print(r.json())
curl https://api-endpoints.alphaedge-ai.com/models/alpha-digit-max/ocr \
-H "X-API-Key: TA_CLE" \
-F "file=@document.pdf" \
-F "model=alphaedge-ocr-3"
import fs from "node:fs";
const form = new FormData();
form.append("image", new Blob([fs.readFileSync("/chemin/image.png")]), "image.png");
const res = await fetch("https://api-endpoints.alphaedge-ai.com/models/alpha-digit-max/ocr", {
method: "POST",
headers: { "X-API-Key": "TA_CLE" },
body: form
});
console.log(res.status, await res.json());
Here are the available parameters for the OCR API:
| PARAMETER | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
model |
string | Yes | - | The model name to use (e.g. alphaedge-ocr-3) |
file |
File | Yes | - | The file to process (PDF, image, etc.) |
The AlphaEdge OCR API supports a wide range of document formats for text extraction. Here is the full list of supported formats:
PDF limitations: Maximum 100 pages per document, maximum size 25 MB
Image limitations: Maximum resolution 4096x4096 pixels, maximum size 25 MB per file
The OCR API returns a response in JSON format. Here is an example response structure:
{
"id": "req_abc123",
"object": "ocr.response",
"created": 1677652288,
"model": "alphaedge-ocr-3",
"text": "Le texte extrait depuis le document...",
"usage": {
"total_tokens": 60
}
}
Extract structured data from a form:
import requests
url = "https://api-endpoints.alphaedge-ai.com/models/alpha-digit-max/ocr"
headers = {"X-API-Key": "TA_CLE"}
with open("/chemin/image.png", "rb") as f:
files = {"image": ("image.png", f, "image/png")}
r = requests.post(url, headers=headers, files=files, timeout=300)
print(r.status_code)
print(r.json())
Here is how to handle errors properly:
import requests
url = "https://api-endpoints.alphaedge-ai.com/models/alpha-digit-max/ocr"
headers = {"X-API-Key": "TA_CLE"}
with open("/chemin/image.png", "rb") as f:
files = {"image": ("image.png", f, "image/png")}
r = requests.post(url, headers=headers, files=files, timeout=300)
print(r.status_code)
print(r.json())
import fs from "node:fs";
const form = new FormData();
form.append("image", new Blob([fs.readFileSync("/chemin/image.png")]), "image.png");
const res = await fetch("https://api-endpoints.alphaedge-ai.com/models/alpha-digit-max/ocr", {
method: "POST",
headers: { "X-API-Key": "TA_CLE" },
body: form
});
console.log(res.status, await res.json());
Here are some common use cases for the OCR API:
Convert paper documents to digital text for archiving and search.
Automatically extract information from scanned forms (invoices, contracts, etc.).
Extract text from images, screenshots or document photos.
To view all available OCR models with their detailed specifications, visit the Our models and filter by type.