Skip to main content
The Chat SDK provides first-class support for streaming AI-generated text from libraries like the Vercel AI SDK, with platform-native streaming on Slack and graceful fallback for other platforms.

Basic Streaming

Simply pass an AsyncIterable<string> to thread.post():

Platform Support

Slack

Native streaming via Assistants API - smooth character-by-character updates

Google Chat

Fallback mode - post + edit with throttling (500ms default)

Teams

Fallback mode - post + edit with throttling (500ms default)

Discord

Fallback mode - post + edit with throttling (500ms default)

How It Works

Native Streaming (Slack)

When the adapter supports native streaming:
Slack’s streaming API updates the message in real-time as tokens arrive.

Fallback Streaming (Other Platforms)

For platforms without native support, the SDK uses post + edit:

Streaming Markdown Renderer

The SDK includes a sophisticated streaming markdown renderer that handles:
  • Table buffering - Holds back potential table headers until confirmed by separator line
  • Inline marker balancing - Prevents unclosed **, *, ~~, `, [ from appearing mid-stream
  • Code fence tracking - Detects when inside code blocks to avoid processing markdown inside them

Table Buffering Example

Without buffering, tables would flash as raw pipe-delimited text:

Inline Marker Balancing

Prevents broken formatting mid-stream:

Configuration Options

Update Interval (Fallback Mode)

Control how often edits are sent:
Lower intervals = smoother updates but higher rate limit risk. Higher intervals = choppier updates but safer.

Placeholder Text

Customize the initial placeholder (or disable it):

Streaming with Context

The SDK automatically extracts user/team context for Slack’s streaming API:

Advanced: Streaming to Channels

When streaming to a channel (not a thread), the SDK accumulates text before posting:
Channel-level streaming doesn’t support incremental updates - the full response is posted once complete.

Example: AI Chat Bot

Performance Considerations

Rate Limits

Slack Native Streaming

No additional rate limits - uses dedicated streaming API

Fallback Mode

Each edit counts against platform rate limits. Adjust streamingUpdateIntervalMs if you hit limits.

Edit Scheduling

The fallback renderer uses recursive setTimeout to avoid overwhelming slow services:
Edits are scheduled after the previous edit completes, preventing request buildup during slow responses.