Optical Character Recognition
The DeepSeek OCR API enables you to extract text from images with high accuracy. This powerful OCR model can process images from URLs or base64-encoded data, making it ideal for document processing, receipt scanning, ID card extraction, and other text recognition tasks.Key Features
- High Accuracy: Advanced OCR model for precise text extraction
- Flexible Input: Support for both URL and base64-encoded images
- Fast Processing: Optimized for quick text extraction
- Optional Image Return: Get back an annotated image with recognized text regions
- OpenAI-Compatible: Standard API format for easy integration
API Endpoint
Authentication
Include your API key in the request header:Request Parameters
The OCR model to use. Currently supports
deepseek-ocr.The image to process. Can be either:
- A publicly accessible image URL (when
image_typeis “url”) - Base64-encoded image data (when
image_typeis “base64”)
The type of image data being provided. Must be either:
"url"- Image is provided as a URL"base64"- Image is provided as base64-encoded data
Whether to return an annotated image with recognized text regions. When set to
true, the response will include result_image_base64 field containing the processed image.Response Format
The API returns a JSON response in OpenAI-compatible format with the following structure:Response Fields
- id: Unique identifier for this OCR request
- object: Type of response object, always “ocr.completion”
- created: Unix timestamp of when the request was processed
- model: The model used for OCR processing (e.g., “deepseek-ocr”)
- choices: Array containing the OCR results
- index: Choice index, always 0 for OCR
- text: The text extracted from the image
- finish_reason: Completion status, typically “stop”
- result_image_base64: Base64-encoded annotated image (only included if
return_imageis true) - usage: Token usage information for billing
Quick Start Testing
Want to try the OCR API immediately? Use this test image URL to extract text from a sample receipt: Test Image URL:https://res.cloudinary.com/dcwnn9c0u/image/upload/v1762880072/gh1nwfzslf4glu2cde9z.jpg
Quick Test with Curl
Remember: The first request may take 10-15 seconds due to cold start. If you get a timeout, wait a few seconds and try again.
Code Examples
Use Cases
Document Processing
Extract text from scanned documents, PDFs converted to images, or photographed papers for digital archival and processing.Receipt Scanning
Automatically extract transaction details, amounts, and merchant information from receipt images for expense tracking.ID Card & Document Verification
Extract information from ID cards, passports, and other identity documents for verification processes.Image Annotation
Use thereturn_image parameter to get back an annotated image showing detected text regions, useful for debugging and visualization.
Error Handling
The API returns structured error responses for invalid requests:Common Error Codes
- model_not_found: The specified model does not exist
- unsupported_capability: The model does not support OCR
- parameter_missing: Required parameter is missing
- invalid_parameter: Parameter value is invalid
- invalid_parameter_type: Parameter has wrong data type
- invalid_url_format: Image URL is malformed
- invalid_url_protocol: Image URL must use HTTP/HTTPS
- invalid_base64_format: Base64 data is not valid
Error Handling Example
Pricing
The DeepSeek OCR API uses token-based pricing:- Per Image Processing: 100 tokens equivalent (approximately 50 tokens)
- Token Cost: Charged according to your Neosantara AI pricing tier
usage field of the response.
The
return_image parameter does not affect token usage. Annotated images are provided at no additional cost.Best Practices
- First Request Latency: The first OCR request may take 10-15 seconds due to cold start initialization. Subsequent requests will be significantly faster (2-5 seconds). If you encounter a timeout on the first request, retry after a few seconds.
- Image Quality: Use high-resolution, clear images for best results
- Image Format: Supported formats include JPEG, PNG, and other common image formats
- URL Accessibility: Ensure image URLs are publicly accessible when using
image_type: "url" - Base64 Size: Be mindful of base64 encoded image sizes for large images
- Error Handling: Always implement proper error handling in your application, including retry logic for timeout errors
- Rate Limits: Respect API rate limits according to your tier
Rate Limits
Rate limits vary by your Neosantara AI subscription tier. Check your tier limits in the dashboard.Support
Need help with the OCR API? We are here to assist:- Email: support@neosantara.xyz
- Documentation: API Reference
- Community: Join our Discord community