# Create a transcription task

Source: [Create a transcription task](<https://docs.gptunnel.ru/en/transcription/create/>)

<a id="_top"></a>
> **Note: Deprecated models**
>
> If the provider retires the requested model, the API creates the task with its designated replacement and bills at the original model’s rate. Check the response headers and the `warnings` array in the creation response. Without a replacement, the API returns `410` with code `15`. See [Deprecated models](<https://docs.gptunnel.ru/en/getting-started/deprecated-models/>).

 <a id="create-a-transcribation-task"></a>
 
<a id="create-a-transcription-task"></a>
## Create a transcription task

`POST https://gptunnel.ru/v1/audio/transcriptions`

Transcription runs asynchronously. The endpoint creates a task and returns its `id` and `status`. Set `callback_url` to receive the result via webhook, or [poll the result endpoint](<https://docs.gptunnel.ru/en/transcription/result/>).

### Request headers

| Parameter | Type | Required? | Description |
| --- | --- | --- | --- |
| `Authorization` | `string` | Required | API key |

### Request body

| Parameter | Type | Required? | Description |
| --- | --- | --- | --- |
| `audio_url` | `string` | Required | Direct public HTTP or HTTPS URL for the audio or video file |
| `model` | `string` | Required | Model: deepgram-whisper-tiny \| deepgram-whisper-medium \| deepgram-whisper-large |
| `language` | `string` | Optional | Language code (e.g. "ru", "en"). If not specified, language is automatically defined |
| `callback_url` | `string` | Optional | URL to send the result (webhook). Must be public |

<a id="example-request"></a>
### Example request

Set your [API key](<https://docs.gptunnel.ru/en/#get-an-api-key>) in the `GPTUNNEL_API_KEY` environment variable. The Python example uses `requests` and the cURL example uses `jq`. Save the task ID printed by the example and pass it as `task_id` when you [retrieve the transcription](<https://docs.gptunnel.ru/en/transcription/result/>). All three examples use the [sample WAV file](<https://docs.gptunnel.ru/examples/blue-sky.wav>) from the [quickstart](<https://docs.gptunnel.ru/en/transcription/quickstart/>). To transcribe a different file, set `GPTUNNEL_AUDIO_URL` to its public HTTPS URL.

<a id="tab-panel-0-0"></a>
**Python**

```python
import os

import requests

response = requests.post(
    'https://gptunnel.ru/v1/audio/transcriptions',
    headers={'Authorization': os.environ['GPTUNNEL_API_KEY']},
    json={
        'audio_url': os.environ.get('GPTUNNEL_AUDIO_URL') or 'https://docs.gptunnel.ru/examples/blue-sky.wav',
        'model': 'deepgram-whisper-tiny',
        'language': 'en',
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()['id'])
```

<a id="tab-panel-0-1"></a>
**cURL**

```bash
audio_url=${GPTUNNEL_AUDIO_URL:-https://docs.gptunnel.ru/examples/blue-sky.wav}
body=$(jq -nc --arg url "$audio_url" '{audio_url: $url, model: "deepgram-whisper-tiny", language: "en"}')
curl --fail-with-body --silent --show-error \
  --url 'https://gptunnel.ru/v1/audio/transcriptions' \
  --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \
  --json "$body" \
  | jq -er '.id'
```

<a id="tab-panel-0-2"></a>
**JavaScript (Node.js)**

```javascript
const response = await fetch('https://gptunnel.ru/v1/audio/transcriptions', {
  method: 'POST',
  headers: {
    Authorization: process.env.GPTUNNEL_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    audio_url: process.env.GPTUNNEL_AUDIO_URL || 'https://docs.gptunnel.ru/examples/blue-sky.wav',
    model: 'deepgram-whisper-tiny',
    language: 'en',
  }),
})

if (!response.ok) throw new Error(await response.text())
console.log((await response.json()).id)
```

<a id="example-response"></a>
### Example response

<a id="tab-panel-1-0"></a>
**200 OK**

```json
{
  "code": 0,
  "id": "6a47bb78fb3f0d852e64c8e3",
  "status": "processing"
}
```

<a id="tab-panel-1-1"></a>
**400 Bad Request**

```json
{
  "code": 3,
  "message": "Invalid input, check schema issues."
}
```

<a id="tab-panel-1-2"></a>
**400 Audio too long**

```json
{
  "code": 8,
  "message": "Audio is too long. Maximum duration is 2 hours."
}
```

<a id="tab-panel-1-3"></a>
**400 Audio too short**

```json
{
  "code": 9,
  "message": "Audio is too short. Minimum duration is 1 second."
}
```

<a id="tab-panel-1-4"></a>
**400 Source fetch failed**

```json
{
  "code": 12,
  "message": "Could not read the audio file at audio_url. Ensure the link is a direct, publicly accessible file URL (no bot protection), supports HTTP Range requests, and returns a correct Content-Length."
}
```

<a id="tab-panel-1-5"></a>
**403 Model not allowed**

```json
{
  "code": 19,
  "message": "Model is not allowed for this API key. Adjust allowed models in the dashboard or use another key."
}
```

<a id="tab-panel-1-6"></a>
**404 Model not found**

```json
{
  "code": 4,
  "message": "Record not found."
}
```

<a id="tab-panel-1-7"></a>
**415 Unsupported format**

```json
{
  "code": 11,
  "message": "Unsupported audio format. Supported formats: mp3, mp2, wav, flac, aac, ogg, oga, opus, m4a, mp4, mov, 3gp, alac, webm, mka, wma, wmv, amr, aiff, ac3, avi, flv, ts, mpg, au."
}
```

<a id="tab-panel-1-8"></a>
**402 Payment Required**

```json
{
  "code": 5,
  "message": "Insufficient balance, check account balance."
}
```

<a id="tab-panel-1-9"></a>
**504 Probe timeout**

```json
{
  "code": 10,
  "message": "Could not read audio duration in time. Ensure audio_url is a direct, fast, publicly reachable link."
}
```

> **Note: When a request is rejected before charging**
>
> The API returns these errors immediately, **before creating the task or charging the account**.
>
>
>
> - `400 / code 3` - invalid request body or a URL that does not meet the requirements;
> - `400 / code 12` – the service could not read the file from the URL because the host is unreachable, blocks bots, or drops the connection. See the [hosting requirements](<https://docs.gptunnel.ru/en/transcription/about/#file-hosting-requirements>);
> - `403 / code 19` — the API key is not allowed to use that `model`;
> - `404 / code 4` - unknown `model` or a model unavailable to the API key;
> - `415 / code 11` - file format not supported - see [supported formats](<https://docs.gptunnel.ru/en/transcription/about/#supported-formats>);
> - `504 / code 10` - the check for file duration timed out.

Errors that arise after the creation of a task are listed in [transcription errors](<https://docs.gptunnel.ru/en/transcription/result/#transcription-errors-status-failed>).
