Overview
Enable Local API in PrivyTranslate Settings. The service then listens on the loopback interface only — it is not reachable from another machine, and no request is proxied anywhere.
http://127.0.0.1:49321/v1v1macOSapplication/jsonAuthentication
Settings displays an API token once the Local API is enabled. Every
endpoint except /health and /capabilities
requires it. Three transports are accepted:
X-Privy-Tokenheader — the primary form for HTTP requests.Authorization: Bearer— accepted by both HTTP requests and the WebSocket handshake.?token=or?access_token=— query parameters for browser WebSocket clients, which cannot set headers.
Treat the token like any other credential: it grants translation on your machine to whatever holds it.
Endpoints
Translate
POST /translate takes a batch of up to 128 strings and returns
one result per item, in order. source defaults to
auto; target is required.
Request
curl -s http://127.0.0.1:49321/v1/translate \
-H "X-Privy-Token: $PRIVY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"source": "auto",
"target": "zh-Hans",
"texts": ["Could you confirm the revised delivery schedule?"],
"mode": "paragraph",
"format": "text",
"options": { "engine": "auto", "sensitive": true }
}' mode accepts selection, paragraph,
webpage, subtitle, message or
document. format accepts text,
html or markdown. Under options,
engine pins a specific backend
(local-llm, ollama, lm-studio,
openai-compatible) and sensitive: true keeps the
request out of translation history.
Response
{
"id": "tr_8F2A6D4E-5F58-4A37-8E92-7B4FD40BE2D2",
"object": "translation",
"created": 1755561600,
"engine": "local-llm",
"model": "translategemma-4b-it.Q4_K_M.gguf",
"source": "en",
"target": "zh-Hans",
"results": [
{
"index": 0,
"text": "能否确认修订后的交付时间表?",
"detected_source": "en",
"confidence": 0.98,
"alternatives": []
}
],
"usage": { "input_chars": 48, "output_chars": 15, "latency_ms": 412 }
} Detect
POST /detect returns a language code and a confidence score
between 0 and 1 for each item, without translating it.
curl -s http://127.0.0.1:49321/v1/detect \
-H "Authorization: Bearer $PRIVY_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "texts": ["Guten Morgen", "早上好"] }' {
"id": "det_8F2A6D4E-5F58-4A37-8E92-7B4FD40BE2D2",
"object": "language_detection",
"created": 1755561600,
"results": [
{ "index": 0, "language": "de", "confidence": 0.97 },
{ "index": 1, "language": "zh-Hans", "confidence": 0.99 }
],
"usage": { "input_chars": 16, "latency_ms": 24 }
} WebSocket
GET /ws/translate upgrades to a WebSocket. Each frame you send
is a TranslateRequest; each frame you receive is either a
TranslateResponse or an ErrorResponse. Use it
when you are translating a stream of short items and want to avoid
per-request overhead.
const socket = new WebSocket(
"ws://127.0.0.1:49321/v1/ws/translate?token=" + PRIVY_TOKEN
);
socket.addEventListener("open", () => {
socket.send(JSON.stringify({
target: "ja",
texts: ["The quarterly invoice is attached."]
}));
});
socket.addEventListener("message", (event) => {
const frame = JSON.parse(event.data);
if (frame.error) console.error(frame.error.message);
else console.log(frame.results[0].text);
}); Limits and languages
GET /capabilities reports the live values; these are the
defaults.
128800050000Language codes
Target languages use BCP 47 codes. source additionally accepts auto.
enEnglishzh-Hans简体中文zh-Hant繁體中文ja日本語ko한국어frFrançaisdeDeutschesEspañolviTiếng ViệtthไทยidBahasa IndonesiamsBahasa MelayufilFilipinomyမြန်မာkmខ្មែរloລາວ
Errors
Failures return a single error object with a stable type.
invalid_request_error 400, 413, 422 Malformed body, unknown field, or a batch over the limits. authentication_error 401, 403 Missing, wrong or revoked API token. server_error 500, 503 Translation pipeline failed, or the app is not ready yet. {
"error": {
"code": "batch_too_large",
"message": "texts exceeds max_items (128)",
"type": "invalid_request_error",
"param": "texts"
}
}