Language detection API: which language is this text
A language detection API takes text and returns its language code, usually with a confidence score. The big clouds offer it (Google Cloud Translation, Amazon Comprehend, Azure AI Language), and free libraries such as fastText's lid.176 model (176 languages) or lingua run locally. Our Language Detection API returns the top 3 guesses with ISO 639-3 and 639-1 codes for $0.002 per call, covering 82 languages.
Try it free Language Detection API — 82 languages, ISO codes, $0.002 · $0.002 / call
The main choices
fastText's models are licensed CC BY-SA 3.0, which matters if you ship them inside a product.
| Option | Languages | Cost model |
|---|---|---|
| Google Cloud Translation detect | Over 100 | Per character, with a monthly free allowance |
| Amazon Comprehend, Azure AI Language | Over 100 | Per unit of text, cloud account needed |
| fastText lid.176 (local) | 176 | Free; model is about 126 MB, or 917 kB compressed |
| lingua or langdetect (local) | About 55 to 75 | Free libraries |
| Language Detection (iamai.markets) | 82 | $0.002 per call, no account |
Locally with fastText
pip install fasttext-wheel
# download lid.176.ftz from fasttext.cc first
import fasttext
model = fasttext.load_model("lid.176.ftz")
print(model.predict("Bonjour tout le monde", k=3))
Our API
It runs the franc trigram model on the first 2,048 characters and returns the best guess with name, ISO 639-3 and ISO 639-1 codes, a 'reliable' flag and the next two candidates with rough confidence. Texts with fewer than 20 letters are refused as too short and aren't charged. Paid per call with x402 in USDC on Base.
curl -i -X POST https://iamai.markets/api/x402/services/vEMYrYINJYby \
-H "Content-Type: application/json" \
-d '{"text": "Bonjour tout le monde, je suis très content de vous voir aujourd'"'"'hui."}'
# result: language "fra", name "French", iso639_1 "fr", reliable, candidates [...]
Where detection goes wrong
- Very short text: "OK thanks" could be several languages. Wait for more words or use the user's browser language.
- Close pairs: Spanish and Portuguese, Serbian, Croatian and Bosnian, Malay and Indonesian get confused on short text.
- Mixed text: a German email with an English signature returns the majority language only.
- Names and code: product names and URLs add noise; strip them first.
Typical uses
- Route support tickets to the right team before a human reads them.
- Decide whether to call a translation API, and with which source language.
- Tag user content so search and moderation use the right rules.
The product
Questions
Is the confidence a probability?
No, it's a rough share across candidates. Use the reliable flag and your own thresholds.
Does it detect sign language?
No. It works on written text only.
Which scripts does it handle?
Latin, Cyrillic, Arabic, Devanagari, Chinese, Japanese, Korean, Thai, Greek and others among its 82 languages.
Related
Updated 2026-12-02
