Securely deploy Anam AI in production environments
When deploying to production, it’s important not to expose your API key publicly. Instead, you should:
Anam AI offers two types of session tokens: Stateful and Ephemeral.
API Change Notice: Recent API changes mean we now use a POST
request
instead of GET
, and you define your persona configuration at this point in
the request body. This change improves security by allowing you to configure
your persona on the server side, preventing sensitive configuration details
from being exposed to the client.
Stateful tokens reference a persona that you’ve created and configured in the Anam AI Lab, or using the Anam AI API. These are referenced by a unique ID.
Configuration changes are managed in the Lab interface without needing code changes. So this is ideal for personas that don’t need to change from session to session.
This approach offers less flexibility for per-user customization.
Ephemeral tokens allow you to define the persona configuration at runtime.
Define your persona configuration at runtime, enabling per session customization and fast feedback during development.
Requires managing persona configuration inside your application.
From your server, make a request to get a stateful session token, referencing your persona ID:
From your server, make a request to get an ephemeral session token, with your persona configuration:
Once you have a session token from your server, use the createClient
method to initialize the Anam client:
The client exposes the same methods whether initialized with an API key or session token.
The sequence diagram below shows how a typical session is started.
Learn how to control persona output using talk commands
Control audio input and streaming behavior