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.
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.
curl https://api.fluentc.ai/ai_agent/languages \
-H "Authorization: $FLUENTC_KEY"
Response
200 OK
{
"supported_languages": [
{ "code": "es", "name": "Spanish" },
{ "code": "fr", "name": "French" },
{ "code": "de", "name": "German" }
],
"source_languages": [
{ "code": "en", "name": "English" }
]
}
| Field | Type | Description |
|---|---|---|
supported_languages | array | Languages you can translate into. |
source_languages | array | Languages you can name as source_language. |
code | string | The code to send to the API. Lowercase, two or three letters. |
name | string | The 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_languageagainst it, instead of waiting for a422. - Build a language picker. Show
name, sendcode. - Cache it. The list changes only when you change your account's languages.
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.