Documentation menu

Languages

GET /ai_agent/languages. List the languages enabled for your API key, to validate a language code before you translate or to populate a language picker.

View as Markdown
http
GET https://api.fluentc.ai/ai_agent/languages

Returns the languages your key can use. A language must appear here before it can be a target_language or source_language in Translate.

Request

No body. Send the Authorization header.

bash
curl https://api.fluentc.ai/ai_agent/languages \
  -H "Authorization: $FLUENTC_KEY"

Response

200 OK

json
{
  "supported_languages": [
    { "code": "es", "name": "Spanish" },
    { "code": "fr", "name": "French" },
    { "code": "de", "name": "German" }
  ],
  "source_languages": [
    { "code": "en", "name": "English" }
  ]
}
FieldTypeDescription
supported_languagesarrayLanguages you can translate into.
source_languagesarrayLanguages you can name as source_language.
codestringThe code to send to the API. Lowercase, two or three letters.
namestringThe language's name in English.

Both lists reflect what is enabled for your key, so they can differ from key to key.

Using it

  • Validate before you translate. Fetch the list once at startup and check target_language against it, instead of waiting for a 422.
  • Build a language picker. Show name, send code.
  • Cache it. The list changes only when you change your account's languages.
js
const res = await fetch("https://api.fluentc.ai/ai_agent/languages", {
  headers: { Authorization: process.env.FLUENTC_KEY },
});
const { supported_languages } = await res.json();
const codes = new Set(supported_languages.map((l) => l.code));

if (!codes.has("ja")) throw new Error("Japanese isn't enabled for this key");

Errors

Only key and account errors apply: 401 and 403. See Authentication and Errors.

Something unclear, or missing? Tell us.