I am trying to use open ai api for chatGPT integration website project
but i got those errors:
1-POST https://api.openai.com/v1/chat/completions 404 (Not Found)
2-Uncaught (in promise) D {message: ‘Request failed with status code 404’, name: ‘AxiosError’, code: ‘ERR_BAD_REQUEST’, config: {…}, request: XMLHttpRequest, …}code: “ERR_BAD_REQUEST”config: {transitional: {…}, adapter: Array(2), transformRequest: Array(1), transformResponse: Array(1), timeout: 0, …}message: “Request failed with status code 404″name: “AxiosError”request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}response: {data: {…}, status: 404, statusText: ”, headers: i, config: {…}, …}stack: “AxiosError: Request failed with status code 404n at https://cdnjs.cloudflare.com/ajax/libs/axios/1.2.3/axios.min.js:1:21076n at XMLHttpRequest.d (https://cdnjs.cloudflare.com/ajax/libs/axios/1.2.3/axios.min.js:1:21221)”[[Prototype]]: Error
(anonymous) @ script.js:35
here is my post request
const response = await axios.post('https://api.openai.com/v1/chat/completions',{
model: "text-davinci-003",
messages: [
{
role: "user",
content: message
}
]
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
}