Translator

Translate text into a target language. $0.02 per request.

What it does

Send text and a target language, get back the translation with the source language auto-detected.

Endpoint

MethodPOST
Path/translate
Content-Typeapplication/json

Fields

fieldrequireddescription
textyesThe text to translate, max 20,000 characters
target_languageyesTarget language name or ISO code, e.g. "es" or "Spanish"

Example

curl -X POST https://translator.pdfextractapi.workers.dev/translate \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, how are you today?", "target_language": "es"}'

Example response

{ "translated_text": "Hola, ¿cómo estás hoy?", "source_language": "en", "target_language": "es" }

Errors

Errors return a non-200 status with { "error": { "code": "...", "message": "..." } }. Common codes: missing_text, text_too_large, missing_target_language.

Payment

This endpoint is paid per-request via the x402 protocol (HTTP 402 + USDC). Unpaid requests receive a 402 response with payment instructions.

Try it in your browser