ForHosting KIT · OCR & Data Extraction

Detect a document's language

Sorting an unlabeled inbox of files by language is a small task that quietly blocks a much bigger pipeline, since translation, OCR and review tools all need to know what they're reading before they can do their job. This endpoint reads a document, identifies its language or languages, and returns that as JSON before anything downstream even opens the file.

● StablePer request + per document$0.003
Use it from WebAPIEmailApp soonTelegram soon

Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.

The routing problem nobody notices until it breaks

A support inbox, a legal intake folder, or a scanned-archive project rarely arrives labeled by language; a file just shows up, and every downstream step — which OCR model to run, which translator to queue, which reviewer speaks the language well enough to check it — depends on knowing the answer first. Guessing wrong wastes a processing pass entirely, and doing it by opening every file manually doesn't scale past a few dozen documents.

Who needs to know the language before anything else

Translation agencies triaging an incoming batch of files from a client before quoting or assigning a translator, multinational support teams routing scanned correspondence to the right regional office, digital archives sorting a mixed-language collection before applying language-specific OCR models, and compliance teams flagging documents in a language that requires a specific reviewer's sign-off.

What comes back from the call

Submit the file to POST /ocr/language and receive a task_id immediately, since detection runs as an asynchronous task rather than blocking the request. The result — the detected language or languages, in order of how much of the document each one covers for mixed-language files — arrives by signed webhook or is available at a signed link for 24 hours.

Why mixed-language documents are the real test

A single-language memo is the easy case; the harder and far more common one is a document that switches language mid-page — a contract with an English clause and a Spanish appendix, a form with printed labels in one language and handwritten answers in another, an email thread that drifts between languages as participants reply. Detecting language reliably means reading the whole document rather than sampling the first line, because the first line is exactly where a document is least likely to reveal what's on page four.

Where it sits before everything else

At $0.003 per request plus $0.0135 per document, billed only when detection succeeds, this endpoint is cheap enough to run as the very first step in an intake pipeline, before OCR, before translation, before a document ever reaches a human queue — the detected language becomes the routing key for whatever happens next. A failed detection retries automatically up to three times at no charge, and access requires prepaid balance; there's no free tier, which keeps the endpoint responsive at intake volume.

Translation agency triage

An agency detects the language of every incoming client file before quoting or assigning it to a translator who works in that language.

Multinational support routing

A support team routes scanned correspondence to the regional office that handles its detected language instead of guessing from the sender's address.

Mixed-language archive sorting

A digitization project sorts a collection of unlabeled scanned documents by detected language before applying the correct OCR model to each group.

Compliance review assignment

A compliance team flags documents written in a language that requires sign-off from a specific reviewer before further processing.

What does the Document Language Detection API return?

The detected language or languages of the document as JSON, ordered by how much of the document each language covers when more than one is present.

How do I call the document language detection api?

Send the file to POST /ocr/language, get a task_id right away, and receive the detected language by webhook or a signed link once the async task completes.

Can it detect more than one language in the same document?

Yes, it reads the full document and returns every language it finds, ordered by how much of the content each one accounts for.

Is there a free tier for language detection?

There's no free tier — free tiers get abused and slow everyone down. Access runs on a prepaid ForHosting KIT balance: top up from $10.00 (it never expires) and each request is charged at its published price, so a call with no balance returns HTTP 402. No subscription, no tokens, no invented credits, and a failed task is never charged.

How much does it cost to detect a document's language?

$0.003 per request plus $0.0135 per document, published pricing billed only when detection succeeds.

Does it work on scanned or handwritten documents, not just typed text?

Yes, it reads scanned and handwritten pages as well as native digital text before identifying the language.

Am I charged if detection fails?

No. A failed task retries automatically up to three times and is never billed; you receive a clear error instead.

How is this different from just checking the file's metadata or locale?

Metadata and file locale often don't match the actual content language; this endpoint reads the text itself rather than trusting file properties.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/ocr/language

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.

curl -X POST https://api.kit.forhosting.com/ocr/language \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"…"}'
{
  "input": "…"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "ocr.language",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.003
Per document$0.0135

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb25
max_pages10
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.
422task_failedThe task failed after 3 retries. You are never charged for it.

Read the full KIT documentation →