-
Notifications
You must be signed in to change notification settings - Fork 87
Error: Uncaught (in promise) Error: Request failed with status code 401 #67
Copy link
Copy link
Open
Description
Reproduce
-
Generate the key from the OpenAPI.
-
Installation
npm install openai-api
- Copy/past the example in my NextJS component ( Button )
const sendRequest = async (event: React.MouseEvent<HTMLImageElement>) => {
const request = {
title: prompt,
output: 'Done',
};
setRequests(request);
const gptResponse = await openai.complete({
engine: 'davinci',
prompt: 'this is a test',
maxTokens: 5,
temperature: 0.9,
topP: 1,
presencePenalty: 0,
frequencyPenalty: 0,
bestOf: 1,
n: 1,
stream: false,
stop: ['\n', 'testing'],
});
console.log(gptResponse.data);
};
Expected
Print the result
Current
createError.js?6b1b:16 Uncaught (in promise) Error: Request failed with status code 401
at createError (webpack-internal:///(:3000/app-client)/./node_modules/openai-api/node_modules/axios/lib/core/createError.js:16:15)
at settle (webpack-internal:///(:3000/app-client)/./node_modules/openai-api/node_modules/axios/lib/core/settle.js:17:12)
at XMLHttpRequest.onloadend (webpack-internal:///(:3000/app-client)/./node_modules/openai-api/node_modules/axios/lib/adapters/xhr.js:54:7)
Screenshot
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
