# 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.

Source: https://www.fluentc.ai/docs/api/languages/

```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](https://www.fluentc.ai/docs/api/translate.md).

## 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" }
  ]
}
```

| 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_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](https://www.fluentc.ai/docs/authentication.md) and [Errors](https://www.fluentc.ai/docs/api/errors.md).
