I am getting 500 internal server error while pushing back the whole conversation to the API

Hey there I am getting this error while pushing back the whole conversation to the Open AI’s API I am using nodejs as a programming language that mean I am using the openai npm package.

This is my code

const response = await openai.chat.completions.create({
        model: "gpt-4-vision-preview",
        messages: transformedArray,
        max_tokens: 3000,
  `Preformatted text`});

and this is my conversation body with the chat gpt

[
{ role: 'system', content: 'Chat GPT is a good bot!' }
{
  role: 'user',
  content: [
    { type: 'text', text: 'What is the capital of Denmark' },
    { type: 'image_url', image_url: null }
  ]
}
{ role: 'assistant', content: 'The capital of Denmark is Copenhagen.' }
]

Can anyone please help me here what I am doing wrong and how can I fix this error?

Hi! Welcome to the community!

why is image_url null? :thinking:

Because I am not sending any image back to the API @Diet

Consider taking the whole message out. I reproduced your error:

Error: 500 {
  "error": {
    "message": "The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our help center at help.openai.com if you keep seeing this error. (Please include the request ID ... in your email.)",
    "type": "server_error",
    "param": null,
    "code": null
  }
}

it doesn’t happen if you comment the image out:

[
  { role: 'system', content: 'Chat GPT is a good bot!' },
  {
    role: 'user',
    content: [
      { type: 'text', text: 'What is the capital of Denmark' },
      // { type: 'image_url', image_url: null }
    ]
  },
  { role: 'assistant', content: 'The capital of Denmark is Copenhagen.' }
]
1 Like