Lượt tương tác khi phát trực tuyến

Khi tạo một Lượt tương tác, bạn có thể đặt stream: true để truyền trực tuyến phản hồi theo gia số bằng cách sử dụng sự kiện do máy chủ gửi (SSE).

Python

from google import genai

client = genai.Client()

stream = client.interactions.create(
    model="gemini-3.6-flash",
    input="Count from 1 to 25.",
    stream=True,
)
for event in stream:
    if event.event_type == "step.delta":
        if event.delta.type == "text":
            print(event.delta.text, end="", flush=True)

JavaScript