---
title: "Detect language"
method: POST
path: "/v1/detect"
tags: ["Directionality"]
---

# Detect language

`POST /v1/detect`

## Request

- Base URL: `https://hc.itsbaba.com`
- URL: `https://hc.itsbaba.com/v1/detect`
- Auth: HTTP bearer

Detect the dominant language, script and base direction of a string, with one segment per language. Built for short, code-switched input such as chat messages, search queries and voice transcripts: 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 ("ה-API") are split correctly. Links and email addresses are ignored. Latin script is tagged `en`.

**Quota.** Deterministic, no model. Does not consume the character quota.

**Limits.** `text` up to 20,000 characters. Idempotent.

## Request body

- DetectRequest
  - `text` string, required: Text to classify, up to 20,000 characters. Built for short, code-switched input.

## Response `200`

Detection

- DetectResponse
  - `lang` string, required: Dominant language (BCP 47). Latin script is tagged `en`.
  - `script` string, required: Dominant ISO 15924 script.
  - `dir` 'ltr' | 'rtl', required: Base direction of the dominant language.
  - `confidence` number, required: Share of letters in the dominant language, 0 to 1.
  - `segments` object[], required: Same-script stretches in order, e.g. ru · en ("CBC") · ru. Latin script is tagged en.
    - `text` string, required
    - `start` integer, required
    - `end` integer, required
    - `script` string, required
    - `lang` string, required
  - `languages` object[], required: Every language found, largest share first.
    - `lang` string, required
    - `share` number, required: Share of letters, 0 to 1.

## Other responses

- `400`: Invalid request: the body failed validation or a value is out of range.
- `401`: Missing, malformed, invalid or revoked API key.
- `402`: A new self-serve account must save a card in the console before it can use the API. Adding a card is free.
- `403`: The connection used TLS older than 1.2.
- `429`: Too many requests this minute. Retry after a short wait.
- `500`: Unexpected server error. Safe to retry.

---

[API](https://skmtc.dev/itsbaba/apis/hebrewcore-api.md) · [All operations](https://skmtc.dev/itsbaba/apis/hebrewcore-api/llms.txt) · [OpenAPI document](https://skmtc.dev/itsbaba/apis/hebrewcore-api/revisions/f54229695236?raw)
