> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Translation

> Translates text into a target language

## Overview

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

<Note>
  This endpoint is different from [Audio Translation](/api-reference/audio/create-translation), which accepts an audio file and always outputs English text.
</Note>

For agent workflows, discover the current recommended translation models first:

```bash theme={null}
curl "https://api.tokenlab.sh/v1/models?recommended_for=translation" \
  -H "Authorization: Bearer sk-your-api-key"
```

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

<Note>
  `recommended_for=translation` applies only to **text translation** (`POST /v1/translations`). It does not apply to [audio translation](/api-reference/audio/create-translation).
</Note>

## Request Body

<ParamField body="model" type="string" required>
  Translation model ID returned by `/v1/models?recommended_for=translation`.
</ParamField>

<ParamField body="text" type="string" required>
  Source text to translate.
</ParamField>

<ParamField body="target_language" type="string" required>
  Target language code or language name, depending on model support.
</ParamField>

<ParamField body="source_language" type="string">
  Optional source language hint.
</ParamField>

<ParamField body="mime_type" type="string" default="text/plain">
  Source text format. Supported values: `text/plain`, `text/html`.
</ParamField>

<ParamField body="user" type="string">
  Optional end-user identifier for abuse monitoring and request tracing.
</ParamField>

## Response

<ResponseField name="text" type="string">
  Translated text.
</ResponseField>

<ResponseField name="model" type="string">
  Model that generated the translation.
</ResponseField>

<ResponseField name="source_language" type="string | null">
  Source language detected or accepted by the model.
</ResponseField>

<ResponseField name="target_language" type="string">
  Target language used for the request.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  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"
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI
  import requests

  client = OpenAI(
      api_key="sk-your-api-key",
      base_url="https://api.tokenlab.sh/v1"
  )

  response = requests.post(
      "https://api.tokenlab.sh/v1/translations",
      headers={
          "Authorization": "Bearer sk-your-api-key",
          "Content-Type": "application/json",
      },
      json={
          "model": "doubao-seed-translation",
          "text": "你好，欢迎使用 TokenLab。",
          "target_language": "en",
      },
      timeout=30,
  )

  print(response.json()["text"])
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "text": "Hello, welcome to TokenLab.",
    "model": "doubao-seed-translation",
    "source_language": "zh",
    "target_language": "en"
  }
  ```
</ResponseExample>
