本文へスキップ

クイックスタート

OpenOCRを5分で始める。

1. APIキーを取得する

open-ocr.com/signupで無料アカウントにサインアップします。新規アカウントには開始用のクレジットが含まれます。その後、ダッシュボードからAPIキーを発行してください。

アカウントとAPIキーの作成には人間による操作(CAPTCHA)が必要です。AIエージェントは、ユーザーにsk-ocr-キーを依頼してください。

エンジンの選び方

  • 一般的な文書、スキャン、表:mistral-mistral-ocr-4-1。推奨のデフォルトエンジンで、複数ページのPDFをネイティブに処理します。
  • 許容できる品質で最も安価:google-gemini-3.1-flash-lite。
  • Mistral OCR 4.1はスペルを正規化する場合があります(たとえば明らかな誤字を修正します)。厳密に原文どおりの書き起こしが必要な場合は、LLMビジョンエンジンが当社の逐語指示に従います。
  • すべてのエンジンはランキングページで比較できます。

2. 最初のリクエストを送信する

APIキーと画像URLを使って、OCRエンドポイントにPOSTリクエストを送信します。重複処理を防ぐため、すべてのリクエストにIdempotency-Keyヘッダーが必要です:

bash
curl -X POST https://api.open-ocr.com/v1/ocr \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "engine": "mistral-mistral-ocr-4-1",
    "input": {
      "type": "url",
      "url": "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png"
    }
  }'

3. レスポンスを確認する

json
{
  "request_id": "req_abc123",
  "status": "succeeded",
  "engine": "mistral-mistral-ocr-4-1",
  "extracted_text": "INVOICE #12345\nDate: January 15, 2024\n...",
  "extracted_text_preview": "INVOICE #12345...",
  "cost_debited": 0.004,
  "remaining_balance": 0.996,
  "provider_latency_ms": 280
}

1ページあたりの料金は選択するエンジンによって異なります。最新の料金は料金ページをご覧ください。remaining_balanceフィールドには更新後のクレジット残高が表示されます。

4. base64入力を使用する

画像はbase64エンコードされたデータとして送信することもできます。ファイルがメモリ上にある場合に便利です:

bash
# Encode a local file and send it
BASE64=$(base64 -w0 receipt.png)

curl -X POST https://api.open-ocr.com/v1/ocr \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "engine": "mistral-mistral-ocr-4-1",
    "input": {
      "type": "base64",
      "data_base64": "'$BASE64'",
      "mime_type": "image/png"
    }
  }'

5. どの言語からでも呼び出せる

OpenOCRはシンプルなREST + JSON APIです。SDKのインストールは不要で、お使いのHTTPクライアントをそのまま利用できます。

python
import uuid
import requests

resp = requests.post(
    "https://api.open-ocr.com/v1/ocr",
    headers={
        "Authorization": "Bearer sk-ocr-your-api-key",
        "Content-Type": "application/json",
        "Idempotency-Key": str(uuid.uuid4()),  # new UUID per logical request
    },
    json={
        "engine": "mistral-mistral-ocr-4-1",
        "input": {"type": "url", "url": "https://example.com/receipt.png"},
    },
)
resp.raise_for_status()  # an error envelope has no "status" field
result = resp.json()
if result["status"] != "succeeded":
    raise RuntimeError(f"OCR ended as {result['status']}: {result.get('provider_error')}")
print(result["extracted_text"])
typescript
const resp = await fetch("https://api.open-ocr.com/v1/ocr", {
  method: "POST",
  headers: {
    Authorization: "Bearer sk-ocr-your-api-key",
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(), // new UUID per logical request
  },
  body: JSON.stringify({
    engine: "mistral-mistral-ocr-4-1",
    input: { type: "url", url: "https://example.com/receipt.png" },
  }),
});
const result = await resp.json();
if (result.status !== "succeeded") throw new Error("OCR ended as " + (result.status ?? result.error?.code)); // error envelopes have no status
console.log(result.extracted_text);

6. 利用履歴を照会する(/api/usage)

ダッシュボード形式の利用履歴(ページネーションと日付フィルター付き)を取得するにはGET /api/usageを使用してください。Authorizationヘッダーによる認証を使用してください。 クエリパラメータとしてapi_keyを渡す方法は非推奨のフォールバックとしてのみサポートされています。

bash
# Preferred — the API key alone identifies the caller
curl "https://open-ocr.com/api/usage?page=1&per_page=50"   -H "Authorization: Bearer sk-ocr-your-api-key"

# Deprecated fallback (migration only; avoid in new clients)
# curl "https://open-ocr.com/api/usage?api_key=sk-ocr-your-api-key"

移行に関する注意:URL、ログ、アナリティクスのリファラー、ブラウザ履歴でAPIキーが漏えいするのを防ぐため、既存のクライアントはクエリ認証からヘッダー認証に移行してください。

7. エンジンを探す

OpenOCRは複数のOCRエンジンを提供しており、それぞれ異なるユースケースに最適化されています。最適なエンジンを見つけるには、エンジンカタログをご覧いただくか、比較ツールをお読みください。

bash
# List available engines
curl https://api.open-ocr.com/v1/engines \
  -H "Authorization: Bearer YOUR_API_KEY"

# Quick guide:
# mistral-mistral-ocr-4-1       — Recommended default: general documents, scans, tables
# google-gemini-3.1-flash-lite  — Cheapest acceptable quality
# local-tesseract               — OpenOCR-hosted, clean printed text
# local-easyocr                 — OpenOCR-hosted, multi-language
# local-doctr                   — OpenOCR-hosted, complex layouts
# openocr-ocrmypdf              — OpenOCR-hosted, scanned PDFs with auto-deskew
# openocr-rapidocr              — OpenOCR-hosted, lightweight

8. レート制限

認証済みの POST OCR レスポンスにはレート制限に関するヘッダーが含まれます(結果のポーリングや GET /v1/engines には含まれません):

text
X-RateLimit-Limit: 300       # requests per sliding 60 seconds, per API key
X-RateLimit-Remaining: 299  # requests left in the window
X-RateLimit-Reset: 60       # the window length; on a 429, seconds until a slot frees

デフォルトの上限はAPIキーごとに毎分300リクエストです。上限に達すると429レスポンスが返されます。