Detect language
detect_languageDetect the dominant language, script and direction of a string, with one segment per language. Built for short, code-switched input (chat messages, search queries, voice transcripts): a brand or acronym such as "PayPal" or "API" inside a Hebrew or Russian sentence does not change the dominant language. Use it to pick source_lang or the reply language before translating. Latin script is tagged en. Deterministic and free: no character quota.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to classify, up to 20,000 characters. Built for short, code-switched input. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dir | No | Base direction of the dominant language. | |
| lang | No | Dominant language (BCP 47). Latin script is tagged `en`. | |
| script | No | Dominant ISO 15924 script. | |
| segments | No | Same-script stretches in order, e.g. ru · en ("CBC") · ru. Latin script is tagged en. | |
| languages | No | Every language found, largest share first. | |
| confidence | No | Share of letters in the dominant language, 0 to 1. |