Cancelling Openai api's request

i have implemented openai’s api to my application.Now, i want to set if response time is more than x sec
( i consider 10 seconds) i want to cancel that request and my balance not be charged for incomplete requests.How can i achieve that?(I am using spring boot for my application)

Before answer this question, I think should know something first. Are you using completion API or fine-tuning API?

I am using completion API instead of fine-tuning API

If you are using completion API, I think to kill request that been sent is unavailable. But if fine-tuning API, you can kill the job before been trained.

I would like to cancel requests too, to retry. My requests keep hanging with no feedback, then 10 minutes later one request goes through. Not sure what is happening yet.