API Reference Message Array Different Than Playground

When viewing the API reference it shows the following way to format the array:

 "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'

However, when viewing the code in Playground it shows:

"messages": [
    {
      "role": "system",
      "content": [
        {
          "type": "text",
          "text": "You are a helpful assistant."
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "hello there"
        }
      ]
    },

Both ways seem to work, but my question is, which one is the correct way, or does it not matter?

Hello @n_rose21 !

No problem! There are several ways to query the API with the language libraries (python, nodejs, etc).

It was not clear which “code or language” you are referencing, but here is an example with the current OpenAI module with updated python.

My question is:

1 - Did you test any of these codes before posting this topic on the forum?

2 - If and only IF you have tested and already validated, then:
2.1 - Which part does not make sense of the request?

1 Like

The second, with type:text, allows for multiple blocks of multimodal content. Consider:

  {
        role: "user",
        content: [
          { type: "text", text: "What's in this image?" },
          {
            type: "image_url",
            image_url: {
              "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
            },
          }
        ],
      },
2 Likes

Ok, thanks for clarifying.

Yes, I have tested both methods and they both work. I guess I was just confused as to why the Playground was using the multiple blocks format for just text.