> ## 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.

# Streaming

All chat completion endpoints support streaming via stream: true. Tokens are delivered as server-sent events (SSE) in real time.

```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="")
```

## Streaming Billing Rules

* If the upstream errors before any data is streamed, you are fully refunded.
* If you disconnect after streaming begins, billing uses the actual usage generated when available. If exact usage is unavailable, it is estimated from the generated content.
* If the upstream fails mid-stream, billing uses the actual usage generated when available. If exact usage is unavailable, it is estimated from the partial response received.


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