Skip to content

Instant translation

POST /api/v1/ai/translate-snippet
{
"text": "Hello world",
"source_lang": "auto",
"target_lang": "zh",
"engine": "xr-397b"
}

text is 1–5000 characters. target_lang and source_lang (other than auto) must be supported language codes, otherwise 422. Response:

{ "translated_text": "你好,世界", "source_lang": "auto", "target_lang": "zh" }
POST /api/v1/ai/translate-batch
{
"segments": [
{ "id": "p1", "text": "First paragraph." },
{ "id": "p2", "text": "Second paragraph." }
],
"target_lang": "zh"
}
  • segments holds 1–64 segments of at most 4000 characters each; each id is unique within the request (1–64 characters). Too many segments or a segment that is too long returns 413.
  • The response returns segments: [{ "id", "translated_text" }] in request order.
  • Segments that contain only whitespace are returned as they are and not charged.
  • The request body is limited to 2 MB and a request runs for at most 180 seconds; set client timeouts to at least 180 seconds.
  • Send an Idempotency-Key. After a network drop or timeout, retry with the same key and the same body; you are not charged twice.
  • An unavailable engine returns 400; if the key has allowed settings that do not include the chosen one, 403.
  • Billed by the amount of source text actually processed.
POST /api/v1/ai/ocr

Upload the image in the file field of multipart/form-data (PNG, JPEG, WebP, BMP, GIF, up to 12 MB and 25 million pixels), or send the image as the request body. The response gives the text line by line with pixel coordinates:

{
"width": 640,
"height": 240,
"engine": "omnidoc-ocr",
"blocks": [
{ "text": "编号 INV-20261029-0042", "confidence": 0.97, "x": 23, "y": 76, "w": 366, "h": 33 }
]
}
  • x and y are the top-left corner of the text line, in the coordinates of the uploaded image (a JPEG with orientation data is read upright).
  • One box per line; confidence is the recognition confidence of that line (0–1). If no text is found, the response is 200 with empty blocks.
  • Image text recognition costs no credits. Images narrower or shorter than 11 pixels return an empty result.
  • If recognition is temporarily unavailable the response is 503, on timeout 504, with a Chinese explanation in detail; try again later.
  • The web translation extension’s sign-in (omnidoc.translate.use), API keys and browser sign-in can all call it.
  • The query parameters engine, scene and lang are kept for older extension versions and do not affect the result.
  • To get translated images directly, upload the image and create a translation job.

POST /api/v1/ai/notes, /ai/chat and /ai/generate are retired and return 410.