---
title: "Predict the language of a text"
method: POST
path: "/predict/lang"
tags: ["Predict"]
---

# Predict the language of a text

`POST /predict/lang`

Predict the language of a text using a neural model.
Use this POST version for long texts, as the GET version has a limit on the length
of the text that can be provided in the query string.

## Request body

- object
  - `text` string, required — The text to predict language of
  - `k` integer — The number of predictions to return
  - `threshold` number — The minimum probability for a language to be returned

## Response `200`

the predicted languages

- object
  - `predictions` object[] — a list of predicted languages, sorted by descending probability
    - `lang` string — the predicted language (2-letter code)
    - `confidence` number — the probability of the predicted language

## Other responses

- `400` — An HTTP 400 is returned if the provided parameters are invalid

---

[API](https://skmtc.net/openfoodfacts/apis/api-reference.md) · [All operations](https://skmtc.net/openfoodfacts/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openfoodfacts/api-reference/versions/23d26c6d55e6/schema)
