#GPT-3.5-turbo end point error 404

8 messages · Page 1 of 1 (latest)

light briar
#
**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));
      }
    }
  });
});```
honest sapphire
#

your apiUrl is wrong

light briar
honest sapphire
light briar
#

Will check on PC later I guess

honest sapphire