I am Trying to populate a Google sheet with companies missions values products and services in separate columns using chat gpt i’ve created below function using chatgpt to populate the data once I populate the name of a company in the first column. Keep getting 400 or 404 error.
The error states "Exception: Request failed for URL returned code 404. Truncated server response: { “error”: { “type”: “invalid_request_error”, “code”: “unknown_url”, “message”: “Unknown request URL: POST /gpt-3.5-turbo-instruct/co… (use muteHttpExceptions option to examine full response) (line 19).”
function askChatGPT(prompt) {
var apiKey = ‘my_key’;
var apiURL = ‘URL ';
var payload = {
“prompt”: prompt,
“max_tokens”: 150
};
var options = {
“method”: “post”,
“contentType”: “application/json”,
“payload”: JSON.stringify(payload),
“headers”: {
“Authorization”: "Bearer " + apiKey
}
};
var response = UrlFetchApp.fetch(apiURL, options);
var responseJson = JSON.parse(response.getContentText());
return responseJson.choices[0].text.trim();
}