Instant translation
Short text translation
Section titled “Short text 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" }Batch segment translation
Section titled “Batch segment translation”POST /api/v1/ai/translate-batch{ "segments": [ { "id": "p1", "text": "First paragraph." }, { "id": "p2", "text": "Second paragraph." } ], "target_lang": "zh"}segmentsholds 1–64 segments of at most 4000 characters each; eachidis unique within the request (1–64 characters). Too many segments or a segment that is too long returns413.- The response returns
segments: [{ "id", "translated_text" }]in request order. - Segments that contain only whitespace are returned as they are and not charged.
Conventions
Section titled “Conventions”- 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
enginereturns400; if the key has allowed settings that do not include the chosen one,403. - Billed by the amount of source text actually processed.
Image text recognition
Section titled “Image text recognition”POST /api/v1/ai/ocrUpload 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 } ]}xandyare 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;
confidenceis the recognition confidence of that line (0–1). If no text is found, the response is200with emptyblocks. - 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 timeout504, with a Chinese explanation indetail; 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,sceneandlangare kept for older extension versions and do not affect the result. - To get translated images directly, upload the image and create a translation job.
Retired endpoints
Section titled “Retired endpoints”POST /api/v1/ai/notes, /ai/chat and /ai/generate are retired and return 410.