Start a Real-time STT agent

Updated

Starts subtitle recording and translation.

POST
https://api.agora.io/api/speech-to-text/v1/projects/{appid}/join

Use this method to start subtitle recording and subtitle translation.

Path Parameters

appidstring
Required

The App ID of the project.

Request Body

application/json

languagesarray<string>
Required

The transcription languages you want to recognize. You can specify up to four languages. For a complete list, see Supported languages. Choosing multiple transcription languages can affect both quality and cost. For best practices, see Optimize transcription quality and cost.

uidLanguagesConfigarray<object>

Configure the transcription language for the specified user ID. Supports up to 5 configuration items.

maxIdleTimeinteger

Maximum channel idle time, in seconds. Value range: [0,259200]. Set maxIdleTime to 0 to disable automatic termination due to idle time. When the specified time is exceeded, the task ends automatically. Idle time means that there is no host in a live broadcast channel, or there is no user in a communication channel.

Independent of maxIdleTime, every task also has a maximum lifetime of 72 hours (259200 seconds). Once a task reaches this limit, Agora terminates it, even if maxIdleTime is 0.

rtcConfigobject
Required

Real-time subtitle configuration. After a user's voice is converted to text, the information is pushed to the channel as subtitles to match the UI real-time display.

channelNamestring
Required

The name of the channel to transcribe.

subBotUidstring
Deprecated

The ID of the bot that subscribes to the audio stream. This is always identical to the value of the pubBotUid.

subBotTokenstring
Deprecated

The token used by the subscribing bot for channel authentication. Required only when your project has App Certificate enabled. Generate this token on your token server. For details, see Token authentication.

pubBotUidstring
Required

The ID of the bot that pushes subtitle information to the channel. All UIDs within a channel must be unique. Ensure no other user or service bot is using this UID in the same channel.

pubBotTokenstring

The token used by the subtitle-pushing bot for channel authentication. Required only when your project has App Certificate enabled. Generate this token on your token server. For details, see Token authentication.

subscribeAudioUidsarray<string>

The user IDs for the audio streams you want to subscribe. Set this parameter if you need to subscribe to the audio stream of certain users. Maximum array length: 32. You can set either subscribeAudioUids or unSubscribeAudioUids.

unSubscribeAudioUidsarray<string>

The user IDs for the audio streams you do not want to subscribe. Set this parameter if you don't need to subscribe to the audio stream of certain users. Maximum array length: 5. You can set either subscribeAudioUids or unSubscribeAudioUids.

cryptionModeinteger
Deprecated

The encryption and decryption mode. When enabled, this mode is used for both decrypting incoming streams and encrypting outgoing subtitles.

  • 0: No encryption
  • 1: AES_128_XTS 128-bit AES encryption, XTS mode
  • 2: AES_128_ECB 128-bit AES encryption, ECB mode
  • 3: AES_256_XTS 256-bit AES encryption, XTS mode
  • 4: SM4_128_ECB 128-bit SM4 encryption, ECB mode
  • 5: AES_128_GCM 128-bit AES encryption, GCM mode
  • 6: AES_256_GCM 256-bit AES encryption, GCM mode
  • 7: AES_128_GCM2 128-bit AES encryption, GCM mode, Compared with AES_128_GCM encryption mode, this encryption mode is more secure and requires setting a key and salt.
  • 8: AES_256_GCM2 256-bit AES encryption, GCM mode, Compared with AES_256_GCM encryption mode, this encryption mode is more secure and requires setting a key and salt. The decryption method must match the encryption method set for the channel.
secretstring

The encryption/decryption key. Required when cryptionMode is not 0.

saltstring

A Base64-encoded, 32-byte encryption/decryption salt. Required only when cryptionMode is 7 or 8.

enableJsonProtocolboolean

Set the encoding format of the subtitle data pushed to the channel.

  • true: Use JSON to push subtitles and compress data with gzip. Uses less bandwidth, but requires decoding.
  • false: Use Protobuf to push subtitles (default). The data volume is smaller. Suitable for scenarios with high transmission efficiency requirements.

A single update can contain both a stabilized prefix segment and a segment that may still change. Both JSON and Protobuf formats can carry multiple segments in a single message. For details, see Parse transcription data.

translateConfigobject

Subtitle translation configuration.

captionConfigobject

Subtitle recording configuration.

extensionParamsobject

Optional third-party cloud storage extension configuration. When storage.vendor is set to 11, use this field to specify access information for standard S3-compatible object storage.

keywordsarray<string>

Keyword list. Use it to improve the recognition accuracy of specific words during transcription. Supports up to 500 words.

namestring
Required

Unique ID of the agent. Maximum length is 64 characters. You cannot use the same ID repeatedly.

Response

  • If the returned status code is 200, the request was successful. The response body contains the result of the request.

Response Body

OK

agent_idstring

The ID of the agent.

create_tsinteger

The Unix timestamp (in seconds) when the agent was created.

statusstring

The current status of the agent:

  • 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

Response

Refer to the detail and reason fields to understand the possible reasons for failure.

Authorization

This endpoint requires authentication.

BasicAuth

Request examples

curl --request POST \  --url https://api.agora.io/api/speech-to-text/v1/projects/:appid/join \  --header 'Authorization: Basic <credentials>' \  --data '{  "languages": [    "en-US"  ],  "keywords": [    "Agora",    "STT"  ],  "name": "agora-test",  "maxIdleTime": 50,  "rtcConfig": {    "channelName": "agora-test",    "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    }  }}'

Response example

{  "agent_id": "Agent ID.",  "create_ts": null,  "status": "RUNNING"}