Quickstart
Comprehensive guide for using the Deepseek OCR API on Kloudihub.
Quickstart
The Deepseek OCR API allows you to extract text from images and documents with high accuracy. This guide provides connection details, API usage, and code examples for various programming languages.
Introduction
Deepseek OCR is a state-of-the-art Optical Character Recognition engine designed to transform unstructured documents into structured, actionable data. Leveraging advanced machine learning models, it delivers exceptional accuracy across various document types, including invoices, contracts, ID cards, and handwritten notes.
Whether you are building a document management system, automating data entry, or analyzing scanned archives, Deepseek OCR provides the reliability and speed needed for enterprise-grade applications. Key features include:
- High Accuracy: Precision text extraction even from low-quality images.
- Multi-Format Support: Process PDFs, JPGs, PNGs, and more.
- Structure Recognition: Maintains paragraphs, lists, and table structures.
- Fast Processing: Optimized for real-time applications.
properties
| Property | Value |
|---|---|
| Base URL | https://kloudihub.com |
| Endpoint | /api/v1/deepseek-ocr |
| Method | POST |
| Content-Type | multipart/form-data |
Authentication
Authentication is handled via a Bearer Token. Ensure you include your API key in the Authorization header.
Authorization: Bearer <YOUR_API_KEY>Request Parameters
The API accepts a file upload via multipart/form-data.
| Parameter | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The image or document file to be processed (jpg, png, pdf). |
language | String | No | Optional language code (e.g., eng, chn) for better accuracy. |
Response Format
The API returns a JSON response containing the extracted text and confidence scores.
{
"status": "success",
"data": {
"text": "Extracted text content...",
"confidence": 0.98,
"pages": 1
}
}Code Examples
curl -X POST https://kloudihub.com/api/v1/deepseek-ocr \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/document.pdf"Using the axios library:
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('file', fs.createReadStream('/path/to/document.pdf'));
axios.post('https://kloudihub.com/api/v1/deepseek-ocr', form, {
headers: {
...form.getHeaders(),
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});Using the native fetch API:
const fs = require('fs');
async function uploadFile() {
const formData = new FormData();
formData.append('file', new Blob([fs.readFileSync('/path/to/document.pdf')]), 'document.pdf');
try {
const response = await fetch('https://kloudihub.com/api/v1/deepseek-ocr', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
uploadFile();Using axios with TypeScript:
import axios from 'axios';
import FormData from 'form-data';
import fs from 'fs';
interface OCRResponse {
status: string;
data: {
text: string;
confidence: number;
pages: number;
};
}
const uploadFile = async () => {
const form = new FormData();
form.append('file', fs.createReadStream('/path/to/document.pdf'));
try {
const { data } = await axios.post<OCRResponse>(
'https://kloudihub.com/api/v1/deepseek-ocr',
form,
{
headers: {
...form.getHeaders(),
'Authorization': 'Bearer YOUR_API_KEY',
},
}
);
console.log('Text:', data.data.text);
} catch (error) {
console.error('OCR Error:', error);
}
};
uploadFile();Using the requests library:
import requests
url = "https://kloudihub.com/api/v1/deepseek-ocr"
file_path = "/path/to/document.pdf"
api_key = "YOUR_API_KEY"
with open(file_path, "rb") as file:
files = {"file": file}
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.post(url, headers=headers, files=files)
if response.status_code == 200:
print("Response:", response.json())
else:
print(f"Error {response.status_code}: {response.text}")