API Documentation
Text Recognition API
High-precision text recognition focused on Chinese and English, returns results in pure text format, suitable for daily documents and screenshots
Overview
The Text Recognition API extracts text from image files with high precision, specifically optimized for Chinese and English text recognition. It returns the recognized text in plain text format, making it ideal for daily documents, screenshots, and general text extraction tasks.
This API uses a unified JSON request format, accepting either URL references or base64-encoded image data.
Authentication
The API supports two authentication methods:
- API Key: Pass your API key as a query parameter
?key=YOUR_API_KEY
Extract Text from Image
Extract text from an image file using high-precision text recognition technology, optimized for Chinese and English languages.
Request
POST /api/text-recognition
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
document | object | Yes | Document object |
document.type | string | Yes | Fixed value "image_url" |
document.image_url | string | Yes | Image URL or base64 data |
filename | string | No | Filename (recommended for base64 data) |
key | string | No | API key (query parameter, optional for logged-in users) |
Supported Languages:
- Chinese (中文)
- English (English)
Examples:
Using Image URL:
curl -X POST "https://llmocr.com/api/text-recognition?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"type": "image_url",
"image_url": "https://llmocr.com/image.jpg"
}
}'
Using Base64 Image Data:
curl -X POST "https://llmocr.com/api/text-recognition?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"type": "image_url",
"image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD..."
},
"filename": "document.jpg"
}'
Response
Success Response (200):
{
"id": "12345",
"filename": "document.jpg",
"content": "This is the extracted text content from the image.\n\n这是从图像中提取的文本内容。",
"format": "text",
"timestamp": 1640995200000,
"payload": "https://llmocr.com/api/text-recognition?key=YOUR_API_KEY"
}
Response Fields:
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the processed document |
filename | string | Original filename of the processed image |
content | string | Extracted text content in plain text format |
format | string | Output format (always "text" for this API) |
timestamp | number | Processing timestamp in milliseconds |
payload | string | API endpoint used for processing |
Error Responses:
Status Code | Description |
---|---|
400 | Bad Request - Invalid input parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Insufficient quota or permissions |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Processing failed |
Error Response Format:
{
"statusText": "Error description"
}
Supported Image Formats
- JPEG (.jpg, .jpeg)
- PNG (.png)
- GIF (.gif)
- WebP (.webp)
Rate Limits
- Free tier: 30 requests per month
- Basic tier: 1,000 requests per month
- Pro tier: 5,000 requests per month
- Ultra tier: Unlimited requests
Image Requirements
- Maximum file size: 10MB
- Minimum resolution: 100x100 pixels
- Maximum resolution: 4000x4000 pixels
- Supported formats: JPEG, PNG, GIF, WebP
Best Practices
- Image Quality: Use high-resolution images with clear text for better accuracy
- Text Contrast: Ensure good contrast between text and background
- Image Orientation: Make sure text is properly oriented (not rotated)
- File Size: Optimize image size for faster processing while maintaining quality
- Error Handling: Always implement proper error handling for API responses
SDK Examples
JavaScript/Node.js
const response = await fetch('https://llmocr.com/api/text-recognition?key=YOUR_API_KEY', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
document: {
type: 'image_url',
image_url: 'https://example.com/image.jpg'
}
})
});
const result = await response.json();
console.log(result.content);
Python
import requests
url = "https://llmocr.com/api/text-recognition"
params = {"key": "YOUR_API_KEY"}
data = {
"document": {
"type": "image_url",
"image_url": "https://example.com/image.jpg"
}
}
response = requests.post(url, params=params, json=data)
result = response.json()
print(result["content"])