Examples

Visit our GitHub samples repository for the complete list of examples on how to use the Vatis Streams API.

Prerequisites

  • Vatis API key
  • Linux shell
  • cURL or Postman for making HTTP or WebSocket requests
  • jq for parsing JSON responses
  • uuidgen for generating UUIDs
  • a testing audio/video file

Workflow

1

Export variables

export API_KEY=<your_api_key>
export STREAM_ID=$(uuidgen)
export FILE_PATH=<path_to_file>
2

Choose a stream configuration

The stream configuration defines what processing will be made on the input data (transcoding, transcription, diarization, audio intelligence, etc.). Pick one of the the predefined configurations:

Export the configuration ID:

export CONFIG_ID=<config_id>
Keep the stream configuration page opened in a separate tab for further references during this process
3

Upload the data

Use one of the available gateways for uploading the data.

Set the streamConfigurationTemplateId=$CONFIG_ID, persist=true, and any other patches as query parameters and upload the binary data as the body of the request.

The configuration-specific patches (parameters) can be found under the Parameters section of the configuration page.

When dealing with long parameter values (e.g. prompts) consider using the HTTP Gateway with form-data approach

The body will be sent as binary data on the request body. The actual body can be one of the options mentioned under the Input data section of the configuration page.

curl --request POST \
  --url "https://http-gateway.vatis.tech/http-gateway/api/v1/upload?id=$STREAM_ID&streamConfigurationTemplateId=$CONFIG_ID&persist=true&language=en" \
  --header "Authorization: Basic $API_KEY" \
  --header 'Content-Type: application/octet-stream' \
  --data-binary @"$FILE_PATH" | jq
To prevent any unexpected error, always include the Content-Type: application/octet-stream header
4

Wait for stream completion

Run the following command until the result is COMPLETED:

curl --request GET \
  --url "https://stream-service.vatis.tech/stream-service/api/v1/streams/$STREAM_ID" \
  --header "Authorization: Basic $API_KEY" | jq '.state'
5

Export the final result

After the stream is completed, we can export the final result as JSON using the following command:

curl --request GET \
  --url "https://export-service.vatis.tech/export-service/api/v1/export/JSON?streams=$STREAM_ID" \
  --header "Authorization: Basic $API_KEY" | jq

Based on the stream configuration, the result will be the one mentioned under the Export response section of the configuration.