Authentication
Requests to the API carry an API key in the X-Hume-Api-Key header. The upload and run endpoints need it on every request. A realtime session sends it once, on the handshake that opens the WebSocket.
API keys
- Sign in to the Hume Platform, or create an account.
- On the API keys page, select Create API key.
- Name the key for whatever will use it, and choose its permissions and when it expires.
- Create the key and copy it. The key is shown only once.
A key’s expiry cannot be extended. Before a key expires, create a new one and switch your code to it.
HTTP requests
Set the X-Hume-Api-Key header on every request to an upload or run endpoint. The request below lists your organization’s runs.
The SDKs send the key you pass to the client in this header on every request and connection. If you pass none, they read it from the HUME_API_KEY environment variable.
A missing, invalid or expired key is rejected with 401 Unauthorized before the request reaches the service. The body has a message, plus a request_id when a key was sent and rejected, but no type or code. See HTTP errors.
WebSocket handshake
Set the X-Hume-Api-Key header when opening the connection. The handshake request your client library sends looks like this:
A valid key completes the upgrade, and the server immediately sends session.created. A missing, invalid or expired key is rejected with 401 Unauthorized, and a handshake from an organization that is not permitted to use the endpoint is rejected with 403 Forbidden. Both happen before any WebSocket exists, so there is no error message; read the status from your client library’s handshake result.
Browsers
An API key must never ship in client-side code, so call the API from a server you control. To use the API from a web page, relay through that server: the browser sends media to your server, which forwards it to Hume with the key attached and returns the results. The realtime endpoints need this relay in any case, because browsers cannot set custom headers on a WebSocket handshake.