#Getting Post 401 error when trying to make an API call.
7 messages · Page 1 of 1 (latest)
It looks like you’re using the wrong API endpoint, the /engines/davinci.. endpoint doesn’t exist anymore, it’s now https://api.openai.com/v1/completions
appreciate the help. The link you sent is sending me a JSON error message in the browser??
Yeah, you need to set the API key and etc, that link is the link for the actual API endpoint
realized that right after I sent the message lol. For some reason still getting 401..
I've created a new api key and loaded it into my .env file. I then pass this into the fetch: fetch(https://api.openai.com/v1/completions, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': Bearer ${process.env.API_KEY},
If you print out process.env.API_KEY, does it show the correct key?