Home / API docs / Translate Text API
More

Translate Text API

POST /api/translate-text $0.01 per call USDC on Base · x402

TRANSLATION — POST {text, target} and get the translation plus the detected source language. Any language pair; target as a name or ISO code ('spanish', 'de', 'ja'). Up to 8,000 chars per call; line breaks and markdown preserved; code, URLs, and proper names left alone. Optional {source} to pin the source language, {formality}: formal|informal. Fast cheap LLM under the hood; the x402 payment IS the auth.

Parameters

NameInDescription
textbodyrequiredThe text to translate, up to 8,000 characters
targetbodyrequiredTarget language — name or ISO code ('spanish', 'de', 'ja')
sourcebodyOptional source language; auto-detected when omitted
formalitybodyformal or informal register (optional)

Example request

curl -X POST "https://api.webbersites.com/api/translate-text" \
  -H "Content-Type: application/json" \
  -d '{"text":"The deploy failed because the token expired.","target":"japanese"}'
# first call returns 402 + payment requirements; an x402 client pays and retries automatically

Example response

{
    "translation": "トークンの有効期限が切れたため、デプロイは失敗しました。",
    "target": "japanese",
    "source_language": "English",
    "model": "gemini-2.5-flash-lite"
}
MCP tool: post_translate_text — via npx -y webbersites-x402-mcp (local, key stays on your machine) or the remote endpoint https://api.webbersites.com/mcp.

How payment works

There is no signup and no API key. Call the endpoint; it replies 402 Payment Required with machine-readable payment requirements. Your client signs a USDC transfer authorization (EIP-3009, gasless) and retries with the X-PAYMENT header — @x402/fetch does this automatically. See the overview for a working snippet.