TokenLab

Text

Create Translation

Translates text into a target language

POST
/v1/translations

Overview

Use /v1/translations for text-to-text translation.

This endpoint is different from Audio Translation, which accepts an audio file and always outputs English text.

Use the Models API to get current text-translation models:

curl "https://api.tokenlab.sh/v1/models?recommended_for=translation"

Then explicitly send the chosen model to /v1/translations.

recommended_for=translation applies only to text translation (POST /v1/translations). It does not apply to audio translation.

Request Body

modelstringrequired

Translation model ID returned by /v1/models?recommended_for=translation.

textstringrequired

Source text to translate.

target_languagestringrequired

Target language code or language name, depending on model support.

source_languagestring

Optional source language hint.

mime_typestringdefault: text/plain

Source text format. Supported values: text/plain, text/html.

userstring

Optional end-user identifier for abuse monitoring and request tracing.

Response

textstring

Translated text.

modelstring

Model that generated the translation.

source_languagestring | null

Source language detected or accepted by the model.

target_languagestring

Target language used for the request.

Request

curl -X POST "https://api.tokenlab.sh/v1/translations" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seed-translation",
    "text": "你好,欢迎使用 TokenLab。",
    "target_language": "en"
  }'

Response

Response
{
  "text": "Hello, welcome to TokenLab.",
  "model": "doubao-seed-translation",
  "source_language": "zh",
  "target_language": "en"
}

Authorization

BearerAuth
AuthorizationBearer <token>

API Key authentication. Create or manage API keys in Dashboard > API > API Keys.

In: header

Headers

X-TokenLab-Delivery-Policy?string

Per-request Delivery policy. Overrides the API key and Workspace defaults. Auto tries TokenLab Verified first and may switch once to Official only before output, request acceptance, or persistent resource creation.

Value in

  • "auto"
  • "verified"
  • "official"

Request Body

application/json

Response

application/json

application/json

application/json

application/json

application/json

application/json