# CloudCode blocking OpenAI API streaming

**URL:** <https://community.parseplatform.org/t/cloudcode-blocking-openai-api-streaming/5065>\
**Category:** Parse Server 📡\
**Created:** [January 5, 2026, 11:04pm UTC](https://community.parseplatform.org/t/cloudcode-blocking-openai-api-streaming/5065 "2026-01-05T23:04:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leebert](https://community.parseplatform.org/user_avatar/community.parseplatform.org/leebert/32/2097_2.png) [@leebert](https://community.parseplatform.org/u/leebert)\
**Post date:** [January 5, 2026, 11:04pm UTC](https://community.parseplatform.org/t/cloudcode-blocking-openai-api-streaming/5065/1 "2026-01-05T23:04:18Z")

</div>

Hello. I’m using Back4App to proxy OpenAI API responses to a client app and I’ve got everything working except for streaming. On the server side I am saving the streamed responses to an OpenAIResponse object and on the client side I use LiveQuery to listen for updates to that class so that I can display the response progressively to the user. However, when I call the CloudCode it appears to block everything and the LiveQuery events don’t fire until the function completes. Any ideas on what I’m doing wrong or how I might do this differently?

**CloudCode**

```auto
Parse.Cloud.define("testOpenAI", async (request) => {
  const OpenAIResponse = Parse.Object.extend("OpenAIResponse");
  const openAIResponse = new OpenAIResponse();
  openAIResponse.set('response', '');
  await openAIResponse.save();
  
  const openai = new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
  });

  var tokenCount = 0;
  const stream = openai.responses
    .stream({
    model: 'gpt-5-nano-2025-08-07',
    instructions: 'You are a storyteller that talks like a pirate.',
    input: 'Tell a ten word story about a tardigrade.',
    stream: true,
    })
    .on("response.output_text.delta", (event) => {
      openAIResponse.set('response', `${openAIResponse.get('response')}${event.delta}`);
      tokenCount++;
      openAIResponse.set('tokenCount', tokenCount);
      openAIResponse.save();
    })
    .on("response.error", (event) => {
      console.error(event.error);
    });
  
});

```

**Relevant Client Code**

```auto
liveQueryClient.open();
const query = new Parse.Query("OpenAIResponse");
const subscription = liveQueryClient.subscribe(query);
subscription.on("update", data => {
  res.innerHTML = data.get('response');
});

async function testApp() {
  try {
    await Parse.Cloud.run("testOpenAI");
  } catch (e) {
    console.log(`testOpenAI failed - ${e}`);
  }
};

testApp().then(()=>{
  console.log('testApp completed')
});

```

---

<div class="post-metadata">

**Author:** ![rgunindi](https://community.parseplatform.org/user_avatar/community.parseplatform.org/rgunindi/32/1553_2.png) [@rgunindi](https://community.parseplatform.org/u/rgunindi)\
**Post date:** [January 9, 2026, 11:08am UTC](https://community.parseplatform.org/t/cloudcode-blocking-openai-api-streaming/5065/2 "2026-01-09T11:08:38Z")

</div>

Do you want to stream to the client?

---

<div class="post-metadata">

**Author:** ![leebert](https://community.parseplatform.org/user_avatar/community.parseplatform.org/leebert/32/2097_2.png) [@leebert](https://community.parseplatform.org/u/leebert)\
**Post date:** [January 13, 2026, 5:33pm UTC](https://community.parseplatform.org/t/cloudcode-blocking-openai-api-streaming/5065/3 "2026-01-13T17:33:27Z")

</div>

Yes. I solved this issue by creating a POST endpoint rather than using Parse objects and LiveQuery. On the client side I access the stream via Fetch request.

[https://github.com/leebert/unlegalese](https://github.com/leebert/unlegalese)
