Text
Create Translation
Translates text into a target language
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
Translation model ID returned by /v1/models?recommended_for=translation.
Source text to translate.
Target language code or language name, depending on model support.
Optional source language hint.
text/plainSource text format. Supported values: text/plain, text/html.
Optional end-user identifier for abuse monitoring and request tracing.
Response
Translated text.
Model that generated the translation.
Source language detected or accepted by the model.
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
{
"text": "Hello, welcome to TokenLab.",
"model": "doubao-seed-translation",
"source_language": "zh",
"target_language": "en"
}Authorization
BearerAuth API Key authentication. Create or manage API keys in Dashboard > API > API Keys.
In: header
Headers
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