Service not working
# support
s
I am trying to test a chatbot on our website but i am getting an invalid API response... I have double checked and it is the correct public key : error: index.js:39 POST https://api.vapi.ai/call/web 401 (Unauthorized) index.js:39 Response {data: null, error: {…}, type: 'cors', url: 'https://api.vapi.ai/call/web', redirected: false, …} data : null error : error : "Unauthorized" message : "Invalid Key. Hot tip, you may be using the private key instead of the public key, or vice versa." statusCode : 401 [[Prototype]] : Object constructor : ƒ Object() hasOwnProperty : ƒ hasOwnProperty() isPrototypeOf : ƒ isPrototypeOf() propertyIsEnumerable : ƒ propertyIsEnumerable() toLocaleString : ƒ toLocaleString() toString : ƒ toString() valueOf : ƒ valueOf() __defineGetter__ : ƒ __defineGetter__() __defineSetter__ : ƒ __defineSetter__() __lookupGetter__ : ƒ __lookupGetter__() __lookupSetter__ : ƒ __lookupSetter__() __proto__ : (...) get __proto__ : ƒ __proto__() set __proto__ : ƒ __proto__() body : (...) bodyUsed : true headers : Headers {} ok : false redirected : false status : 401 statusText : "" type : "cors" url : "https://api.vapi.ai/call/web" [[Prototype]] : Response
v
It looks like you're getting a 401 Unauthorized error because the Vapi Web SDK requires your public API key, not the private key or a JWT. Please double-check that you're initializing the SDK like this (with your actual public key from the [Vapi Dashboard](https://dashboard.vapi.ai/account)):
Copy code
js
import Vapi from '@vapi-ai/web';
const vapi = new Vapi('YOUR_PUBLIC_API_KEY');
vapi.start('YOUR_ASSISTANT_ID');
Make sure there are no extra spaces or typos in your key. If the issue persists, try regenerating your public key in the dashboard and updating it in your code. Source: - [Vapi Web SDK Documentation](https://docs.vapi.ai/sdk/web)
s
I am using the websnippet and it is correct... I also see issue in backed in dashboard.vapi.ai that it is not happy with apis
so seems issue is bigger
k
Your Vapi web SDK requires a public-scoped JWT not the raw public key, generate it server-side using your private key and pass it to the client for authentication.. https://docs.vapi.ai/customization/jwt-authentication