> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thesys.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# C1 Response

> Server-side helpers for constructing and streaming C1 Response.

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.

```xml theme={null}
<!-- 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.

```typescript theme={null}
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

<ResponseField name="makeC1Response()" type="C1ResponseBuilder">
  Creates and returns an instance of the Response Builder object.
</ResponseField>

#### Response Builder Methods

The object returned by `makeC1Response()` has the following methods and properties:

<ResponseField name="writeContent" type="(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.
</ResponseField>

<ResponseField name="writeCustomMarkdown" type="(markdown: string) => void">
  Adds a custom markdown response to the stream. This will be wrapped in `<custom_markdown>` tags.
</ResponseField>

<ResponseField name="writeThinkItem" type="(item: ThinkItem) => void">
  Adds a thinking state entry to the `<thinking>` part of the response stream.

  <Expandable title="ThinkItem">
    <ResponseField name="title" type="string">
      The title of the thinking state.
    </ResponseField>

    <ResponseField name="description" type="string" post={["optional"]}>
      A longer description of the current process.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="end" type="() => void">
  Signals that the stream is complete and closes it. This should be called in the `onEnd` callback of your stream processing.
</ResponseField>

<ResponseField name="responseStream" type="ReadableStream">
  The `ReadableStream` object that should be returned from your API route.
</ResponseField>

***

### 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](https://pypi.org/project/thesys-genui-sdk/) 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](/guides/thinking-states)** guide.
