Guides
Streaming
Stream chat responses token by token.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Stream chat responses token by token.
import kitefishai
client = kitefishai.Client(api_key="kf-...")
with client.chat.stream(
model="kf-reasoning-10b",
messages=[{"role": "user", "content": "Summarise the RBI Master Directions on KYC."}],
) as stream:
for chunk in stream:
print(chunk.delta, end="", flush=True)
print() # newline after stream ends
with client.chat.stream(
model="kf-reasoning-10b",
messages=[{"role": "user", "content": "List IRDAI compliance requirements."}],
) as stream:
for chunk in stream:
print(chunk.delta, end="", flush=True)
full_text = stream.get_final_text()
print(f"\nTotal characters: {len(full_text)}")
| Field | Type | Description |
|---|---|---|
id | str | Request ID |
model | str | Model that generated the chunk |
delta | str | The text content of this chunk |
finish_reason | str or None | "stop" on the final chunk |
with client.chat.stream(
model="kf-reasoning-10b",
system="You are a BFSI compliance assistant. Be concise and cite regulations.",
messages=[{"role": "user", "content": "What is Form 60?"}],
) as stream:
for chunk in stream:
print(chunk.delta, end="", flush=True)
chunks = []
with client.chat.stream(model="kf-reasoning-10b", messages=[...]) as stream:
for chunk in stream:
chunks.append(chunk)
print(f"Received {len(chunks)} chunks")
print("".join(c.delta for c in chunks))
