**API key gets handled above ( code is too long so redacted**
document.addEventListener("keydown", function (event) {
if (event.ctrlKey && event.shiftKey && event.keyCode === 75) {
const activeElement = document.activeElement;
const isContentEditable = activeElement.isContentEditable;
const isInputField = activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement;
const textValue = isContentEditable ? activeElement.textContent : activeElement.value;
if (textValue.includes("::")) {
const promptText = textValue.substring(textValue.indexOf("::") + 2).trim();
const apiURL = "https://api.openai.com/v1/engines/davinci-3-5-turbo/completions";
const model = "gpt-3-5-turbo";
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer " + apiKey,
};
const data = {
prompt: promptText,
max_tokens: 128,
temperature: 0.7,
};
console.log("Detected keyboard combo");
console.log("Sending API request with prompt:", promptText);
fetch(apiURL, {
method: "POST",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => {
const generatedText = data.choices[0].text.trim();
const newTextValue = textValue.replace("::" + promptText, generatedText);
if (isContentEditable) {
activeElement.textContent = newTextValue;
} else {
activeElement.value = newTextValue;
activeElement.dispatchEvent(new Event("input", { bubbles: true }));
}
console.log("API response received:", generatedText);
})
.catch((error) => console.log(error));
}
}
});
});```
#GPT-3.5-turbo end point error 404
8 messages · Page 1 of 1 (latest)
your apiUrl is wrong
What apiURl do you suggest, since I get errors no matter which url I use for turbo 3.5
did you check the thread link above? Engines are deprecated and you're calling the wrong endpoint. For 3.5 you need to use chat/completions. I've given all links above
The link above is #unknown on mobile
Will check on PC later I guess
this is for gpt-3: https://platform.openai.com/docs/api-reference/completions/create
and this for 3.5 & gpt-4:https://platform.openai.com/docs/api-reference/chat/create
let me know if that solves your 404 error
An API for accessing new AI models developed by OpenAI
An API for accessing new AI models developed by OpenAI