Chat gpt message issue


I am trying to build an AI chat bot that can help answer questions or help identify information from documents uploaded as vectors into the Retool tool.

The chat bot has been built and its been tested with Retool AI but now I wanted to integrate Retool with my ChatGPT account, but having trouble with what to add in the "message" section of the Request Body.

Keep getting errors like:
"error": {
"message": "Invalid type for 'messages': expected an array of objects, but got an object instead.",
"type": "invalid_request_error",
"param": "messages",
"code": "invalid_type"

I have changed the message to accommodate but still getting similar error messages.
One of the messages tried but failed:
"model": "gpt-4o",
"messages": [
"role": "user",
"content": "Can you help me understand a range of topics as an AI tutor?"
"temperature": "0.5"

Hi there! Welcome to the Retool Community Forum :slight_smile:
Looks like you are getting an error that is saying the type for the messages section is invalid.

From the looks of your screenshot, it seems like you are containing everything in an object for the messages parameter but it is expecting an Array. More specifically, an Array of objects themselves like the example below.

      "role": "user",            
      "content": "Can you help me understand a range of topics as an AI tutor?"     

try changing the type from an object to an array. Currently you have everything wrapped in an object.
Please let me know if you have any other questions. :slight_smile:

Hi Diego,

Thank you for helping out a novice :slight_smile:

It seemed to have done the trick. So appreciate your help.

However I have a couple more steps to do in order to make it work as intended.

I need to first link the vectors I uploaded and link them to this app. With Retool AI I had the option to select them from the query. But I dont get that when trying to use Open AI as my resource. What can I do to link my vectors to this chat app and ensure the chat only refers to the vectors for is sources of information.

Secondly, it looks like I am not getting the output required. Asking the chat a question gives me the loading icon but no response to the question. How can I ensure the chat app gives me the answers to my questions, Please refer to the output and screenshots below for context.

Thanks again for your help



"id": "chatcmpl-9ZzuboYqmF3ZSBbOA2woDDBqQyi96",
"object": "chat.completion",
"created": 1718366497,
"model": "gpt-4o-2024-05-13",
"choices": [
"index": 0,
"message": {
"role": "assistant",
"content": "Absolutely, I'd be happy to help you with a range of topics! Whether you're looking to dive into academic subjects like math, science, history, or literature; need assistance with technology, programming, or data analysis; or are interested in practical skills like writing, public speaking, or business strategies, I'm here to assist. Just let me know what specific topics or areas you need help with, and we can get started!"
"logprobs": null,
"finish_reason": "stop"
"usage": {
"prompt_tokens": 21,
"completion_tokens": 84,
"total_tokens": 105
"system_fingerprint": "fp_319be4768e"

Annotation 2024-06-14 130434

i just tried and got the same results as you. i found this though:

so it looks like you have to use the query it auto generates when you add the chat component. i tried removing that, so no query would be triggered, then setting an event handler for onSubmit to trigger a query and same results. it looks like the query it auto adds has some built in functionality linked directly to the chat component. eventhough the response is recieved the component doesn't know it. since it uses streaming, I'd go out on a limb and guess whatever tells the component the stream is done isn't being triggered

Thanks for your input bobthebear. Appreciate your assistance. Yeah its a very strange one. I seem to be getting the content in the Output but doesn't seem to populate the answers in the chat, when question raised.