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

# POST /translate

> Translate text between 100+ languages with a single API call. Returns the translated text and a confidence score.

## Endpoint

```
POST https://api.bunny.build/api/v1/translate
```

## Authentication

| Header         | Required | Value                    |
| -------------- | -------- | ------------------------ |
| `X-API-Key`    | Yes      | Your API key (`bun_...`) |
| `Content-Type` | Yes      | `application/json`       |

## Overview

Translate text between 100+ languages with a single API call. Bunny's Translation API accepts source and target language codes and returns the translated text along with a confidence score.

## Use cases

* Build multilingual UIs without a dedicated i18n backend
* Translate user-generated content in real time
* Power customer support tools with automatic message translation
* Add language detection to content pipelines

## Details

Uses ISO 639-1 language codes (e.g. `en`, `pt`, `es`, `fr`, `de`). The `confidence` field (0–1) reflects translation quality. Long texts are supported but response time scales with length.

## Request body

| Field  | Type   | Required | Description                                                           |
| ------ | ------ | -------- | --------------------------------------------------------------------- |
| `text` | string | Yes      | Text to translate (max 5,000 characters)                              |
| `to`   | string | Yes      | Target language code (ISO 639-1, e.g. `pt`)                           |
| `from` | string | No       | Source language code (ISO 639-1, e.g. `en`). Defaults to `autodetect` |

### Example

```json theme={null}
{
  "text": "Hello world",
  "to": "pt"
}
```

## Response

### 200 OK

| Field        | Type         | Description                                                      |
| ------------ | ------------ | ---------------------------------------------------------------- |
| `original`   | string       | The original text that was submitted                             |
| `translated` | string       | Translated text                                                  |
| `from`       | string       | Source language code used (may be `autodetect` if not specified) |
| `to`         | string       | Target language code                                             |
| `confidence` | number\|null | Translation confidence score (0–1)                               |

**Example**

```json theme={null}
{
  "original": "Hello world",
  "translated": "Olá mundo",
  "from": "autodetect",
  "to": "pt",
  "confidence": 0.82
}
```

### 401 Unauthorized

```json theme={null}
{
  "detail": "Missing API key. Include X-API-Key header."
}
```

### 402 Payment Required

```json theme={null}
{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}
```

### 422 Unprocessable Entity

Invalid language code or empty text.

```json theme={null}
{
  "detail": "Unsupported language code"
}
```

### 429 Too Many Requests

```json theme={null}
{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}
```

## cURL example

```bash theme={null}
curl -X POST https://api.bunny.build/api/v1/translate \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello world", "to": "pt"}'
```
