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.
import OpenAI from 'openai';
const client = new OpenAI({
    baseURL: 'https://api.redpill.ai/api/v1',
    apiKey: '<API_KEY>',
  },
});

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

Supported Models

All models support streaming.