How to detect the language of a text with an API
POST text to /v1/text/language. It returns the most likely language with its ISO 639-1 and 639-3 codes and a confidence, three alternatives, and a reliable flag.
Request
text is up to 20,000 characters. Detection runs offline on an ensemble of two open-source detectors over 75 languages.
curl -s -X POST https://tanod.dev/v1/text/language \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"text": "Bonjour, je voudrais réserver une table pour deux personnes ce soir."}'Response
{
"language": {
"code": "fr",
"iso639_3": "fra",
"name": "French",
"confidence": 1.0
},
"alternatives": [
{
"code": "en",
"iso639_3": "eng",
"name": "English",
"confidence": 0.0
},
{
"code": "cy",
"iso639_3": "cym",
"name": "Welsh",
"confidence": 0.0
}
],
"reliable": true,
"letters": 56,
"chars_analyzed": 68,
"languages_supported": 75,
"note": "confidence is the mean of two detectors' scores; below 0.6, or u…",
"source": {
"library": "lingua-language-detector 2.1.1 (low-accuracy mode) + langid.py 1…",
"license": "Apache-2.0 / BSD-2-Clause",
"url": "https://github.com/pemistahl/lingua-py ; https://github.com/saff…"
}
}Limits and caveats
Heuristic. Language detection is statistical. reliable is true only with at least 20 letters and a confidence of 0.6 or more; short strings, names, code and mixed-language text are often unreliable. Check the flag before you act on the code.
Related languages. Close pairs such as Spanish and Portuguese, or Norwegian and Danish, are the most likely to be confused. Only the 75 supported languages can be returned.
Text with no letters is a 422 no_text and is not charged. The first call on the worker can take a few seconds. Privacy. Tanod does not log or store the submitted text; it is processed in memory for the answer.
Price and free allowance
USD 0.001 per call, paid in USDC on Base with x402. 10 free calls per IP per UTC day with the header X-Tanod-Free: 1. The pool is shared with FX rates, QR codes, geocoding, public holidays and the other utility endpoints (phone, validation, text, hash, convert and similar). MCP tool: detect_language at https://tanod.dev/mcp, where the free tier is automatic.
Related guides: How to count words and score readability of a text with an API, How to compare two texts and get a diff with an API, How to OCR an image from a URL. Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.