OpenAI API chat history - how to limit api calls and the chat memory?

Hi community,

I am building a chatbot with OpenAI API integration. I am trying to understand how api calls work and how I can restrict the prompts sent to OpenAI with just one conversation. It feels like the API call remembers the whole history so it may be easy to overcome the token limitations and come across other problems with the core app’s functionality.
Is there a way to limit the “history” sent to OpenAI by a certain amount of last messages? Or in a perfect world by the messages created in this conversation (conversation = custom state)?

I thought of adding constraint to an API call’s search for messages, but cannot come up with the right scenario.

Will appreciate any thoughts on this!

Search for messages: items from #(search for messages:count - [maxmimum permitted number of messages)


Thank you so much, @georgecollier !
But how do I keep both conditions? count and field type ("each item’s json join with , ")