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
| Route | Purpose |
|---|---|
GET /health | Service status (no key). |
GET /v1/languages | Supported languages (no key). |
POST /v1/translate | Translates a batch (key required). |
GET /v1/usage | Today's consumption and the limits of your key. |
Languages
| Code | Language |
|---|---|
fr | French |
en | English |
lt | Lithuanian |
de | German |
es | Spanish |
it | Italian |
pt | Portuguese |
nl | Dutch |
pl | Polish |
Limits
- At most 20 items per request, 1,000 characters per item, body limited to 128 KiB;
idandcontext: at most 64 characters. - Calls per minute are capped per key; responses carry
X-RateLimit-Remaining. - Daily budget per key and a global budget, reset at midnight (Europe/Paris).
- 10 rejected keys within 10 minutes from one address: blocked for 10 minutes.
Error codes
Every error has the shape {"code": "...", "detail": "...", "params": {...}}.
The detail text is not a contract: test code.
| Code | HTTP | Meaning |
|---|---|---|
invalid_request | 422 | Malformed request (invalid JSON, missing field, duplicate id). |
unknown_client | 401 | Missing, unknown or revoked key. |
unsupported_language | 422 | Target language not in the list; the list is in params.supported. |
too_many_items | 422 | More than 20 items in the request. |
text_too_long | 422 | A text exceeds 1,000 characters; params.id gives the item. |
rate_limited | 429 | Too many calls per minute for the key, or too many rejected keys from your address; wait params.retry_after seconds (Retry-After header). |
budget_exhausted | 429 | Daily budget of the key or global budget reached; resumes at midnight (Europe/Paris). |
upstream_failed | 502 | The 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).