# Translate text

Translate one or more strings with POST /v2/translate, or with the Google v2 and Azure v3 text endpoints.

Use `POST /v2/translate` to translate text. It has the same shape as the DeepL endpoint. The Google Translate v2 and Azure Translator v3 endpoints at the end of this page do the same work in their own formats.

## Request

```http
POST https://vibeql.com/v2/translate
Authorization: DeepL-Auth-Key YOUR_KEY
```

| Parameter | Required | Description |
|---|---|---|
| `text` | Yes | Text to translate. Repeat it to translate several strings in one request. Up to 50 values. |
| `target_lang` | Yes | Target language code, for example `DE`, `PT-BR` or `EN-US`. See [Languages](/docs/languages). |
| `source_lang` | No | Source language code, for example `EN`. Leave it out and the model reads the source language from the text. |
| `show_billed_characters` | No | Set to `true` or `1` to add `billed_characters` to each result. |

The request body can be up to 128 KB. Send the body as a form or as JSON.

**Form**

```bash
curl https://vibeql.com/v2/translate \
  -H "Authorization: DeepL-Auth-Key $VIBEQL_API_KEY" \
  -d "text=Good morning" \
  -d "text=Thank you" \
  -d "target_lang=ES" \
  -d "source_lang=EN"
```

**JSON**

```bash
curl https://vibeql.com/v2/translate \
  -H "Authorization: DeepL-Auth-Key $VIBEQL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": ["Good morning", "Thank you"], "target_lang": "ES", "source_lang": "EN"}'
```

## Response

The API returns one result for each `text` value, in the same order.

```json
{
  "translations": [
    { "detected_source_language": "EN", "text": "Buenos días" },
    { "detected_source_language": "EN", "text": "Gracias" }
  ]
}
```

With `show_billed_characters=true`:

```json
{
  "translations": [
    { "detected_source_language": "EN", "text": "Buenos días", "billed_characters": 12 }
  ]
}
```

> **Note:** On this endpoint, `detected_source_language` repeats your `source_lang`. If you leave out `source_lang`, the field is `EN`. The translation itself still works from any supported source language. Send `source_lang` when your code reads this field.

Other DeepL parameters, such as `formality`, `glossary_id`, `tag_handling` or `context`, are ignored. See [Migrate from DeepL](/docs/migrate-from-deepl).

## Usage

Usage counts the characters of the source text that you send, not the translated text. `Good morning` counts as 12 characters in every target language. Check your total with [`GET /v2/usage`](/docs/limits-and-errors#usage).

## Google Translate v2 format

`GET` or `POST https://vibeql.com/language/translate/v2`. Repeat `q` for several strings. `source` is optional; leave it out and the API detects the language.

```bash
curl "https://vibeql.com/language/translate/v2?key=$VIBEQL_API_KEY" \
  -d "q=Good morning" \
  -d "q=Thank you" \
  -d "target=es"
```

```json
{
  "data": {
    "translations": [
      { "translatedText": "Buenos días", "detectedSourceLanguage": "en" },
      { "translatedText": "Gracias", "detectedSourceLanguage": "en" }
    ]
  }
}
```

See [Migrate from Google Translate](/docs/migrate-from-google) for all parameters.

## Azure Translator v3 format

`POST https://vibeql.com/translate?api-version=3.0&to=es`. Send a JSON array of `Text` items. Repeat `to` for up to 10 target languages. `from` is optional.

```bash
curl "https://vibeql.com/translate?api-version=3.0&to=es" \
  -H "Ocp-Apim-Subscription-Key: $VIBEQL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[{"Text": "Good morning"}]'
```

```json
[
  {
    "detectedLanguage": { "language": "en", "score": 1 },
    "translations": [{ "text": "Buenos días", "to": "es" }]
  }
]
```

With several `to` languages, usage counts the source characters once for each target language. See [Migrate from Azure Translator](/docs/migrate-from-azure).
