Response Id when Stream=True for background tasks

I’m trying to take a custom made assistant into production using the responses API. The flow I’m using goes as follows:

  1. Make a request to an API endpoint on AWS API Gateway with lambda that takes several inputs for creating the response in object , which is run with the background=True flag.
  2. If successfully, the api request returns the response Id.
  3. Then, the flow enters into a while loop which consists on successive calls to another lambda api endpoint using the response id obtained from the previous step with the aim of verifying wether the response status has been set as complete (using responses.retrieve). If so, the API call returns the full answer to be shown at the frontend of my chatbot app.

I read that background tasks are compatible with streaming, but as of now, it’s been imposible to retrieve the response id, when the stream is set to True at the response object creation.

Is there a way to pull this off? I’d really want to avoid more complex solutions (such as web sockets or getting the agent deployed on fargate ), because I really appreciate both the simplicity of lambda, and the level of control that the responses API provides over the agent’s behavior.

Thanks so much in advance.

1 Like