main
 1#!/usr/bin/env -S poetry run python
 2
 3import asyncio
 4
 5from openai import AsyncOpenAI
 6
 7# gets API Key from environment variable OPENAI_API_KEY
 8client = AsyncOpenAI()
 9
10
11async def main() -> None:
12    stream = await client.completions.create(
13        model="gpt-3.5-turbo-instruct",
14        prompt="Say this is a test",
15        stream=True,
16    )
17    async for completion in stream:
18        print(completion.choices[0].text, end="")
19    print()
20
21
22asyncio.run(main())