Localization API#
The Lingo.dev localization API provides two endpoints: one for translating key-value data through a configured localization engine, and one for detecting the language of arbitrary text.
Authentication#
All API requests require an API key passed in the X-API-Key header.
X-API-Key: your_api_keyAPI keys are scoped to an organization. Each key has access to all localization engines within that organization. Generate keys in the API Keys section of the dashboard.
Key visibility
API keys are shown only once at creation. Store them securely — they cannot be retrieved after the initial display.
Localize#
Translates a set of key-value pairs from one locale to another using a configured localization engine.
Request#
POST /process/localize| Parameter | Type | Description |
|---|---|---|
engineId | string (optional) | The localization engine ID (eng_...). Uses the default engine if omitted. |
sourceLocale | string | BCP-47 source locale (e.g., en) |
targetLocale | string | BCP-47 target locale (e.g., de) |
data | object | Key-value pairs to translate |
{
"engineId": "eng_abc123",
"sourceLocale": "en",
"targetLocale": "de",
"data": {
"greeting": "Hello, world!",
"cta": "Get started"
}
}Response#
Returns the same structure with translated values.
{
"sourceLocale": "en",
"targetLocale": "de",
"data": {
"greeting": "Hallo, Welt!",
"cta": "Jetzt starten"
}
}Examples#
const response = await fetch(
"https://api.lingo.dev/process/localize",
{
method: "POST",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
engineId: "eng_abc123",
sourceLocale: "en",
targetLocale: "de",
data: {
greeting: "Hello, world!",
cta: "Get started",
},
}),
}
);
const { data } = await response.json();
// { greeting: "Hallo, Welt!", cta: "Jetzt starten" }What happens during localization#
When a request hits the localize endpoint, the engine applies its full configuration:
Model selection — Selects the highest-priority LLM model matching the locale pair. Locale-specific models take precedence over wildcard (
*) models. If the primary model fails, the engine falls through to the next ranked model automatically.Brand voice — Loads the brand voice for the target locale (falls back to the wildcard brand voice if no locale-specific one exists).
Instructions — Loads all instructions matching the target locale, including wildcard instructions.
Glossary lookup — Splits input values into searchable chunks, generates embeddings, and performs a vector similarity search against the engine's glossary. Matched terms enforce exact translations or mark terms as non-translatable.
Generation — Sends the composed prompt to the selected model. Parses and validates the JSON response.
Fallback behavior
If the primary model fails, the engine automatically attempts the next model in rank order. This happens transparently — the response includes the same structure regardless of which model produced it.
Recognize#
Detects the language of a given text and returns structured locale metadata.
Request#
POST /process/recognize| Parameter | Type | Description |
|---|---|---|
text | string | The text to analyze |
labelLocale | string (optional) | Locale for the human-readable label (default: en) |
{
"text": "Bonjour le monde",
"labelLocale": "en"
}Response#
{
"locale": "fr",
"language": "fr",
"region": null,
"script": null,
"label": "French",
"direction": "ltr"
}| Field | Type | Description |
|---|---|---|
locale | string | BCP-47 locale code at the most specific level of confidence |
language | string | ISO 639 language subtag |
region | string | null | ISO 3166 region subtag, or null if indistinguishable |
script | string | null | ISO 15924 script subtag, or null if default for the language |
label | string | Human-readable locale name in the requested labelLocale |
direction | "ltr" | "rtl" | Text direction |
Examples#
const response = await fetch(
"https://api.lingo.dev/process/recognize",
{
method: "POST",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
text: "Bonjour le monde",
labelLocale: "en",
}),
}
);
const result = await response.json();
// { locale: "fr", language: "fr", label: "French", direction: "ltr", ... }When regional markers are present in the text (e.g., Brazilian Portuguese vocabulary), the response includes the full tag (pt-BR). When the regional variant is indistinguishable, only the language subtag is returned (pt).