Discussions
Assistance with 401 Unauthorized Error During Streaming Avatar Integration (Free Plan)
We are using the HeyGen API Free Plan to test our integration with the 10 free credits provided. The goal is to dynamically interact with the avatar June_HR_public using the HeyGen Streaming SDK. The integration involves streaming tokenized text responses from OpenAI (via Buildship) to the HeyGen avatar for real-time speech.
Current Implementation:
We are calling the https://api.heygen.com/v1/streaming.create_token endpoint to generate a session token for the avatar.
The request includes:
{
"avatar_id": "June_HR_public"
}
with the appropriate Authorization: Bearer <API_KEY> header.
We initialize the avatar in an HTML div container using the HeyGen SDK (@heygen/[email protected]).
Issue:
The token request consistently fails with a 401 Unauthorized error, despite the following checks:
The avatar_id (June_HR_public) is active, public, and confirmed to be correct.
The API key is valid and configured in the SDK initialization.
What We Need:
Confirmation that the streaming.create_token endpoint is accessible with the Free Plan API key.
Any insights into why a 401 error might occur despite having a valid avatar and API key.
Guidance on whether additional permissions or configurations are needed to use the streaming.create_token endpoint with the Free Plan.
Debugging Steps Taken:
Verified the API request using both fetch and curl.
Confirmed the avatar’s status as ACTIVE and is_public: true.
Checked API key correctness and header structure.
Additional Information:
We are testing the integration on a custom WordPress page with the HeyGen SDK and dynamic streaming from OpenAI. Any insights or suggestions to resolve the token issue would be greatly appreciated.
Thank you