Language Detection
Endpoint​
POST /language/translate/v2/detect
Detects the language of one or more strings without translating them. Uses the same API key and authentication as the translate endpoint.
Request body​
{
"q": "Bonjour le monde"
}
q (required): a string, or an array of strings, to detect. Max 128 items per request.
Response body​
{
"data": {
"detections": [
[
{
"language": "fr",
"confidence": 0.95,
"isReliable": true
}
]
]
}
}
detectionsis an array with one entry per item inq, in the same order.- Each entry is itself an array (matching the Google Translate v2 detect shape), currently always holding exactly one detected-language result.
language: BCP-47-style language code, or"und"(undetermined) when the text is too short or no confident match is found.confidence: a number between 0 and 1.isReliable:truewhenconfidenceis 0.9 or higher.
How detection works​
Detection uses a lightweight, signature-based classifier: it checks a string's first words against known common-word signatures for a fixed set of languages. It is not a full statistical language model, so it works well on typical sentences but has limits:
- Strings shorter than 20 characters always return
"und"withconfidence: 0andisReliable: false. There is not enough text to classify reliably. - A confident result requires a match score of at least 0.8; below that, the endpoint also returns
"und".
Frequently asked questions​
Do I need to call /detect before translating?​
No. If you omit the source field on a normal POST /language/translate/v2 request, source-language detection happens automatically as part of that same call, and the detected language is returned in detectedSourceLanguage. Use the dedicated /detect endpoint only when you need to know the language of text you are not translating right now.
Why did I get "language": "und"?​
Either the input string was shorter than 20 characters, or the classifier's confidence score for every candidate language was below 0.8. Very short strings, single words, or text mixing multiple languages are the most common causes.
What does isReliable: false mean if a language was still returned?​
The classifier found a best-guess language above the 0.8 confidence threshold needed to return a result at all, but below the 0.9 threshold used for isReliable. Treat these as a reasonable guess, not a certainty, especially for short or ambiguous text.
Does detecting a language count toward my billing?​
No. The /detect endpoint does not record character usage against your monthly allowance the way a translate request does.