TypeScript quickstart
This guide walks you through using Hume’s Expression Measurement API with the TypeScript SDK. You will submit a batch job to analyze a media file and then connect to the streaming API for real-time predictions.
Setup
Install the SDK
bun
pnpm
npm
yarn
Set your API key
Get your API key from the Hume AI platform and set it as an environment variable.
Create the client
Batch API
The Batch API lets you submit files for processing and retrieve predictions when the job completes. This is best for analyzing recordings, datasets, and other pre-recorded content.
Submit a job and wait for completion
Start a job by specifying the models you want to run and the URLs of the files to process. The SDK provides a built-in
awaitCompletion method that polls the job status for you.
You can also upload local files instead of URLs. See the API reference for the local file upload endpoint.
For production use, consider passing a callbackUrl when submitting the job. Hume will send a POST request to
your URL when the job completes. The webhook payload includes the jobId, status, and predictions.
Retrieve predictions
Once the job completes, retrieve and print the predictions.
Predictions are also available as CSV files. Use the Get job artifacts endpoint to download a zip archive containing one CSV per model.
Streaming API
The Streaming API provides real-time predictions over a WebSocket connection. This is best for live audio, video, and interactive applications.
Connect and send data
Open a streaming connection and send text for analysis.
Stream a file
You can also send audio or video files through the streaming connection.

