Nattsurfaren
Power Member
- Apr 12, 2010
- 593
- 82
It worked yesterday but now it just returns false.
// Your pre-defined message
const predefinedMessage = `This is a test to see if I'm gay`;
// Function to send the message
function sendMessage(inputText) {
const messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": inputText}
];
let secondsElapsed = 0;
const intervalId = setInterval(() => {
document.body.innerHTML = `Busy... ${++secondsElapsed} Seconds elapsed`;
}, 1000);
fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YouFingAPIKey' // Replace YouFingAPIKey with your actual API key
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
messages: messages,
max_tokens: 200
})
})
.then(response => {
clearInterval(intervalId); // Stop the "Busy..." message
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => {
const message = data.choices[0].message;
document.body.innerHTML = ''; // Clear the "Busy..." message
document.write(message.content.replace(/\n/g, '<br>')); // Handles newlines for HTML
})
.catch(error => {
clearInterval(intervalId); // Stop the "Busy..." message
document.body.innerHTML = ''; // Clear the "Busy..." message
document.write(`Error: ${error.message}`);
});
}
// Send the predefined message immediately on load
sendMessage(predefinedMessage);
Well I've not been able to make any requests at all. This day and previous day.Are u in paid plan ? The free plan 3 request per min only
If you'd had no problem running the javascript then it doesn't matter if they changed the API access. I mean I have $ credits left and I've created a new key. I've tested different endpoints and different token limits. So what the heck could it be.Yes OpenAI is ever evolving, recently they made changes to their API access. Though you'll have to look closely into your issue which is relative to you.
Did u add billing / credit card info into ur account ? Regardless u have account with credit or not .. it require to add credit card info since 15-11-2023If you'd had no problem running the javascript then it doesn't matter if they changed the API access. I mean I have $ credits left and I've created a new key. I've tested different endpoints and different token limits. So what the heck could it be.
I'm not an expert javascript developer but I've been programming for many years so I understand code and with chatgpt chat (not the api) I can figure out everything. I don't need fiverr when I have chatgpt. If there is nothing wrong with my code then it boils down to a different computer on a different IP. This is why I need your help testing the javascript. Then I can narrow the problem down in a big way. So it is a big help if anyone can test it.If you can't find a solution, you'll have to pay a developer to help you out. In that case, you could use Fiverr or Upwork.I
Yes I have king masterDid u add billing / credit card info into ur account ? Regardless u have account with credit or not .. it require to add credit card info since 15-11-2023