Translate text (SSE)

post
https://connect.patsnap.com/hiro_translation/translate
Try in Sandbox

Translate `content` from source to target language and stream segments over SSE. Choose the strategy with `mode`: `fast` (default) segmented, `stream` sliding-window, `raw` direct model pass-through.

`content` defaults to max 65536 characters (`RD_MAX_TEXT_CHARS`); longer text or `Content-Length` above `RD_MAX_REQUEST_BYTES` (default 262144) returns 413. Invalid languages, identical source/target, missing/extra fields, or invalid `mode` return 400. `X-Openapi-Amount` is set only on the 200 stream, from input `content` when the stream is created.

Request Parameters

List of parameters supported by this API endpoint

NameTypeExampleDescription
content
Required
string本发明涉及一种用于图像识别的装置,包括处理器和存储器。 所述处理器被配置为对输入图像进行分类。
Source text to translate. Must not be blank. Default max 65536 characters.
sourceLanguageCode
Required
objectzh
Source language code.
targetLanguageCode
Required
objecten
Target language code; must differ from source.
mode
stringfast
Translation mode: `fast` (default) segmented, `stream` sliding-window, `raw` direct pass-through. Example: `fast`.

Response Schema

Structure of the API response data

Field NameTypeExampleDescription
_meta
object{ "openapi_billing": { "version": 1, "multiplier": "2" } }
Billing metadata on the SSE JSON body (not an HTTP header).
state
Required
stringsuccess
Execution status
progress
string1/2
Translation progress as ``current/total`` segments (e.g. ``3/10``). `raw` is typically ``1/1``.
textOriginal
Required
string本发明涉及一种用于图像识别的装置,包括处理器和存储器。
Source segment text
textTranslated
Required
stringThe present invention relates to an apparatus for image recognition, comprising a processor and a memory.
Translated segment text
translatedCharacterCount
Required
integer105
Character count of this translated segment

Success Response Example

Example of a successful API response

JSON
{
  "_meta": {
    "openapi_billing": {
      "version": 1,
      "multiplier": "2"
    }
  },
  "state": "success",
  "status": true,
  "progress": "1/2",
  "error_code": 0,
  "textOriginal": "本发明涉及一种用于图像识别的装置,包括处理器和存储器。",
  "textTranslated": "The present invention relates to an apparatus for image recognition, comprising a processor and a memory.",
  "translatedCharacterCount": 105
}

Error Codes

List of possible error codes returned by this endpoint

Business Errors

Error CodeDescription
68300004Invalid parameter!
68300005Search api failure!
68300006Analytic basic access error!
68300007Bad request!
68300008Service error, please try again later!
68300010The file does not comply with upload specifications!

Platform Errors

Error CodeDescription
67200001API call exceeds the total limit set by the platform!
67200002Quota exceeds the limit!
67200003Access token expired or authentication error!
67200004No permission or API package quota has exceeded the limit!
67200005Insufficient balance, call failed!
67200006This client has expired and call failed!
67200007Exceeded the call limit, call failed!

HTTP Status Codes

Status CodeDescription
0Success
400Validation failed before the stream starts. Body is always `{"error":"..."}`; no `TYPE` field and no billing header.
413Payload too large. `content` exceeds `RD_MAX_TEXT_CHARS` (default 65536) or `Content-Length` exceeds `RD_MAX_REQUEST_BYTES` (default 262144). Body is `{"error":"..."}` with no billing header.

Performance Metrics

Expected performance characteristics for this endpoint

Normal Response Time

5000 ms

Max Response Time

10000 ms