Connecting to GPTs through API (again)

This question was asked before, but the answers were not very satisfactory as the OP was also asking about web browsing, so lets try again…

I created some GPTs with specialized knowledge, and overall I feel that they work really nicely. Whatever RAG system sits behind GPTs mostly does an incredible job in my view.

So now I want to consume those GPTs programmatically not just through the web based chat interface, but make API calls to them.

Is there a way to do this? Or if not, is there some equivalent API based system that I could migrate to that would let me work in a similar way, particularly the ability to upload some data files for it to RAG on?