How to send out the AzureOpen AI response in real-time streaming throught

I use sdk @azure/openai-assistants and when creating a chat with an assistant, I cannot achieve the effect in the window, my messages are sent to the client in parts
Currently I receive a complete answer within a minute after the request

I also use sockets for communication that I monitor on the client

Previously I tried to use methods such as:
getRunStep(threadId: string, runId: string, stepId: string, options?: GetRunStepOptions)
listRunSteps(threadId: string, runId: string, options?: ListRunStepsOptions)

but unsuccessfully

I am interested in whether there is an option to receive a response from the assistant as the response is being formed, which is not yet completed, in order to allow the client to see the response in real time (text streaming)

My code:

async runAssistantJob(
    data: {
      text: string;
      person_id?: number;
      prompt_id?: number;
      user_id: number;
    user_ai_request: UserAiRequest,
  ): Promise<string> {
    const { text, person_id = null, prompt_id = null, user_id } = data;
    const assistant = await this.assistantRepo.findOne({
      where: { user_id },

    const { assistant_id, instructions: baseInstruction } = assistant;

    const person = await this.getUserPersonById(user_id, person_id);
    const thread_id = person.thread_id;

    const promptInstruction = 'this my prompt';
    instructions = instructions + `:${promptInstruction}`;

    await this.assistantsClient.createMessage(thread_id, 'user', text);

    let runResponse = await this.assistantsClient.createRun(thread_id, {
      assistantId: assistant_id,

    do {
      await sleep(1000);
      runResponse = await this.assistantsClient.getRun(
    } while (
      runResponse.status === 'queued' ||
      runResponse.status === 'in_progress'

    const runMessages = await this.assistantsClient.listMessages(thread_id, {
      limit: 1,

    const responseTexts: string[] = [];
    for (const runMessageDatum of {
      for (const item of runMessageDatum.content) {
        if (item.type === 'text') {

    return responseTexts.length ? responseTexts[0] : '';

my socket service

await sendIoSystemMessage(user_id, {
        event: 'is_ai_request_in_progress',
        value: true,

      const value = await this.aiService.runAssistantJob(,

      await sendIoSystemMessage(user_id, {
        event: type_event,

Grateful for the help…