Skip to content

Conversation

i25959341
Copy link
Contributor

@i25959341 i25959341 commented Sep 12, 2025

Description

  • This PR add a plugin that works with Anam to provider AI avatar experience

Changes Made

  • add api.py for the api route with anam needed
  • add avatar.py for managing the session, and api calls with anam
  • add an example script that run the anam avatar

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included

Testing

  • Automated tests added/updated (if applicable) N/A
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes) N/A

Additional Notes


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

Copy link

changeset-bot bot commented Sep 12, 2025

🦋 Changeset detected

Latest commit: 3bbac7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@livekit/agents-plugin-anam Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Sep 12, 2025

CLA assistant check
All committers have signed the CLA.

@i25959341
Copy link
Contributor Author

image

@i25959341
Copy link
Contributor Author

i25959341 commented Sep 12, 2025

Transcription is not working for the agent, other than that I can have a converation with the avatar. Not sure if it s avatar plugin related

@Shubhrakanti
Copy link
Contributor

https://www.loom.com/share/e9179bd171f142498124ad4583f2f5c5

the only remaining issue is the agent transcription, @Shubhrakanti @toubatbrian

Ahh is this because you need timed string response support?

@i25959341
Copy link
Contributor Author

i25959341 commented Oct 6, 2025

timed string response support

Sorry @Shubhrakanti, can you expand on this a little bit? Is it related to something like elevenlab where they send words with timestamp for transcription sync on the agents side? So i need to swap to use a tts, sst rather than a real time model?

@i25959341
Copy link
Contributor Author

i25959341 commented Oct 6, 2025

I remember this is an existing issue on python side as well

i have turn this syncTranscription off for now and we have the agent transcription now - this seems to suggest that we can not sync transciption with the audio

await session.start({ agent, room: ctx.room, outputOptions: { syncTranscription: false, }, });

@Shubhrakanti
Copy link
Contributor

I'm super sorry this actually shouldn't affect the avatar side. What's the issue you're having with transcriptions?

@Shubhrakanti
Copy link
Contributor

Oh I see from the look your not seeing the transcripts at all. @toubatbrian can you take a look? Might be an issue with DataStreamAOutput

@i25959341
Copy link
Contributor Author

i25959341 commented Oct 7, 2025

I remember that Anam only send Audio and Video frame back into the room but no transcription that goes with the Audio frame

https://github.com/livekit/agents/blob/main/examples/avatar_agents/audio_wave/avatar_runner.py#L77 - example implementation

@Shubhrakanti
Copy link
Contributor

Interesting.... @toubatbrian can you take a look?

@toubatbrian
Copy link
Contributor

Hey @i25959341 I'm trying to test your avatar plugin with my own API key but keep getting error

[02:03:36.210] ERROR (22281): Anam /v1/auth/session-token failed: 401 {"error":"Invalid API key"}
    jobID: "AJ_n3NavqiRdM36"
    err: {
      "type": "AnamException",
      "message": "Anam /v1/auth/session-token failed: 401 {\"error\":\"Invalid API key\"}",
      "stack":
          Error: Anam /v1/auth/session-token failed: 401 {"error":"Invalid API key"}
              at AnamAPI.postWithHeaders (file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/plugins/anam/dist/api.js:73:17)
              at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
              at async AvatarSession.start (file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/plugins/anam/dist/avatar.js:63:30)
              at async entry (file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/examples/src/anam_realtime_agent.ts:69:5)
              at async file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/agents/dist/ipc/job_proc_lazy_main.js:72:5

I tried creating multiple keys but getting the same result. Anything that I might be missing for my account?

@toubatbrian
Copy link
Contributor

For your reference, here's the email I used to create anam account [email protected]

@i25959341
Copy link
Contributor Author

i25959341 commented Oct 7, 2025

i think I have set

export ANAM_AVATAR_ID=
export ANAM_API_KEY=

ANAM_API_KEY should be the one that you are copying from the site

ANAM_AVATAR_ID, you can get one from here - https://docs.anam.ai/resources/avatar-gallery

This is gabriel for example, 6cc28442-cccd-42a8-b6e4-24b7210a09c5

@i25959341
Copy link
Contributor Author

@toubatbrian it is okay?

@toubatbrian
Copy link
Contributor

toubatbrian commented Oct 7, 2025

I have this exact setup:

Brians-MacBook-Pro agents-js-anam % echo $ANAM_API_KEY && echo $ANAM_AVATAR_ID
MmI0Y2*****09sRzQ9
6cc28442-cccd-42a8-b6e4-24b7210a09c5

but still producing above error, not sure why. I also tested the same env vars with python agent and getting the same error

@toubatbrian
Copy link
Contributor

toubatbrian commented Oct 7, 2025

Yes, Here's a more complete error log:

[02:22:49.411] ERROR (40089): Anam API request failed                                                                                              
    module: "AnamAPI"
    url: "https://api.anam.ai/v1/auth/session-token"
    method: "POST"
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer ****"
    }
    body: {
      "personaConfig": {
        "type": "ephemeral",
        "name": "Agent",
        "avatarId": "6cc28442-cccd-42a8-b6e4-24b7210a09c5",
        "llmId": "CUSTOMER_CLIENT_V1"
      },
      "environment": {
        "livekitUrl": "wss://dev-****.livekit.cloud",
        "livekitToken": "****"
      }
    }
    status: 401
    response: "{\"error\":\"Invalid API key\"}"
