I am using API to request some data from openAI
This is my url code
const response = await axios.post('https://api.openai.com/v1/chat/completions', data, { headers: headers });
This is my data, in header I am sending my apiKey
const data = {
model: "gpt-3.5-turbo-1106",
response_format: { type: "json_object" },
messages: messages,
tools: functions6,
tool_choice: "auto"
};
This is my response from openAPI
{
id: 'chatcmpl-8wRDZcadfAAV2W3riPote5dvBBK',
object: 'chat.completion',
created: 17089383341,
model: 'gpt-3.5-turbo-1106',
choices: [
{
index: 0,
message: [Object],
logprobs: null,
finish_reason: 'tool_calls'
}
],
usage: { prompt_tokens: 337, completion_tokens: 297, total_tokens: 634 },
system_fingerprint: 'fp_406bAFe318f3'
}
Why I am getting the response message: [Object],
It should be a JSON text but it gives me a Object
I am trying to parse in this way
if (response.data && response.data.choices && response.data.choices[0] && response.data.choices[0].message) { }
and it gives an unknown error