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

# Streaming

> Receive tokens as they are generated

# Streaming

Streaming returns tokens as the model generates them, reducing time-to-first-token. The stream format is identical to OpenAI and Anthropic.

## OpenAI format

Set `stream: true` in your Chat Completions request.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.radium.cloud/v1/chat/completions \\
    -H "Authorization: Bearer $RADIUM_API_KEY" \\
    -H "Content-Type: application/json" \\
    -d '{
      "model": "clarke-1.0",
      "messages": [{"role": "user", "content": "Count to 5"}],
      "stream": true
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI
  client = OpenAI(api_key="YOUR_RADIUM_API_KEY", base_url="https://api.radium.cloud/v1")
  stream = client.chat.completions.create(
      model="clarke-1.0",
      messages=[{"role": "user", "content": "Count to 5"}],
      stream=True,
  )
  for chunk in stream:
      print(chunk.choices[0].delta.content or "", end="")
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from "openai";
  const client = new OpenAI({ apiKey: process.env.RADIUM_API_KEY, baseURL: "https://api.radium.cloud/v1" });
  const stream = await client.chat.completions.create({
    model: "clarke-1.0",
    messages: [{ role: "user", content: "Count to 5" }],
    stream: true,
  });
  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0].delta.content || "");
  }
  ```
</CodeGroup>

## Anthropic format

Streaming works the same way in the Messages API. Set `stream: true`.

## Limitations

Tool call streaming follows the same partial-delta format as OpenAI. Function arguments arrive as incremental JSON deltas in the `tool_calls` array. The final chunk contains the complete tool call with ` finish_reason: "tool_calls"`.


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