Imagine GPT 3.5/4 being a sort of black boxes. If you use them via API keys, you are just using their LLM service and they do not store inputs / outputs in any database. (https://openai.com/enterprise-privacy#our-commitments)
But if you use there interface of ChatGPT, they store both inputs as well as outputs and use it to train their models.
For API calls they only will look at if any government entity asks them to do so. And that too for only last 30 days. Please correct me if I am wrong and point me to the exact place where they mention it.
"We do not train on your data from ChatGPT Enterprise or our API Platform"
This is exact sentence from their privacy policy page.