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

# streaming

Set `"stream": true` to receive the response as Server-Sent Events (SSE). Tokens arrive in chunks as they're produced, which is ideal for chat UIs.

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI
  client = OpenAI(base_url="https://api.heyaskr.ai", api_key="ASKR_API_KEY")

  stream = client.chat.completions.create(
      model="gpt-5.5",
      messages=[{"role": "user", "content": "Write a haiku about the sea."}],
      stream=True,
  )
  for chunk in stream:
      delta = chunk.choices[0].delta.content
      if delta:
          print(delta, end="", flush=True)
  ```

  ```javascript Node theme={null}
  import OpenAI from "openai";
  const client = new OpenAI({ baseURL: "https://api.heyaskr.ai", apiKey: "ASKR_API_KEY" });

  const stream = await client.chat.completions.create({
    model: "gpt-5.5",
    messages: [{ role: "user", content: "Write a haiku about the sea." }],
    stream: true,
  });
  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || "");
  }
  ```
</CodeGroup>

## Raw SSE

If you're not using an SDK, read the stream directly. Each line is prefixed with `data: ` and the stream ends with `data: [DONE]`.

```text theme={null}
data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":" world"}}]}
data: [DONE]
```

<Tip>
  After a stream finishes, refresh the [balance](/billing/balance) to show the updated credit in your UI.
</Tip>
