Basic Usage
Install and setup the Anam AI JavaScript SDK
Installation
Install the SDK in your project using npm:
Local Development
The quickest way to start using the SDK is with a local development setup:
This example uses the unsafe_createClientWithApiKey
method. This is not recommended for production use as it exposes your API key. See the Usage in Production guide for secure implementation.
If you haven’t already created your own persona, you can use one of our default personas to get started.
Try Leo, the AI receptionist with the ID 773a8ca8-efd8-4449-9305-8b8bc1591475
.
DOM Elements
This quickstart example requires two DOM elements to stream to:
- A video element to play the video stream of your persona
- An audio element to play the voice stream of your persona
For this example we would include the following in our HTML:
autoplay
is used to start the stream as soon as the page loads.
The playsinline
attribute prevents the video from being played in fullscreen mode on mobile devices.
Stopping a Stream
To stop an active session, use the stopStreaming
method. This will end the current session and release the audio and video elements.
Next Steps
Usage in Production
Before taking the next steps to release your persona to real users, learn the important considerations for using personas in production.
Was this page helpful?