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

# Translation

Translates audio content to a specified language.

## Endpoint

```python
POST https://api.sambanova.ai/v1/audio/translations
```

<Note>
  For SambaStack, developers should check with their system administrator for the correct URL.
</Note>

## Request parameters

The following tables outline the parameters required to make an audio translation request, parameter type, description, and default values.

<Note>
  For improved accuracy, we strongly recommend specifying the `language` parameter when using any audio model.
</Note>

### Whisper Large v3

| Parameter         | Type    | Description                                                                                                                            | Default  |
| :---------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------- | :------- |
| `model`           | String  | The ID of the model to use.                                                                                                            | Required |
| `file`            | File    | Audio file in FLAC, MP3, MP4, MPEG, MPGA, M4A, Ogg, WAV, or WebM format. File size limit is 25MB.                                      | Required |
| `prompt`          | String  | Prompt provided to influence translation style or vocabulary. Example: "Please translate carefully, including pauses and hesitations." | Optional |
| `response_format` | String  | Output format: JSON or text.                                                                                                           | `json`   |
| `language`        | String  | The language of the input audio. Supplying the input language in ISO-639-1 (e.g. en) format will improve accuracy and latency.         | Optional |
| `stream`          | Boolean | Enables streaming responses.                                                                                                           | false    |
| `stream_options`  | Object  | Additional streaming configuration (e.g., `{"include_usage": true}`).                                                                  | Optional |

## Request format

This section provides examples of how to send a request using different methods.

### CURL

```
curl --location 'https://api.sambanova.ai/v1/audio/translations' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--form 'model="Whisper-Large-v3"' \
--form 'language="spanish"' \
--form 'response_format="json"' \
--form 'file=@"/path/to/audio/file.mp3"' \
--form 'stream="true"'
```

### Python

<CodeGroup>
  ```python helloWorld.py
  import requests

  def translate_audio(audio_file_path, api_key, target_language="spanish"):
        headers = {"Authorization": f"Bearer {api_key}"}

        files = {'file': open(audio_file_path, 'rb')}
        
        data = {
            'model': 'Whisper-Large-v3',
            'language': target_language,
            'response_format': 'json',
            'stream': True  # Optional
        }
        response = requests.post(
            "https://api.sambanova.ai/v1/audio/translations",
            headers=headers,
            files=files,
            data=data
        )
        return response.json()
  ```
</CodeGroup>

## Response format

The API returns a translation of the input audio in the selected format.

### JSON

```
{
    "text": "Es un efecto de sonido de una campana sonando, específicamente una campana de iglesia."
}
```

### Text

```
Es un efecto de sonido de una campana sonando, específicamente una campana de iglesia.
```
