> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudsome-inc.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 串流傳輸

所有對話補全介面都支援透過 stream: true 開啟串流傳輸。Token 會以 SSE（伺服器推送事件）的形式即時回傳。

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.cloudsome-inc.ai/v1",
    api_key="sk_live_...",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)

for chunk in response:
    for choice in chunk.choices:
        if choice.delta.content:
            print(choice.delta.content, end="")
```

## 串流計費規則

* 如果上游在資料流開始前回傳錯誤，將全額退款。
* 如果資料流開始後斷開連線，將優先按已產生的實際用量結算；無法取得準確用量時，將根據已產生的內容估算。
* 如果上游在傳輸中出錯，將按已產生的實際用量結算；無法取得準確用量時，將根據已接收的部分回應估算。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.