baba

Hebrew language detection API for code-switched text

Israelis type Hebrew with English brand names, acronyms and prefixes glued on with a hyphen. A detector built for long documents calls that English. baba HebrewCore reads it as Hebrew with English segments.

The short answer

baba HebrewCore, the Hebrew API from baba, detects the language of short code-switched text with POST /v1/detect: it returns the dominant language, script, direction and confidence, plus a segment for each language with offsets, and a brand like PayPal or a prefix like ה-API inside a Hebrew sentence does not flip the result. It runs with no model and is not counted against the quota.

  • Built for chat messages, search queries and voice transcripts.
  • Free to call on every plan.

Detect with Curl

Request

curl https://hc.itsbaba.com/v1/detect \
  -H "Authorization: Bearer hc_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Можно оплатить через PayPal сегодня?" }'

Response

{
  "lang": "ru", "script": "Cyrl", "dir": "ltr", "confidence": 0.941,
  "segments": [
    { "text": "Можно оплатить через ", "start": 0, "end": 21, "script": "Cyrl", "lang": "ru" },
    { "text": "PayPal ", "start": 21, "end": 28, "script": "Latn", "lang": "en" },
    { "text": "сегодня?", "start": 28, "end": 36, "script": "Cyrl", "lang": "ru" }
  ],
  "languages": [ { "lang": "ru", "share": 0.941 }, { "lang": "en", "share": 0.059 } ]
}

Why Code-Switched Hebrew Is Hard to Detect

Everyday Hebrew is full of English: product names, app names, acronyms and tech words, often attached to a Hebrew prefix with a hyphen (ה-API, ב-Gmail). A short message may carry more Latin letters than Hebrew ones and still be a Hebrew sentence. HebrewCore's detector is built for that shape of text, and the per-language segments tell you exactly which part is which.

The same applies to Russian, the third language HebrewCore covers for protected translation, which is why the example above is a Russian question with a brand in the middle.

What to Call Next

About baba HebrewCore

baba HebrewCore is the Hebrew API from baba, the engine the baba Hebrew translator app runs on. detect_language is also a tool on its MCP server, so an agent can check the language of a user message before it replies. See the best Hebrew API comparison.

Frequently Asked Questions

Is there a language detection API that handles Hebrew mixed with English?

Yes. baba HebrewCore has POST /v1/detect, built for short, code-switched input such as chat messages, search queries and voice transcripts. It returns the dominant language, script and base direction, a confidence, a segment per language with offsets, and each language’s share of the text.

Does a brand name in a Hebrew sentence change the detected language?

No. A brand, product name or acronym inside a Hebrew or Russian sentence (PayPal, iPhone, API) does not change the dominant language, and Hebrew prefixes joined by a hyphen, such as ה-API, are split correctly. Links and email addresses are ignored.

Which languages does /v1/detect tag?

Each segment carries an ISO-15924 script (such as Hebr, Latn or Cyrl) and a language; Latin script is tagged en. GET /v1/languages lists the languages HebrewCore supports, with display names and direction.

Does language detection count against the quota?

No. Detection, like direction analysis, wrap and strip nikud, is deterministic, runs with no language model, and is not counted against the monthly character quota on any plan.

How do I route a message by language?

Call /v1/detect, read lang and confidence, and route on those: reply in Hebrew when lang is he, or pass the text to /v1/translate with source_lang set. The segments array lets you keep an English product name untouched while translating the Hebrew around it.

Try baba HebrewCore free

Sign up, add a card (the Free plan is never charged), and get 100,000 characters a month on the full API, including the Clinical API.

Sign up free

Related Developer Guides