# Get the transcription result

Source: [Get the transcription result](<https://docs.gptunnel.ru/en/transcription/result/>)

<a id="_top"></a>
<a id="get-the-result-of-the-transcription"></a>
## Get the result of the transcription

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

Returns the current transcription status and result. For automatic delivery, set `callback_url` when you [create the task](<https://docs.gptunnel.ru/en/transcription/create/>).

> **Note: Use the transcription endpoint to get the result**
>
> Poll the transcription endpoint shown above. Sending the same `task_id` to `GET /v1/media/result` returns HTTP `400` with code `17` because that endpoint only handles Creative Lab tasks.

### Request headers

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

### Request parameters

| Parameter | Type | Required? | Description |
| --- | --- | --- | --- |
| `task_id` | `string` | Required | The id field from the task creation response |

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

Set `GPTUNNEL_API_KEY` to your [API key](<https://docs.gptunnel.ru/en/#get-an-api-key>) and `TASK_ID` to the `id` field from the [task creation response](<https://docs.gptunnel.ru/en/transcription/create/>). The Python example requires `requests`, and the cURL example requires `jq`.

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

```python
import os

import requests

response = requests.get(
    'https://gptunnel.ru/v1/audio/transcriptions',
    headers={'Authorization': os.environ['GPTUNNEL_API_KEY']},
    params={'task_id': os.environ['TASK_ID']},
    timeout=30,
)
response.raise_for_status()
task = response.json()
print(task['status'])

if task['status'] == 'done':
    for channel in task['result']['results']['channels']:
        alternatives = channel.get('alternatives') or []
        if alternatives:
            print(alternatives[0].get('transcript', ''))
elif task['status'] == 'failed':
    print(task.get('error_title'), task.get('error_description'))
```

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

```bash
curl --fail-with-body --silent --show-error --get \
  --url 'https://gptunnel.ru/v1/audio/transcriptions' \
  --data-urlencode "task_id=${TASK_ID:?Set TASK_ID to the task ID returned when creating the task}" \
  --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \
  | jq -r '.status, (.result.results.channels[]?.alternatives[0].transcript // empty), (.error_title // empty)'
```

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

```javascript
const url = new URL('https://gptunnel.ru/v1/audio/transcriptions')
url.searchParams.set('task_id', process.env.TASK_ID)

const response = await fetch(url, {
  headers: { Authorization: process.env.GPTUNNEL_API_KEY },
})

if (!response.ok) throw new Error(await response.text())
const task = await response.json()
console.log(task.status)

if (task.status === 'done') {
  for (const channel of task.result.results.channels) {
    if (channel.alternatives?.[0]?.transcript) {
      console.log(channel.alternatives[0].transcript)
    }
  }
} else if (task.status === 'failed') {
  console.error(task.error_title, task.error_description)
}
```

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

The example shows the result of transcribing the [sample recording](<https://docs.gptunnel.ru/en/transcription/quickstart/>) with `deepgram-whisper-tiny`. The response reports `whisper-tiny` in `provider`.

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

```json
{
  "code": 0,
  "id": "6a47bb78fb3f0d852e64c8e3",
  "status": "done",
  "result": {
    "provider": "whisper-tiny",
    "metadata": {
      "duration": 1.8840625,
      "channels": 1
    },
    "results": {
      "channels": [
        {
          "alternatives": [
            {
              "transcript": "The sky is blue today.",
              "confidence": 0.9200794
            }
          ]
        }
      ]
    }
  },
  "error_title": null,
  "error_description": null
}
```

<a id="tab-panel-1-1"></a>
**200 OK (processing)**

```json
{
  "code": 0,
  "id": "6a47bb78fb3f0d852e64c8e3",
  "status": "processing",
  "result": null,
  "error_title": null,
  "error_description": null
}
```

<a id="tab-panel-1-2"></a>
**200 OK (failed)**

```json
{
  "code": 0,
  "id": "6a47bb78fb3f0d852e64c8e3",
  "status": "failed",
  "result": null,
  "error_title": "SOURCE_UNREACHABLE",
  "error_description": "The source did not serve the audio file (failed to fetch remote content). Make sure the URL is publicly accessible to external servers without cookies or user-agent filtering, and returns a correct Content-Length."
}
```

<a id="tab-panel-1-3"></a>
**404 Not Found**

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

| Status | What to Do |
| --- | --- |
| `processing` | The result is not ready (`result: null`). Continue polling or wait for the webhook. |
| `done` | Read the result and stop polling. |
| `failed` | Read `error_title` and `error_description` and stop polling. |

The statuses `done` and `failed` are final.

<a id="webhook-delivery-callback_url"></a>
## Webhook delivery (callback\_url)

If you supplied `callback_url` when you [created the task](<https://docs.gptunnel.ru/en/transcription/create/>), the API sends the result to that URL in a `POST` request when the task reaches `done` or `failed`. Both the polling response and the webhook body include the task status, result, and the same `error_title` and `error_description` fields. You can use those fields to handle errors in either case. Only the polling response includes `code`.

<a id="tab-panel-2-0"></a>
**POST body (done)**

```json
{
  "id": "6a47bb78fb3f0d852e64c8e3",
  "status": "done",
  "url": null,
  "result": {
    "provider": "whisper-tiny",
    "metadata": { "duration": 1.8840625, "channels": 1 },
    "results": {
      "channels": [
        { "alternatives": [{ "transcript": "The sky is blue today.", "confidence": 0.9200794 }] }
      ]
    }
  },
  "error_title": null,
  "error_description": null
}
```

<a id="tab-panel-2-1"></a>
**POST body (failed)**

```json
{
  "id": "6a47bb78fb3f0d852e64c8e3",
  "status": "failed",
  "url": null,
  "error_title": "SOURCE_UNREACHABLE",
  "error_description": "The source did not serve the audio file (failed to fetch remote content). Make sure the URL is publicly accessible to external servers without cookies or user-agent filtering, and returns a correct Content-Length."
}
```

> **Note: Web-hook processing**
>
> Respond to the webhook with a `2xx` status. The `error_title` values match the machine-readable codes in the table below.

 <a id="transcribation-errors-status-false"></a>
 
<a id="transcription-errors-status-failed"></a>
## Transcription errors (status: failed)

When `status` is `failed`, `error_title` contains a machine-readable reason code and `error_description` explains the failure.

| error\_title | Cause | Should I repeat the request? |
| --- | --- | --- |
| `SOURCE_UNREACHABLE` | The transcription provider could not download the file from `audio_url`. The host may block external servers, require cookies, or filter requests by User-Agent. | No. First move the file to a host that the provider [can reach without signing in](<https://docs.gptunnel.ru/en/transcription/about/#file-hosting-requirements>). |
| `UNSUPPORTED_MEDIA` | The provider does not support the file codec or container. | No. Convert the file to a [supported format](<https://docs.gptunnel.ru/en/transcription/about/#supported-formats>) (e.g. mp3 or wav). |
| `TIMEOUT_TRY_AGAIN_LATER` | Temporary service malfunction or overload. | Yes - repeat the request later. |
| `EXCEPTION` | Other processing error. | You can retry. If the error persists, contact support. |

> **Note: When the funds are returned**
>
> If the task fails (`status: "failed"`), the amount charged when the task was created **is automatically refunded**. For `SOURCE_UNREACHABLE` or `UNSUPPORTED_MEDIA`, fix the cause before retrying the same URL.

> **Note: Audio without recognized speech**
>
> Audio without recognizable speech can return `status: "done"` with an empty `alternatives` array and no `transcript` field. Check that a transcript is present before using it.
