Français

Translation API

An HTTP API that translates batches of short texts (chat messages, labels) into nine languages. It stores neither the submitted texts nor the translations. Versioned contract: /v1 (an incompatible change will become /v2). Interactive documentation: /docs.

Getting a key

Keys are issued on request to the service administrator. Each application gets its own key, with its own per-minute call limit and daily budget. The key is shown only once, when it is created. Send it in the X-API-Key header and never put it in a web page: call the API from your server.

Examples

curl -s https://translate.pixalio.app/v1/translate \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"target": "fr", "items": [{"id": "1", "text": "Hello everyone"}]}'
import requests

r = requests.post(
    "https://translate.pixalio.app/v1/translate",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"target": "fr", "items": [{"id": "1", "text": "Hello everyone"}]},
    timeout=30,
)
r.raise_for_status()
for item in r.json()["items"]:
    print(item["id"], item["text"])

Response: {"target": "fr", "items": [{"id": "1", "text": "...", "skipped": false, "same_language": false}], "model": "..."}. An item the model did not return is absent from the response. skipped: text without any letter (empty, emojis, digits, punctuation), copied back without calling the model; a link contains letters: it is sent to the model, which is told to leave it unchanged; same_language: text already in the target language.

Routes

RoutePurpose
GET /healthService status (no key).
GET /v1/languagesSupported languages (no key).
POST /v1/translateTranslates a batch (key required).
GET /v1/usageToday's consumption and the limits of your key.

Languages

CodeLanguage
frFrench
enEnglish
ltLithuanian
deGerman
esSpanish
itItalian
ptPortuguese
nlDutch
plPolish

Limits

Error codes

Every error has the shape {"code": "...", "detail": "...", "params": {...}}. The detail text is not a contract: test code.

CodeHTTPMeaning
invalid_request422Malformed request (invalid JSON, missing field, duplicate id).
unknown_client401Missing, unknown or revoked key.
unsupported_language422Target language not in the list; the list is in params.supported.
too_many_items422More than 20 items in the request.
text_too_long422A text exceeds 1,000 characters; params.id gives the item.
rate_limited429Too many calls per minute for the key, or too many rejected keys from your address; wait params.retry_after seconds (Retry-After header).
budget_exhausted429Daily budget of the key or global budget reached; resumes at midnight (Europe/Paris).
upstream_failed502The upstream translation service did not answer, answered too slowly, or gave no usable translation; retry later. The call is counted against the key's budget as soon as the request was sent to the model (the provider may have charged it); it is not if the request was never sent.

Besides these eight codes, three generic HTTP codes exist (internal_error: unexpected service error, without detail): not_found (404), method_not_allowed (405), internal_error (500).