Code:
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const response = await openai.completions
.create({
prompt: "Hello",
model: "text-davinci-003",
stream: true,
})
.asResponse();
for await (const chunk of response.body) {
console.log(chunk.toString());
console.log("-".repeat(10));
}
}
main();
Output
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_complet
----------
ion","created":1695192584,"choices":[{"text":"\"","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_complet
----------
ion","created":1695192584,"choices":[{"text":"\n","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_complet
----------
ion","created":1695192584,"choices":[{"text":"\n","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completi
----------
on","created":1695192584,"choices":[{"text":"❱","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion"
----------
,"created":1695192584,"choices":[{"text":" local","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completio
----------
n","created":1695192584,"choices":[{"text":"\n\n","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion"
----------
,"created":1695192584,"choices":[{"text":" Local","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completi
----------
on","created":1695192584,"choices":[{"text":" is","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completi
----------
on","created":1695192584,"choices":[{"text":" an","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion","cr
----------
eated":1695192584,"choices":[{"text":" adjective","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion
----------
","created":1695192584,"choices":[{"text":" that","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion"
----------
,"created":1695192584,"choices":[{"text":" means","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion","cr
----------
eated":1695192584,"choices":[{"text":" something","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion","cr
----------
eated":1695192584,"choices":[{"text":" belonging","index":0,"logprobs":null,"finish_reason":null}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion",
----------
"created":1695192584,"choices":[{"text":" to","index":0,"logprobs":null,"finish_reason":"length"}],"model":"text-davinci-003"}
data: {"warning":"This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations","id":"cmpl-80lJo9XeeHSV3FLtp9zr9Utz2BR8Y","object":"text_completion","created":1695192584,"choices":[{"text":"","index":0,"logprobs":null,"finish_reason":"length"}],"model":"text-davinci-003"}
data: [DONE]
----------
Is this intended behavior?