How to insert insight from an external APIs into a conversation using the ChatGPT API?

Hi, I’m trying to implement some ideas I have with the ChatGPT API and I got into a doubt that does not let me continue. Perhaps people in this forum can give me some insight.

I’m creating some sort of chatbot where the user can ask about specific issues ChatGPT does not need to know. My idea is that in these cases ChatGPT will generate an API call, the response will be incorporated in the context (all this without the user knowing what’s going on behind the table), and ChatGPT will develop a sensible response based on this. This is obviously how official ChatGPT plugins work.

But I’d like to make it work in my application, not as an official plugin. My doubt is, how do I insert the response of the API in the context, given that only two roles, “user” and “assistant” are available. Ideally I’d need a third role “api response”. I tried putting the api response in the “assistant” role, but it tends to confuse ChatGPT and it sometimes hallucinates the API responses too, which is misleading for the user.

This must be a simple issue, but I could not find anything useful online, as the web is overpopulated with countless identical tutorials with the basic stuff. Also the documentation of openai does not seem to help much.

Thanks for any insight!