[AI62-1] PDF Translation - Submit Translation Task

post
https://connect.patsnap.com/pdf-translation/translate
Try in Sandbox

Upload a PDF file using pdf, or supply a PDF download URL using pdf_url, including a signed URL. Provide exactly one. Set output_format=pdf for a layout-preserving translated PDF (default), or output_format=markdown for a Markdown text file (.md). Accepted tasks return HTTP 202. Poll status_url; once state is succeeded, call the result endpoint in download_file to retrieve the translation in the selected format. Request example (file upload, multipart/form-data): ```bash curl -X POST 'http://s-patsnaprd-pdf-translation-api.patsnaprd/translate' \ -H 'accept: application/json' \ -F 'pdf=@/path/to/sample.pdf;type=application/pdf' \ -F 'source_lang=zh' \ -F 'target_lang=en' \ -F 'pages=1' \ -F 'model_id=9' \ -F 'output_format=pdf' ``` Request example (PDF URL, multipart/form-data): ```bash curl -X POST 'http://s-patsnaprd-pdf-translation-api.patsnaprd/translate' \ -H 'accept: application/json' \ -F 'pdf_url=https://storage.example.com/sample.pdf?signature=EXAMPLE' \ -F 'source_lang=zh' \ -F 'target_lang=en' \ -F 'pages=1' \ -F 'model_id=9' \ -F 'output_format=pdf' ``` For Markdown output, set output_format=markdown. Omit pages to translate all pages. Omit pdf when using pdf_url. With -F, curl automatically generates the multipart/form-data Content-Type header with its boundary; no manual Content-Type header is needed. Success response example (HTTP 202): ```json { "task_id": "0123456789abcdef0123456789abcdef", "taskId": "0123456789abcdef0123456789abcdef", "job_id": "0123456789abcdef0123456789abcdef", "state": "pending", "source_lang": "zh", "target_lang": "en", "lang": "zh2en", "model_id": "9", "output_format": "pdf", "total_pages": 2, "selected_pages": [ 1 ], "selected_page_count": 1, "skipped_pages": [ 2 ], "skipped_page_count": 1, "status_url": "http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef", "download_file": "http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef/result", "message": "任务已提交。请轮询 status_url,成功后访问 download_file 获取结果:PDF。" } ``` Request parameters (multipart/form-data): | Parameter | Type | Required | Example | | --- | --- | --- | --- | | pdf | file / string | No; exactly one of pdf / pdf_url | sample.pdf | | pdf_url | string | No; exactly one of pdf_url / pdf | https://storage.example.com/sample.pdf?signature=EXAMPLE | | source_lang | string | No; explicitly supply it | zh | | target_lang | string | No; explicitly supply it | en | | pages | string | No; omitted means all pages | 1 | | model_id | string | No; server default is 9 | 9 | | output_format | string | No; server default is pdf | pdf |

Request Parameters

List of parameters supported by this API endpoint

NameTypeExampleDescription
pdf
filesample.pdf
Input PDF file or HTTP(S) PDF URL, including a signed URL; provide exactly one of pdf and pdf_url. Upload with -F 'pdf=@/path/to/sample.pdf;type=application/pdf', or pass a URL with -F 'pdf=https://storage.example.com/sample.pdf?signature=EXAMPLE'. Swagger 2.0 cannot represent a file/string union for a form field; the file type is retained for file selection. File-size and whole-document page limits depend on the service configuration for output_format; exceeding them returns HTTP 413. default is a documentation-import example only, not a server-side default. Replace filename or signed-URL placeholders before use.
pdf_url
stringhttps://storage.example.com/sample.pdf?signature=EXAMPLE
HTTP(S) download URL of the input PDF. Signed URLs and publicly accessible PDF URLs are supported. The URL must be valid and accessible to the service when it fetches the source file. Provide exactly one of pdf_url or pdf. Example: "https://storage.example.com/sample.pdf?signature=EXAMPLE" default is a documentation-import example only, not a server-side default. Replace filename or signed-URL placeholders before use.
source_lang
stringzh
Source language: zh Chinese, en English, ja Japanese. Example: "zh" The current staging Swagger marks this field optional. Examples explicitly supply both source_lang and target_lang to specify the translation direction. default is a documentation-import example only, not a server-side default. Replace filename or signed-URL placeholders before use.
target_lang
stringen
Target language: zh Chinese, en English, ja Japanese, de German, fr French, ko Korean; must differ from the source. Example: "en" The current staging Swagger marks this field optional. Examples explicitly supply both source_lang and target_lang to specify the translation direction. default is a documentation-import example only, not a server-side default. Replace filename or signed-URL placeholders before use.
pages
string1
Optional one-based page selection, e.g. 3,5,8 or 22-25 or a combination. Omitted, empty or whitespace-only means all pages. Duplicates and overlaps count once. First fully successful result billing uses selected_page_count; unselected pages retained in PDF output are excluded. For a two-page PDF, pages=1 bills 1 page and empty pages bills 2. Example: "1" default is a documentation-import example only, not a server-side default. Replace filename or signed-URL placeholders before use.
model_id
string9
Layout model: 9 fast default mode; 25 higher accuracy. Example: "9"
output_format
stringpdf
Output format: pdf (default) generates a layout-preserving translated PDF; markdown generates a Markdown text file (.md). Both support page selection via pages and metering by unique selected translation pages, using the same asynchronous submission, status polling and result retrieval flow. Pass response_format=url to the result endpoint for a signed URL, or response_format=file to download the file directly. Example: "pdf" Classified Markdown with model_id=25 is translated in chunks of at most 8000 tokens.

