Skip to main content
Use text() for plain outbound text. You can also pass a plain string anywhere Spectrum accepts content.
import { text } from "spectrum-ts";

await space.send(text("Hello, world."));

// Plain strings are equivalent:
await space.send("Hello, world.");

Streaming text

Both text() and markdown() accept a streaming source: an AI SDK result, an AsyncIterable, or a ReadableStream. On platforms that support it, text streams live. iMessage in remote mode sends the first chunk as a real message and edits in place as more text arrives. Telegram private chats animate a native draft preview. Platforms without streaming support wait for the stream to finish and send the full text as one message.
import { text } from "spectrum-ts";
import { streamText as aiStreamText } from "ai";

const result = aiStreamText({ model, prompt: message.content.text });
await space.send(text(result));
A stream can only be sent once. Pass options.extract for any chunk shape the built-in auto-detection doesn’t recognize.