Skip to main content

Deprecate brainType in favor of llmId

Important Update: The brainType parameter has been deprecated and replaced with llmId to support custom language models. Your existing brainType values will continue to work as llmId for backwards compatibility.

What This Means For You

If you currently use brainType in your persona configuration, you should update your code to use llmId instead. This change enables support for custom language models while maintaining compatibility with existing brain types. This change allows you to:
  • Create and use your own language models with Anam personas
  • Process custom LLMs from Anam’s servers for lower latency
  • Store API keys for custom LLMs encrypted at rest
  • Continue using existing brain types as LLM IDs without code changes

Migration Steps

Replace brainType with llmId in your persona configuration:
const response = await fetch("https://api.anam.ai/v1/auth/session-token", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${ANAM_API_KEY}`,
  },
  body: JSON.stringify({
    personaConfig: {
      avatarId: "30fa96d0-26c4-4e55-94a0-517025942e18",
      voiceId: "6bfbe25a-979d-40f3-a92b-5394170af54b",
-     brainType: "0934d97d-0c3a-4f33-91b0-5e136a0ef466",
+     llmId: "0934d97d-0c3a-4f33-91b0-5e136a0ef466",
      systemPrompt: "You are a helpful assistant.",
    },
  }),
});

Available LLM IDs

All existing brain types continue to work as LLM IDs:
Previous brainTypeNew llmIdDescription
0934d97d-0c3a-4f33-91b0-5e136a0ef4660934d97d-0c3a-4f33-91b0-5e136a0ef466OpenAI GPT-4 Mini model
ANAM_LLAMA_v3_3_70B_V1ANAM_LLAMA_v3_3_70B_V1Llama 3.3 70B model
CUSTOMER_CLIENT_V1CUSTOMER_CLIENT_V1Client-side LLM processing

Custom LLMs

With this change, you can now create custom LLMs and use them with your personas. Learn more about Custom LLMs.

Deprecate GET /session-token

Important Update: Declaring persona configuration on the client side is deprecated and has been removed in the latest version of the Anam SDK. You should follow the instructions below to migrate to the new POST /session-token endpoint and pass the persona config in the request body.

What This Means For You

If you currently use the GET /session-token endpoint, you need to update your code to use the POST endpoint and pass your persona config in the request body. This means you will need to move your persona configuration from your client side to your server side. This change allows you to:
  • Define persona config entirely at runtime
  • Keep your Anam config (persona ID, system prompt) hidden from the client
  • Reduce connection start times

Implementation Recommendations

  1. Upgrade to the latest version of the Anam SDK.
  2. If you currently make a GET request to /session-token, update this to a POST request and pass the personaConfig in the request body. This request must be made from your server, so you may need to pass details from your client to your server if you are creating your system prompt dynamically.
  3. Update your client side to use the session token only: createClient(sessionToken). You can still pass client options such as disableInputAudio: createClient(sessionToken, { disableInputAudio: true }).
For more information on creating sessions, see Authentication.

Example migration

The old way (deprecated):
// Server side - GET request (no longer supported)
const response = await fetch("https://api.anam.ai/v1/auth/session-token", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${ANAM_API_KEY}`,
  },
});
const { sessionToken } = await response.json();
return sessionToken;

// Client side - legacy tokens are no longer supported
// The SDK will throw an error: "Legacy session tokens are no longer supported"
The new way:
// On the server side
const response = await fetch("https://api.anam.ai/v1/auth/session-token", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${ANAM_API_KEY}`,
  },
  body: JSON.stringify({
    personaConfig: {
      personaId: "<YOUR_PERSONA_ID>",
    },
  }),
});

const { sessionToken } = await response.json();
return sessionToken;

// On the client side
const anamClient = createClient(sessionToken);

Error Handling

If you attempt to use a legacy session token with the current SDK, you will see this error:
Legacy session tokens are no longer supported. Please define your persona when 
creating your session token. See https://docs.anam.ai/resources/migrating-legacy 
for more information.
To resolve this error, ensure you are:
  1. Using the POST /session-token endpoint
  2. Including your personaConfig in the request body
  3. Using only the session token on the client side (not passing personaConfig to createClient)
For more in depth examples of how to define your persona config at runtime see our full implementation example.