API Documentation

Quick Start

Get your API key and start converting documents in minutes.

Get Started →

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:

ParameterTypeRequiredDescription
documentobjectYesDocument object
document.typestringYesFixed value "image_url"
document.image_urlstringYesImage URL or base64 data
filenamestringNoFilename (recommended for base64 data)
keystringNoAPI 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:

FieldTypeDescription
idstringUnique identifier for the processed document
filenamestringOriginal filename of the processed image
contentstringExtracted text content in plain text format
formatstringOutput format (always "text" for this API)
timestampnumberProcessing timestamp in milliseconds
payloadstringAPI endpoint used for processing

Error Responses:

Status CodeDescription
400Bad Request - Invalid input parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient quota or permissions
429Too Many Requests - Rate limit exceeded
500Internal 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

  1. Image Quality: Use high-resolution images with clear text for better accuracy
  2. Text Contrast: Ensure good contrast between text and background
  3. Image Orientation: Make sure text is properly oriented (not rotated)
  4. File Size: Optimize image size for faster processing while maintaining quality
  5. 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"])
Text Recognition API - LLMOCR Developer Guide