Skip to content
Dashboard

Chat SDK agents can now stream generative UI with json-render

Railly Hugo, Lahfir,

You can now stream generative UI from your Chat SDK agent with json-render.

With a typed catalog of components, the agent writes a JSON spec that json-render converts into a Chat SDK card. Each adapter then posts the card in its platform’s native format, such as Block Kit on Slack and Adaptive Cards on Teams.

The catalog covers tables, charts, buttons, and more, so there’s no separate tool to build and maintain for each message shape.

lib/bot.ts
import { defineCatalog } from "@json-render/core";
import {
schema,
standardComponentDefinitions,
streamCard,
} from "@json-render/chat";
import { streamText } from "ai";
const catalog = defineCatalog(schema, {
components: standardComponentDefinitions,
});
bot.onNewMention(async (thread, message) => {
const result = streamText({
model: "anthropic/claude-haiku-5.5",
system: catalog.prompt(),
prompt: message.text,
});
await streamCard(thread, result.textStream);
});

Stream a generated card into the thread when your agent is mentioned.

Copy link to headingStream cards as the model writes

streamCard posts the card once its root element has content and updates the message as new elements stream in. Edits go out at most once every 500 ms by default, which matches Chat SDK’s streaming interval. Once the stream ends, the message shows the final, validated card.

Copy link to headingValidate specs and enforce platform limits

toCard checks every element’s props against its component schema and throws CardSpecError for an invalid spec. Each problem gets its own readable issue, so you can send the list back to the model for a corrected spec.

Platforms cap what a single message can hold, and Chat SDK adapters degrade content past those caps. The Slack adapter, for example, turns a second table into a code block. Pass limits to reject those specs instead.

Read the documentation to get started, or try the playground.

Contributors