curl --request POST \
--url https://api.anam.ai/v1/auth/session-token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"personaConfig": {
"name": "Cara",
"avatarId": "071b0286-4cce-4808-bee2-e642f1062de3",
"voiceId": "de23e340-1416-4dd8-977d-065a7ca11697",
"llmId": "a7cf662c-2ace-4de1-a21e-ef0fbf144bb7",
"systemPrompt": "You are a helpful assistant."
}
}
'import requests
url = "https://api.anam.ai/v1/auth/session-token"
payload = { "personaConfig": {
"name": "Cara",
"avatarId": "071b0286-4cce-4808-bee2-e642f1062de3",
"voiceId": "de23e340-1416-4dd8-977d-065a7ca11697",
"llmId": "a7cf662c-2ace-4de1-a21e-ef0fbf144bb7",
"systemPrompt": "You are a helpful assistant."
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
personaConfig: {
name: 'Cara',
avatarId: '071b0286-4cce-4808-bee2-e642f1062de3',
voiceId: 'de23e340-1416-4dd8-977d-065a7ca11697',
llmId: 'a7cf662c-2ace-4de1-a21e-ef0fbf144bb7',
systemPrompt: 'You are a helpful assistant.'
}
})
};
fetch('https://api.anam.ai/v1/auth/session-token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.anam.ai/v1/auth/session-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'personaConfig' => [
'name' => 'Cara',
'avatarId' => '071b0286-4cce-4808-bee2-e642f1062de3',
'voiceId' => 'de23e340-1416-4dd8-977d-065a7ca11697',
'llmId' => 'a7cf662c-2ace-4de1-a21e-ef0fbf144bb7',
'systemPrompt' => 'You are a helpful assistant.'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.anam.ai/v1/auth/session-token"
payload := strings.NewReader("{\n \"personaConfig\": {\n \"name\": \"Cara\",\n \"avatarId\": \"071b0286-4cce-4808-bee2-e642f1062de3\",\n \"voiceId\": \"de23e340-1416-4dd8-977d-065a7ca11697\",\n \"llmId\": \"a7cf662c-2ace-4de1-a21e-ef0fbf144bb7\",\n \"systemPrompt\": \"You are a helpful assistant.\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.anam.ai/v1/auth/session-token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"personaConfig\": {\n \"name\": \"Cara\",\n \"avatarId\": \"071b0286-4cce-4808-bee2-e642f1062de3\",\n \"voiceId\": \"de23e340-1416-4dd8-977d-065a7ca11697\",\n \"llmId\": \"a7cf662c-2ace-4de1-a21e-ef0fbf144bb7\",\n \"systemPrompt\": \"You are a helpful assistant.\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.anam.ai/v1/auth/session-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"personaConfig\": {\n \"name\": \"Cara\",\n \"avatarId\": \"071b0286-4cce-4808-bee2-e642f1062de3\",\n \"voiceId\": \"de23e340-1416-4dd8-977d-065a7ca11697\",\n \"llmId\": \"a7cf662c-2ace-4de1-a21e-ef0fbf144bb7\",\n \"systemPrompt\": \"You are a helpful assistant.\"\n }\n}"
response = http.request(request)
puts response.read_body{
"sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAifQ.signature"
}create session token
Create a new session token used to initialise Anam client side SDKs
curl --request POST \
--url https://api.anam.ai/v1/auth/session-token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"personaConfig": {
"name": "Cara",
"avatarId": "071b0286-4cce-4808-bee2-e642f1062de3",
"voiceId": "de23e340-1416-4dd8-977d-065a7ca11697",
"llmId": "a7cf662c-2ace-4de1-a21e-ef0fbf144bb7",
"systemPrompt": "You are a helpful assistant."
}
}
'import requests
url = "https://api.anam.ai/v1/auth/session-token"
payload = { "personaConfig": {
"name": "Cara",
"avatarId": "071b0286-4cce-4808-bee2-e642f1062de3",
"voiceId": "de23e340-1416-4dd8-977d-065a7ca11697",
"llmId": "a7cf662c-2ace-4de1-a21e-ef0fbf144bb7",
"systemPrompt": "You are a helpful assistant."
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
personaConfig: {
name: 'Cara',
avatarId: '071b0286-4cce-4808-bee2-e642f1062de3',
voiceId: 'de23e340-1416-4dd8-977d-065a7ca11697',
llmId: 'a7cf662c-2ace-4de1-a21e-ef0fbf144bb7',
systemPrompt: 'You are a helpful assistant.'
}
})
};
fetch('https://api.anam.ai/v1/auth/session-token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.anam.ai/v1/auth/session-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'personaConfig' => [
'name' => 'Cara',
'avatarId' => '071b0286-4cce-4808-bee2-e642f1062de3',
'voiceId' => 'de23e340-1416-4dd8-977d-065a7ca11697',
'llmId' => 'a7cf662c-2ace-4de1-a21e-ef0fbf144bb7',
'systemPrompt' => 'You are a helpful assistant.'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.anam.ai/v1/auth/session-token"
payload := strings.NewReader("{\n \"personaConfig\": {\n \"name\": \"Cara\",\n \"avatarId\": \"071b0286-4cce-4808-bee2-e642f1062de3\",\n \"voiceId\": \"de23e340-1416-4dd8-977d-065a7ca11697\",\n \"llmId\": \"a7cf662c-2ace-4de1-a21e-ef0fbf144bb7\",\n \"systemPrompt\": \"You are a helpful assistant.\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.anam.ai/v1/auth/session-token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"personaConfig\": {\n \"name\": \"Cara\",\n \"avatarId\": \"071b0286-4cce-4808-bee2-e642f1062de3\",\n \"voiceId\": \"de23e340-1416-4dd8-977d-065a7ca11697\",\n \"llmId\": \"a7cf662c-2ace-4de1-a21e-ef0fbf144bb7\",\n \"systemPrompt\": \"You are a helpful assistant.\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.anam.ai/v1/auth/session-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"personaConfig\": {\n \"name\": \"Cara\",\n \"avatarId\": \"071b0286-4cce-4808-bee2-e642f1062de3\",\n \"voiceId\": \"de23e340-1416-4dd8-977d-065a7ca11697\",\n \"llmId\": \"a7cf662c-2ace-4de1-a21e-ef0fbf144bb7\",\n \"systemPrompt\": \"You are a helpful assistant.\"\n }\n}"
response = http.request(request)
puts response.read_body{
"sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAifQ.signature"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Configuration for the session to be created. Supply personaConfig.personaId to use a persona you've already created (stateful), or the set avatarId/voiceId/llmId/systemPrompt to configure the persona at run time (ephemeral).
The returned token is valid for one hour and bound to this exact config.
Server-side SDKs in a secure context can skip this exchange and start a session directly by calling POST /v1/engine/session with their API key and the same configuration in the request body.
Response
Successfully started session
Short-lived credential used by a client to connect to a live persona. Valid for one hour.
Signed JWT the client passes to the Anam SDK to open a WebRTC connection.
Was this page helpful?

