Skip to content

streamText resulting text is not blocking #6522

Closed
@nicoalbanese

Description

@nicoalbanese

Description

The following generation exits early as await result.text doesn't appear to be blocking as expected.

import { openai } from "@ai-sdk/openai";
import { streamText } from "ai";
import "dotenv/config";

const main = async (prompt: string) => {
  const result = streamText({
    model: openai("gpt-4.1-mini"),
    prompt,
  });

  console.log(await result.text);
};

main("Hey, how are you?");

AI SDK Version

    "@ai-sdk/openai": "2.0.0-alpha.4",
    "ai": "5.0.0-alpha.5",

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions