Detect language
POST /ai_agent/checklanguage. Identify the language of text or HTML without translating it.
POST https://api.fluentc.ai/ai_agent/checklanguage
Identifies the language of input and reports how confident the detection is. Use it when you need to know the language before you decide what to do, for example to route a support ticket. If you only want a translation, skip this call: Translate works out the source language when you leave source_language out.
Request
Headers are the same as every endpoint: Authorization with your key and Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The text or HTML to analyse. |
input_format | string | Yes | text or html. json is not accepted. |
curl -X POST https://api.fluentc.ai/ai_agent/checklanguage \
-H "Authorization: $FLUENTC_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Bonjour, comment allez-vous?",
"input_format": "text"
}'
Response
200 OK
{
"detected_language": "fr",
"confidence": 0.99
}
| Field | Type | Description |
|---|---|---|
detected_language | string | The language code, in the same format as target_language. |
confidence | number | From 0 to 1. Higher is more certain. |
Decide in your own code what to do below a confidence threshold you choose, for example to ask a person to check.
Errors
| Status | Message | Fix |
|---|---|---|
422 | Input is missing | Send a non-empty input. |
422 | Invalid or missing input format. Allowed formats: text, html | Set input_format to text or html. |
Key and account errors are covered in Authentication. All error shapes are on Errors.
Something unclear, or missing? Tell us.