Loading topic
async/await and have run a coroutine with asyncio.run. It also assumes you know what a Python generator is. By the end you will be able to write an async generator, consume it, and explain why it is a good fit for streaming a response.2 min readasync/await, and you have seen an async generator (a function with async def that uses yield). Here you will connect the two: FastAPI sends whatever the generator yields, one piece at a time.3 min readStreamingResponse sends each yielded chunk as it is produced. Here you will learn how to wrap each token in a format that clients can parse reliably.3 min readasync/await, have seen an async generator, and know what a chat completions API is. You will read a streamed model response chunk by chunk and turn it into an async generator of plain text. The next chapters connect that generator to FastAPI.2 min readStreamingResponse, and the Server-Sent Events (SSE) forma2 min read/chat endpoint from the previous chapters running. It also assumes you know async/await and have used httpx for ordinary requests. You will write a client that prints tokens as they arrive instead of waiting for the full reply.2 min read/chat endpoint from the previous chapters. It covers what happens when generation fails after the first byte has already been sent.3 min read/chat endpoint from the previous chapters: an async generator wrapped in StreamingResponse, SSE framing, and an async LLM client injected with Depends. It also assumes you know try/finally and basic asyncio task cancellation.2 min read/chat endpoint that returns StreamingResponse with Server-Sent Events (SSE). Your code can be correct and still look broken in production. The cause is often a proxy between the client 3 min read/chat endpoint from the earlier chapters. It also assumes you know basic pytest, and that get_client is provided through Depends. You will test the endpoint without calling a real model.2 min read/chat endpoint, its SSE helper, and the Depends client provider. It also assumes you know how the endpoint handles disconnects and mid-stream errors. It needs Python 3.11 or newer for `asyncio.tim2 min read