KloudiHub Docs

Quickstart

Comprehensive guide for using the olmOCR API on Kloudihub.

Quickstart

The olmOCR API offers specialized OCR capabilities designed for high performance and efficiency. This guide provides connection details, API usage, and code examples for various programming languages.

Introduction

olmOCR is a specialized Optical Character Recognition system designed by the Allen Institute for AI (AI2). It is optimized for processing high volumes of documents with a focus on speed and efficient resource utilization. olmOCR is particularly effective for large-scale data processing tasks where throughput is a critical requirement.

Key features include:

  • Optimized Throughput: Engineered for fast processing of large document batches.
  • Resource Efficient: High performance with minimal computational overhead.
  • High Consistency: Delivers reliable results across diverse document types.
  • Modern Architecture: Leverages recent advances in vision-language modelling.

properties

PropertyValue
Base URLhttps://kloudihub.com
Endpoint/api/v1/olm-ocr
MethodPOST
Content-Typemultipart/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.

ParameterTypeRequiredDescription
fileFileYesThe image or document file to be processed.

Response Format

The API returns a JSON response containing the extracted text.

{
  "status": "success",
  "data": {
    "text": "Extracted text content...",
    "confidence": 0.94
  }
}

Code Examples

curl -X POST https://kloudihub.com/api/v1/olm-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/olm-ocr', form, {
  headers: {
    ...form.getHeaders(),
    'Authorization': 'Bearer YOUR_API_KEY'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});

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;
  };
}

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/olm-ocr',
      form,
      {
        headers: {
          ...form.getHeaders(),
          'Authorization': 'Bearer YOUR_API_KEY',
        },
      }
    );
    console.log('Raw Text:', data.data.text);
  } catch (error) {
    console.error('OCR Error:', error);
  }
};

uploadFile();

Using the requests library:

import requests

url = "https://kloudihub.com/api/v1/olm-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}")

On this page