API Features · Python

Streaming Responses

Stream AI responses in real-time using Server-Sent Events. Build responsive chat interfaces with token-by-token output.

1. Install

pip install xalen

2. Code

#89B4FA;">from xalen import XALEN

client = XALEN(api_key=#A6E3A1;">"xln_test_YOUR_KEY")

stream = client.chat.completions.create(
    model=#A6E3A1;">"vedika-standard",
    messages=[{#A6E3A1;">"role": "user", "content": "Explain Vimshottari Dasha"}],
    stream=True
)

#89B4FA;">for chunk in stream:
    #89B4FA;">if chunk.choices[0].delta.content:
        #89B4FA;">print(chunk.choices[0].delta.content, end="", flush=True)

Related Tutorials

Function Calling API Features · Python JSON Mode API Features · Python Batch Processing (50% Off) API Features · Python Build RAG with Embeddings API Features · Python Python Quickstart Getting Started · Python JavaScript Quickstart Getting Started · JavaScript

200+ AI models. One API. Start building in 5 minutes.

Get API Key

Last updated: 2026-05-21