# OCR-AI Arabic API

Read Arabic documents and transcribe Arabic speech from your code or your AI agent. The same engine as https://ocr-ai.com/ar/, over REST or MCP.
Human docs (Arabic): https://ocr-ai.com/ar/developers · OpenAPI 3.1: https://ocr-ai.com/ar/openapi.json

## Authentication

Every call sends an API key: `Authorization: Bearer ocrar_sk_...`. Keys are created on https://ocr-ai.com/ar/account after signing in with an email link. An account's first key comes with 50 free units, once.

## Units

One unit reads one page, or transcribes one started minute of audio. A page that fails, or a recording with no speech, is not charged. Packs: `p100` 100 units ($9), `p500` 500 units ($29), `p2000` 2000 units ($89), valid 365 days from the last purchase.

## POST /ar/api/v1/read

A PDF or an image (JPEG, PNG, WebP) up to 20 MB in, its pages as text, fields and tables out. Up to 20 pages per call; read longer PDFs in ranges with `pages` and follow `next_pages`.

Send it as multipart (`file`), as JSON (`file_base64` or `file_url`), or as the raw file with its Content-Type.

| Field | Type | Meaning |
|---|---|---|
| file / file_base64 / file_url | file, string | The document. |
| pages | string | PDF pages, for example `"1-5,8"`. Default: from page 1 up to the per-call limit. |
| hint | string | `auto`, `invoice`, `receipt`, `card`, `table`, `text`, `handwriting`. Default `auto`. |

```bash
curl https://ocr-ai.com/ar/api/v1/read \
  -H "Authorization: Bearer ocrar_sk_..." \
  -F "file=@invoice.pdf" -F "hint=invoice"
```

The answer: `{object: "document", total_pages, pages_read, pages_charged, balance, next_pages, buy_url?, pages: [...]}`. A page read is `{page, status: "done", partial, document_type, language, summary, fields: [{key, label, value, normalized?, type, uncertain?}], tables: [{title?, columns, rows}], text}`; a page that failed is `{page, status: "failed", error, refunded}`; a page the balance did not cover is `{page, status: "no_pages"}`. Values keep Arabic-Indic digits as written; `normalized` holds the value for computation (`1250.00`, `2026-11-07`). In `text`, `value`, table cells and transcript segments, a word the engine was unsure of is written between ⟦ and ⟧ with its best reading inside, and ⟦…⟧ is a word it could not read: show them to your user for review, and strip the brackets for display. The marks are a hint, not a guarantee: a misread digit is often not marked, so compare identifiers (tax and invoice numbers) and amounts with the original wherever they matter.

## POST /ar/api/v1/transcribe

A recording in, its transcript out: 16-bit PCM WAV or Ogg Opus (a WhatsApp voice note), up to 10 minutes per call. Units for the whole recording are taken before the answer starts and given back if it fails. A silent or near-silent WAV is recognized before reading and is not charged. An Ogg Opus file cannot be measured on the server, so one that holds only silence or room noise is read like any other: the engine may write words for it, and they are charged. Send Ogg Opus only when it holds speech (the website checks this itself before it uploads).

| Field | Type | Meaning |
|---|---|---|
| file / file_base64 / file_url | file, string | The recording. |
| task | string | `transcript` (default), `summary` (also a summary and action items) or `order` (also each item ordered, with quantity and details). |

The answer: `{object: "transcript", status, partial, seconds, units_charged, balance, language, dialect, summary, segments: [{start, speaker?, text}], requests: [{item, quantity, details}], action_items}`. The dialect is one of `msa`, `gulf`, `egyptian`, `levantine`, `iraqi`, `maghrebi`, `sudanese`, `yemeni`, `mixed`, `other`; speech is written as spoken, never translated.

## GET /ar/api/v1/balance

`{object: "balance", balance, expired, key, buy_url, packs}`. `buy_url` is a page the key's owner opens to add units; nothing is charged by calling the API.

## MCP

Server: `https://ocr-ai.com/ar/mcp` (Streamable HTTP, stateless JSON responses). Send the same Bearer key.

Tools: `read_document` (same arguments as /read), `transcribe_audio` (same as /transcribe), `check_balance`, `buy_units` (returns a checkout link for the user to open; it never charges by itself).

```json
{ "mcpServers": { "ocr-ai-ar": { "url": "https://ocr-ai.com/ar/mcp", "headers": { "Authorization": "Bearer ocrar_sk_..." } } } }
```

## Errors

Every error is `{error, message}`: `error` is a stable code, `message` a sentence an agent can relay. 401 `unauthorized`, 402 out of units (with `buy_url`), 400 `bad_pages` / `missing_file`, 413 `too_large`, 415 `unsupported_type`, 429 `rate_limited`.

## Privacy

Files and extracted text are not stored. The service keeps an operations log without content (time, units, outcome). Documents are never used to train models.
