Semantic Kernel, a powerful tool for integrating large language models into your applications, now supports streaming responses. In this blog post, we’ll explore how to leverage this feature to obtain streamed results from LLMs like AzureOpenAI and OpenAI.
![]()
Why Streamed Responses Matter?
When working with language models, especially in conversational scenarios, streaming responses offer several advantages.
- Real-time Interaction: Streaming allows you to receive partial responses as they become available, enabling more interactive and dynamic conversations.
- Reduced Latency: Instead of waiting for the entire response, you can start processing and displaying content incrementally, reducing overall latency.
- Efficient Resource Usage: Streaming conserves memory and resources by handling data in smaller chunks.
How to use Streaming Responses?
I've published a complete video on how to generate this using Python and that can be found here.
Here, I'm just publishing the code snippets for your usage.
Install Dependencies
Read configuration values and Instantiate Kernel
Create an Object of LLM
Azure OpenAI
OpenAI
Define execution settings for LLM
Azure OpenAI
OpenAI
Make a Call to LLM
Azure OpenAI
OpenAI
Final output
![Output]()
Conclusion
Streaming responses enhance the user experience, making interactions smoother and more efficient. Whether you’re building chatbots, virtual assistants, or any other AI-powered application, consider leveraging Semantic Kernel’s streaming capabilities.
Happy streaming!