AI Help
How do I run a long AI request in the background without keeping the connection open?
Use background mode on a supported Responses request and persist its response ID so another worker can check the result.
Steps to follow
- Confirm that background mode supports the model and your retention requirements. Check its documented storage behavior.
- Create the request with the background option and store the returned ID and job association.
- Poll or use supported completion events until the response reaches a terminal state. Handle failed, cancelled and incomplete results.
Example in practice
Illustrative example. A long report job can return a job reference to the interface while a worker later retrieves the completed response.
Related AI help
- When should I use the Batch API for an AI workload?
- How do I use webhooks to find out when a background AI response is ready?