# REST quickstart (/en/realtime-media/speech-to-text/get-started/quickstart)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

A Real-Time STT agent subscribes to the audio content of a media stream and transcribes it into text in real time. This page shows you how to use basic RESTful API methods to start, stop, and query a Real-Time STT agent.

> **Info**
>
> The command-line examples are for demonstration purposes only. In a production environment, send RESTful API requests through your application server.

## Understand the tech

The following diagram outlines the process of implementing Real-Time STT:

![real-time-stt-flow](https://assets-docs.agora.io/images/real-time-stt/real-time-stt-flow.png)

This process includes calling the following RESTful API methods:

1. `start`: Call this method to join the channel and start transcription. If the request is successful, you receive an `agent_id` in the response body that identifies the current transcription session.

2. `update`: While a transcription agent is running, use the `update` method to modify transcription or translation languages or update the hosts for which transcription is enabled.

3. `query`: Use this method to query the agent status between `start` and `stop` calls.

4. `stop`: Call this method to stop transcription.

## Prerequisites

To follow this procedure, you must:

- Have a valid [Agora Account](https://console.agora.io/).

- Have a valid Agora project with an app ID and a temporary token or a token
  server. For details, see [Agora account management](/en/introduction/account).

- Have a computer with access to the internet. If your network has a firewall, follow the steps in [Firewall requirements](../reference/firewall).

- Join an RTC channel as a host and start streaming. Refer to the [Voice SDK quickstart](/en/realtime-media/rtc/voice-quickstart) guide.

## Project setup

To enable Real-Time STT:

1. Log in to [Agora Console](https://console.agora.io) and select **RTC Services** from the sidebar.
2. From the **Project** dropdown, select the project for which you want to enable the service.
3. Locate the **Real-Time Speech-to-Text** card and turn on its toggle.
4. Read the prompt and select **Confirm** to enable.

Now you can use Agora Real-Time STT and see the usage statistics on the **Usage** page.

## Implement Real-Time STT

This section presents sample API calls to `start`, `stop`, `update`, and `query` a Real-Time STT agent.

### Authentication

Real-Time STT RESTful APIs require basic HTTP authentication. Set the `Authorization` parameter to a Base64-encoded credential in every HTTP request header. For details on how to get the `Authorization` value, see [RESTful authentication](/en/api-reference/api-ref/speech-to-text/authentication).

### Start an agent

Call `start` to start subtitle recording and translation.

When the request is successful you receive an `agent_id` in the HTTP response body. This ID is a unique identifier of your transcription session.

**Request example**

Following is a simple request example to start a Real-Time STT agent. Refer to [Encrypt captions](../build/process-transcription-data/encrypt-captions), [Record captions](../build/process-transcription-data/record-captions), and [Transcribe specified hosts](../build/start-transcribing-and-translating/transcribe-individual-host) for more feature configurations.

```bash
curl --request post \
  --url https://api.agora.io/api/speech-to-text/v1/projects/:appid/join \
  --header 'Authorization: Basic <credentials>' \
  --data '
{
  "languages": [
    "en-US"
  ],
  "name": "agora-test",
  "maxIdleTime": 50,
  "rtcConfig": {
    "channelName": "agora-test",
    "subBotUid": "47091",
    "pubBotUid": "88222"
  },
  "translateConfig": {
    "languages": [
      {
        "source": "en-US",
        "target": [
          "ar-SA",
          "id-ID",
          "fr-FR",
          "ja-JP"
        ]
      }
    ]
  },
  "captionConfig": {
    "sliceDuration": 60,
    "storage": {
      "accessKey": "test-oss",
      "secretKey": "test-oss",
      "bucket": "test-oss",
      "vendor": 2,
      "region": 3
    }
  }
}'
```

> **Info**
>
> - String UIDs are supported only on a 128 host environment, with full support planned in the near future.
> - `pubBotUid` and `subBotUid` are `int` type UIDs that must be different to avoid unknown issues.

**Response example**

- Success

  ```json
  {
    "agent_id": "Agent ID.",
    "create_ts": 1730974708,
    "status": "RUNNING"
  }
  ```


  | Parameter Name | Type    | Description                                              |
  | -------------- | ------- | -------------------------------------------------------- |
  | `agent_id`     | String  | The ID of the agent.                                     |
  | `createTs`     | Integer | The Unix timestamp (seconds) when the agent was created. |
  | `status`       | String  | [status details](#status-details)                        |

  #### status details

  Agent Status:

  - `IDLE`: The agent is not initialized.
  - `STARTING`: The agent is starting.
  - `RUNNING`: The agent is running.
  - `STOPPING`: The agent is exiting.
  - `STOPPED`: The agent exited successfully.
  - `RECOVERING`: The agent is recovering.
  - `FAILED`: Agent exit failed.

- Failure

  ```json
  {
    "detail": "Details of the request failure.",
    "reason": "The reason why the request failed."
  }
  ```

### Query agent status

Call `query` to get the status of an agent during a transcription session. When the request is successful, you receive the current status and related information in the response body.

**Request example**

```bash
curl --request get \
  --url https://api.agora.io/api/speech-to-text/v1/projects/:appid/agents/:agentId \
  --header 'Authorization: Basic <credentials>'
```

**Response example**

- Success

  ```json
  {
    "message": "Details of the request result.",
    "agent_id": "Agent ID.",
    "create_ts": 1730974708,
    "status": "RUNNING"
  }
  ```


- Failure

  ```json
  {
    "message": "Details of the failed request.",
    "agent_id": "Agent ID.",
    "create_ts": 1730974708,
    "status": "FAILED"
  }
  ```

### Update configuration

See [Update configuration](../build/start-transcribing-and-translating/update-service) for details.

### Stop the agent

Call `stop` to stop transcribing. When the request is successful, you receive the status of the transcription session in the response body.

**Request example**

```bash
curl --request post \
  --url https://api.agora.io/api/speech-to-text/v1/projects/:appid/agents/:agentId/leave \
  --header 'Authorization: Basic <credentials>'
```

## Reference

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

### Demo app and source code

To try Real-Time STT and evaluate its accuracy and latency, use the [demo app](https://stt-demo-global.agora.io/).

To see how captions and transcription are implemented, refer to the [sample project on GitHub](https://github.com/AgoraIO-Community/Agora-RTT-Demo/tree/release/7.x). This sample is for testing only. Don't use it in production. For more demo code, contact <support@agora.io>.

### REST API middleware

[Agora Go Backend Middleware](https://github.com/AgoraIO-Community/agora-go-backend-middleware) is an open-source microservice that exposes a RESTful API designed to simplify Real-Time STT interactions with Agora. Written in Golang and powered by the Gin framework, this community project serves as a middleware to bridge front-end applications using Agora's RTC SDK or Voice SDK with Agora's RESTful APIs.