[02:22:49.411] ERROR (40089): Anam /v1/auth/session-token failed: 401 {"error":"Invalid API key"}
    jobID: "AJ_6XPC9qh7vHHo"
    err: {
      "type": "AnamException",
      "message": "Anam /v1/auth/session-token failed: 401 {\"error\":\"Invalid API key\"}",
      "stack":
          Error: Anam /v1/auth/session-token failed: 401 {"error":"Invalid API key"}
              at AnamAPI.postWithHeaders (file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/plugins/anam/dist/api.js:73:17)
              at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
              at async AvatarSession.start (file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/plugins/anam/dist/avatar.js:63:30)
              at async entry (file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/examples/src/anam_realtime_agent.ts:69:5)
              at async file:///Users/toubatbrian/Documents/GitHub/agents-js-anam/agents/dist/ipc/job_proc_lazy_main.js:72:5
    }

@i25959341
Copy link
Contributor Author

let me get back to you in 30 minutes

@toubatbrian
Copy link
Contributor

Thanks, @i25959341 ! I'm heading to sleep now as I'm in Asia timezone, and will be back in about 7 hours. I'll be focusing on a fix for it first thing tomorrow.

@toubatbrian
Copy link
Contributor

toubatbrian commented Oct 8, 2025

Hi @i25959341, from my end I can see exact transcripts coming as agent and avatar are speaking: Screenshot 2025-10-08 at 3 03 54 PM. Is this not the case on your end? (I'm running the anam_realtime_agent.ts from this branch.

@i25959341
Copy link
Contributor Author

i25959341 commented Oct 8, 2025

yes, it is working now as i have just made add the below option in the agent script

outputOptions: { syncTranscription: false, }

Sorry that I did not make this clear earlier @toubatbrian

if you are happy with this PR, maybe we can proceed to fix the nits and merge this PR?

@toubatbrian
Copy link
Contributor

@Shubhrakanti We might need to look into potential bugs related to syncTranscription and TranscriptionSynchronizer. However, since that's a separate issue, I think it's fine to go ahead and merge the avatar PR for now. I'll create a ticket to track the fix.

Copy link
Contributor

@toubatbrian toubatbrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! For now, let's add a comment in anam_realtime_agent.ts to remind users to set syncTranscription to false. We'll work on a proper fix for it later.

@i25959341
Copy link
Contributor Author

@toubatbrian added the comment

@toubatbrian toubatbrian merged commit dcfa03f into livekit:main Oct 8, 2025
5 checks passed
@github-actions github-actions bot mentioned this pull request Oct 8, 2025
@Shubhrakanti
Copy link
Contributor

LGTM! For now, let's add a comment in anam_realtime_agent.ts to remind users to set syncTranscription to false. We'll work on a proper fix for it later.

@toubatbrian can you link this PR in the ticket?

@toubatbrian
Copy link
Contributor

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants