Skip to main content
Unlike standard LLM responses, which are plain text or markdown, a C1 Response is a string that is structured payload to contain rich content. It uses an XML-like structure to package multiple types of content into a single string. It is generally stored as assistant message content in the database.
<!-- A C1 Response can contain multiple content types -->
<thinking>...</thinking><content>...</content><artifact>...</artifact>

Node.js SDK (@thesysai/genui-sdk/server)

This SDK provides a function to create a Response Builder object that manages the creation and streaming of the C1 Response.
import { makeC1Response } from "@thesysai/genui-sdk/server";
import { transformStream } from "@crayonai/stream";

export async function POST(req: NextRequest) {
  const c1Response = makeC1Response();
  // ... use c1Response methods ...
  return new NextResponse(c1Response.responseStream, {
    headers: { "Content-Type": "text/event-stream" },
  });
}

Main Function

makeC1Response()
C1ResponseBuilder
Creates and returns an instance of the Response Builder object.

Response Builder Methods

The object returned by makeC1Response() has the following methods and properties:
writeContent
(content: string) => void
Pipes the raw string response from a C1 API call (e.g., from the Generative UI or Artifacts endpoint) into the response stream.
writeCustomMarkdown
(markdown: string) => void
Adds a custom markdown response to the stream. This will be wrapped in <custom_markdown> tags.
writeThinkItem
(item: ThinkItem) => void
Adds a thinking state entry to the <thinking> part of the response stream.
end
() => void
Signals that the stream is complete and closes it. This should be called in the onEnd callback of your stream processing.
responseStream
ReadableStream
The ReadableStream object that should be returned from your API route.

Python SDK (thesys_genui_sdk)

The thesys_genui_sdk package provides the C1Response class, which acts as the Response Builder. Please refer to the Python SDK Reference for more details.

A Practical Example: Adding Thinking States

A common use case for the Response Builder is to add real-time thinking state indicators to the stream before the main content from the LLM arrives. This significantly improves the user’s perception of responsiveness. For a complete, step-by-step example of how to use these helpers, see the Thinking States guide.