Documentation menu

Detect language

POST /ai_agent/checklanguage. Identify the language of text or HTML without translating it.

View as Markdown
http
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.

FieldTypeRequiredDescription
inputstringYesThe text or HTML to analyse.
input_formatstringYestext or html. json is not accepted.
bash
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

json
{
  "detected_language": "fr",
  "confidence": 0.99
}
FieldTypeDescription
detected_languagestringThe language code, in the same format as target_language.
confidencenumberFrom 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

StatusMessageFix
422Input is missingSend a non-empty input.
422Invalid or missing input format. Allowed formats: text, htmlSet 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.