Streaming feature of assistant api nodeJS

  ws.on("message", function message(data) {
    const msg = JSON.parse(data);
    if (msg.event === "start") {
      streamSid = msg.start.streamSid;
      console.log(`Starting Media Stream for ${streamSid}`);
    } else if (msg.event === "media") {
      transcriptionService.send(msg.media.payload);
    } else if (msg.event === "mark") {
      const label = msg.mark.name;
      console.log(`Media completed mark (${msg.sequenceNumber}): ${label}`);
    }
  });

  transcriptionService.on("transcription", async (text) => {
    console.log(`Received transcription: ${text}`);
    try {
      // Create a thread for the conversation
      const thread = await openai.beta.threads.create({
        messages: [
          { role: 'user', content: text }
        ],
      });

      let threadId = thread.id;
      console.log('Created thread with Id: ' + threadId);

      // Stream the response
      const run = openai.beta.threads.runs.stream(threadId, {
        assistant_id: assistantId,
        stream: true
      });

      await ttsService.connect();
      
      run
        .on('textDelta', (delta) => {
          const chunk = delta.content && delta.content.length ? delta.content[0].text.value : '';
          if (chunk) {
            ttsService.sendText(chunk);
          }
        })
        .on('messageDelta', (delta) => {
          const chunk = delta.content && delta.content.length ? delta.content[0].text.value : '';
          if (chunk) {
            ttsService.sendText(chunk);
          }
        })
        .on('end', () => {
          console.log('Streaming ended');
          ttsService.close();
        });

    } catch (error) {
      console.error("Error:", error);
      const errorMessage = "I'm sorry, I encountered an error while processing your request.";
      ttsService.emit("speech", Buffer.from(errorMessage).toString('base64'), errorMessage);
    }
  });

In the above code the streaming is working perfectly but for every input a new thread is being created. I tried to create the thread at msg.event === “start”.

But when I used retrieve I don’t know how to handle the stream at that time.
Is there any documentation or reference for how we can handle that?
Or if someone can modify by above code, would be helpful.