Open Ai source ChatGPT API undefined response

Hello Thunkable Support Team, hope this message finds you in good spirits !
I’m encountering an issue with the OpenAI service integration in my Thunkable app where I consistently receive an ‘undefined’ response when attempting to retrieve data.

Could you please help me understand what might be causing this issue and how to fix it?

Thank you for your assistance!

Best regards.

1 Like

Welcome to the Community!
I Recommend using OpenAI through their Web API.
Please Check your API Keys whether it is Operational or not.


Want to hire a Certified Thunkable Expert? Whoocoder | Thunkable Expert | Hire Now On Fiver!!

2 Likes


i tried this but it shows me a blue screen

1 Like

Your API Request is Incorrect
Try These:

1 Like

I’m really sorry for bothering you. I still have the same result


1 Like

A blue screen / crash usually means that the property you’re attempting to get is invalid. For example, if the property name was “brand” and you tried to get “brain”.

But I don’t see anything like that in your blocks. Can you post a link to the project?

The one thing I notice different about your blocks vs. @whoocoder’s is that you created an object with the field “content” but @whoocoder created an object with the field “messages”. So you might try fixing that.

1 Like

I attempted to replicate the screen in a new test project but encountered the same results. Here’s the link to the project for your reference:
https://x.thunkable.com/projects/662d4da9a0ae23616dde11f7/6fbc182f-8c79-4e76-8715-3be09cdf815f/blocks
Thanks a lot for your help.

I sought assistance from the Thunkable Assistant (ChatGPT-4), and they provided me with this code.

While it no longer results in a ‘blue’ screen, It shows now the error alert.

You should always connect the green ‘error’ block to your label’s text so you can see the actual error rather than just “ERROR”.

What exact error is it giving you?

1 Like

“Failed to execute ‘fetch’ on ‘Window’: Failed to read the ‘headers’ property from ‘RequestInit’: The object must have a callable @@iterator property.”

You shouldn’t use that Hearder Objects blocks inside a List Block,
As @tatiang said, in my code, you named that one body object to content, instead of message, it is a lost of conversation, please fix it and name it as messages, and as @tatiang said to add error conditions, it is important debugging your project as it provides info about what exact issue is happening.
If same problem is persisting, you continue or ask from thunkable staff like @ioannis and @matt_conroy

I followed all your instructions, including naming the field “messages” and connecting the ‘error’ output to the label. However, the issue persists. The specific error encountered is: “Failed to execute ‘fetch’ on ‘Window’: Failed to read the ‘headers’ property from ‘RequestInit’: The object must have a callable @@iterator property.”

When you initialize variables like chat history which are in list, you have to set the value to empty list while initialisation.
Same goes with question, you have to set it’s value to a empty string while initialisation.
Also, please check in your device through live test.

After these adjustment, it shows me now “null”
I tried to check in my device through live test and same issue.

Can you send me Current Blocks you Are Using

:grimacing::grimacing:
Brother why did you Put the Value of Content to that API Body Variable??
You have to Insert the Prompt there!

I apologize for the confusion regarding the API body setup. The “prompt” field is designed to contain the question or statement you want the API to respond to. Here, the prompt is formulated by joining the text input from the user with your specific question, ensuring that the AI understands the context and provides the relevant information. I used the join block to assemble this query based on user input to make the prompt context-specific. If there’s a different requirement or format expected for the prompt, please let me know so I can adjust it. Thanks a lot

1 Like

I would recommend you First use the Blocks I gave you, they are basic, then if the worked and if you want you can Modify them according to your needs.

That’s exactly what I did. Like I mentioned earlier, I ended up with a blue screen after sending the request. I realized that the main issue in the code you provided was specifically the “in list chat-history insert at last as” part.