Jquery AJAX function returning all answers, but not com

This is my jquery code. I want to have a completion

let pop = {
“prompt”: “Write 5 convincing reasons about the subject: why candies are bad”,
“max_tokens”: 90,
“temperature”: 1,
“top_p”: 1,
“n”: 1,
“stream”: false,
“logprobs”: null,
“stop”: “\n”

url: “https://api.openai.com/v1/engines/text-davinci-001/completions”,
method: “POST”,
contentType: “application/json”,
beforeSend: function(xhr) {
xhr.setRequestHeader(“Authorization”, “Bearer ssxssxcted”)
data: JSON.stringify(pop),
success: function(x){
//process the JSON data etc

@visitwritersco, welcome to the OpenAI community!

Can you elaborate more on the problem that you are having? I’m unsure what you mean when you say that it is returning all answers but not completion. Do you mean that you would like to have the prompt included with the completion as well?

If so, then you’ll need to add "echo":true, to the variable pop. Here’s a quote directly from OpenAI’s documentation on the echo parameter:

Echo back the prompt in addition to the completion

If that’s not what you mean, however, then please explain in further detail in order for me to understand the problem you are having so I can assist you!


Thank you so much this has helped me :slight_smile:

1 Like