Response Schema

Structure of the API response data

Field NameTypeExampleDescription
lang
stringzh2en
Translation direction. Example: "zh2en"
state
Required
stringpending
Task accepted and awaiting processing; the value is pending. Example: "pending"
job_id
string0123456789abcdef0123456789abcdef
Compatibility alias of task_id. Example: "0123456789abcdef0123456789abcdef"
taskId
string0123456789abcdef0123456789abcdef
Compatibility alias of task_id. Example: "0123456789abcdef0123456789abcdef"
message
string任务已提交。请轮询 status_url,成功后访问 download_file 获取结果:PDF。
Current-stage message. Example: "任务已提交。请轮询 status_url,成功后访问 download_file 获取结果:PDF。"
task_id
Required
string0123456789abcdef0123456789abcdef
Task ID. Example: "0123456789abcdef0123456789abcdef"
model_id
Required
string9
Layout model: 9 for fast mode, 25 for higher accuracy. Example: "9"
status_url
Required
string<uri>http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef
Task status endpoint. Example: "http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef"
source_lang
stringzh
Source language. Example: "zh"
target_lang
stringen
Target language, different from the source. Example: "en"
total_pages
Required
integer<int32>2
Total pages in the input PDF, not the selected-page count or the output page count. X-Openapi-Amount equals this value on the first fully successful retrieval only when translating the whole PDF. Example: 2
download_file
Required
string<uri>http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef/result
Result API URL, not the signed PDF or Markdown URL itself. Once the task completes, call it with response_format=url; download_file in that JSON response is the signed PDF or Markdown download URL, valid for one week (7 days, 604800 seconds). Example: "http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef/result"
output_format
Required
stringpdf
Output file format. Example: "pdf"
skipped_pages
array[ 2 ]
Unselected pages; retained unchanged in PDF output. Example: [2]
selected_pages
array[ 1 ]
Selected page numbers, starting at 1. Example: [1]
skipped_page_count
integer1
Number of unselected pages. Example: 1
selected_page_count
integer1
Unique selected-page count used as the first fully successful result billing amount; equals total_pages when pages is empty or omitted. Example: 1

Success Response Example

Example of a successful API response

JSON
{
  "lang": "zh2en",
  "state": "pending",
  "job_id": "0123456789abcdef0123456789abcdef",
  "status": true,
  "taskId": "0123456789abcdef0123456789abcdef",
  "message": "任务已提交。请轮询 status_url,成功后访问 download_file 获取结果:PDF。",
  "task_id": "0123456789abcdef0123456789abcdef",
  "model_id": "9",
  "error_code": 0,
  "status_url": "http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef",
  "source_lang": "zh",
  "target_lang": "en",
  "total_pages": 2,
  "download_file": "http://s-patsnaprd-pdf-translation-api.patsnaprd/tasks/0123456789abcdef0123456789abcdef/result",
  "output_format": "pdf",
  "skipped_pages": [
    2
  ],
  "selected_pages": [
    1
  ],
  "skipped_page_count": 1,
  "selected_page_count": 1
}

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
67200000API call exceeds the total limit set by the platform!
67200001API call exceeds the total limit set by the platform!
67200002The current call rate is too fast, exceeding the current configuration limit QPS!
67200003The key and secret parameters for applying for the token are incorrect or the client has been disabled!
67200004The requested api does not have permission. Please contact our support personnel!
67200005Insufficient account balance/number of calls!
67200006The client has exceeded the activation validity period!
67200007The current call exceeds the configured usage limit of the day!
67200008Please check if the required apikey in the query parameter has been transmitted!
67200009The apikey does not match the passed bearerToken. Please check if a valid token is being used!
67200012The request is illegal!
67200100The current server status is busy, request response timeout!
67200101The API requested currently does not exist. Please check the request path!

HTTP Status Codes

Status CodeDescription
0Success
202Task accepted; submission amount defaults to 1.
400Empty, invalid, damaged or unreadable PDF.
413File exceeds the size or whole-document page limit for output_format.
422Validation failed: input selection, unsupported or identical languages, invalid page selection, etc.
502Remote PDF download failed.
503Service temporarily unavailable; retry later.
504Remote PDF download timed out.