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

# Streaming

> Learn how to use streaming in Confidential AI API

<Note>
  This feature works for both API Access and Dedicated Models.
</Note>

## Streaming in Confidential AI API

Confidential AI API supports streaming, enabling you to receive responses in a streaming fashion. This is particularly useful for applications that require real-time data processing or integration with other systems.

### Example of Streaming

Replace `<API_KEY>` with your actual API key in the examples below.

<CodeGroup>
  ```python Python theme={"system"}
  from openai import OpenAI

  client = OpenAI(
      api_key="<API_KEY>",
      base_url="https://api.redpill.ai/v1",
  )

  stream = client.chat.completions.create(
      model="phala/qwen3.5-27b",
      messages=[
          {
              "role": "user",
              "content": "say `Hello` 2 times fast, no other output",
          },
      ],
      stream=True,
  )
  for chunk in stream:
      content = chunk.choices[0].delta.content
      if content:
          print(content, end="")
  ```

  ```typescript TypeScript theme={"system"}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: "<API_KEY>",
    baseURL: "https://api.redpill.ai/v1",
  });

  const stream = await client.chat.completions.create({
    model: "phala/qwen3.5-27b",
    messages: [
      { role: "user", content: "say `Hello` 2 times fast, no other output" },
    ],
    stream: true,
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || "");
  }
  ```
</CodeGroup>

<Accordion title="Sample output of streaming request">
  ```
  HelloHello
  ```
</Accordion>

### Supported Models

All models support streaming.
