400 Error during API Call

I am probably missing something very basic here and would appreciate inputs. I would like to pass message to GPT-3.5 model as parameter and constructing the message dynamically as follows (in node.JS)

build_prompt should have the following {“role”: “system”, “content”: “You are a helpful assistant.”},{“role”: “user”, “content”:“what is moon”},

CODE:
let build_prompt = “{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content":”;
build_prompt = build_prompt + “"what is moon"},”;

const response = await openai.createChatCompletion({
  model: "gpt-3.5-turbo-0301",
  messages:[
		build_prompt
  ],
});

console.log("****************RESPONSE FROM OPENAI**************");
console.log(response.data.choices[0].message.content);

I havent developed using node previously - I feel I am messing up passing prameter- appreciate input. Thank you

Your “build_prompt” variable returns a string, but the requirement for the chat API completion param is JSON array.

:slight_smile: