API_KEY Problem
I am making a chat bot with ChatGpt, but i am getting an error where it tells me that i did not provide an API KEY but i did, i cant seem to find a solution or where did i go wrong in my code, so anything helps, thank you
9 Replies
Line 23. it should be
headers
not header
Still gives the same error message
Well that shouldn't happen. Try refreshing, restarting server etc?
yea tried all that, i am confused as hell xDDD
why don't you use the openai npm package?
https://platform.openai.com/docs/api-reference/introduction
Wait are you trying to access that page directly lol? Like you typed URL in your browser?
I don't get why are you getting error message like that
he is, i just noticed that now
Yeah well @lajkmi. you cannot access it like that. You have to fetch it like you already did and then log data to the console
Also not sure if you put your API_KEY there just for demo/debugging purposes but just in case I'll warn you not to do that since everyone will be able to access it. Instead you should create ".env" file where you will store it something like this:
And then access it through that
API_KEY
variableYea i fixed it thank you for the input 🙂