# Transports

> Choose how the agent sends generated UI: with the render_ui tool, or inside its markdown reply.

## What is this? [#what-is-this]

The agent must send the UI to the app somehow: the browser, or a React Native app. Some agents are good at tool calls. Others only stream text, or you build their prompt yourself. A **transport** is the way the UI travels:

- **Tool** (the default): the agent calls a `render_ui` tool.
- **Markdown**: the agent writes the UI in `a2ui` code blocks inside its reply.

Both transports use the same catalogs, surfaces, and components. Only the path between the agent and the app changes.

## Which one to use [#which-one-to-use]

| | Tool | Markdown |
| --- | --- | --- |
| The agent writes UI | as `render_ui` tool calls | in `a2ui` code blocks in its reply |
| Checked before the app gets it | yes, by the runtime, and again in the app | in the app |
| Text around the UI | a separate message | the same reply, before and after the UI |
| Works with | agents that use the run's tools and context | any agent that streams text |

Start with the tool transport. If your agent cannot call client tools, or you want the UI inside the text of the reply, use markdown.

## Tool transport [#tool-transport]

This is the default, so the provider needs only the catalog:

<Tabs groupId="frontend_framework" items={["React", "Angular", "React Native", "Vue"]} persist>
  <Tab value="React">
    ```tsx
    import { standardUI } from "@copilotkit/react-core/v2/generative-ui";

    <CopilotKitProvider runtimeUrl="/api/copilotkit" generativeUI={{ ui: standardUI }}>
    ```
  </Tab>
  <Tab value="Angular">
    ```ts
    provideGenerativeUI({ ui: standardUI }),
    ```
  </Tab>
  <Tab value="React Native">
    ```tsx
    <GenerativeUIProvider ui={shopUI}>
    ```

    React Native always uses the tool transport. It has no `standardUI`, so `shopUI` stands for a catalog of your own native components.
  </Tab>
  <Tab value="Vue">
    ```vue
    <CopilotKitProvider runtime-url="/api/copilotkit" :generativeUI="{ ui: standardUI }">
    ```
  </Tab>
</Tabs>

When a run carries the catalog, the runtime adds the `render_ui` tool and a short guide on how to call it. The runtime checks every operation while it streams, and the browser (on React Native, the app) renders the valid ones at once.

The runtime option `generativeUI` controls when the tool is added:

- Left out: for every run that carries a tool-transport catalog.
- `true`: for every run.
- `{ agents: ["shop"] }`: for every run of those agents.
- `false`: never.

```ts title="app/api/copilotkit/route.ts"
const runtime = new CopilotRuntime({
  agents: { default: agent },
  generativeUI: true,
});
```

Your agent must use the tools and the context entries of the run. The built-in agent does this. For a LangGraph Python agent, add `CopilotKitMiddleware`.

## Markdown transport [#markdown-transport]

Set `transport: "markdown"`:

<Tabs groupId="frontend_framework" items={["React", "Angular", "React Native", "Vue"]} persist>
  <Tab value="React">
    ```tsx
    <CopilotKitProvider runtimeUrl="/api/copilotkit" generativeUI={{ ui: standardUI, transport: "markdown" }}>
    ```
  </Tab>
  <Tab value="Angular">
    ```ts
    provideGenerativeUI({ ui: standardUI, transport: "markdown" }),
    ```
  </Tab>
  <Tab value="React Native">
    Not available on React Native yet. `GenerativeUIProvider` always uses the tool transport, and `transport: "markdown"` is a type error there. A transport passed from JavaScript, or through a cast, is dropped, with a warning in development.
  </Tab>
  <Tab value="Vue">
    ```vue
    <CopilotKitProvider runtime-url="/api/copilotkit" :generativeUI="{ ui: standardUI, transport: 'markdown' }">
    ```
  </Tab>
</Tabs>

The provider sends the component schemas and a writing guide as context, and the agent writes the UI in its reply. See [Markdown mode](/generative-ui/components/markdown-mode) for what the agent writes, how it streams, and how to build your own prompt.

## Only some agents [#only-some-agents]

By default every agent gets generative UI. To give it only to some of them, list their ids:

<Tabs groupId="frontend_framework" items={["React", "Angular", "React Native", "Vue"]} persist>
  <Tab value="React">
    ```tsx
    <CopilotKitProvider
      runtimeUrl="/api/copilotkit"
      generativeUI={{ ui: standardUI, agentIds: ["shop"] }}
    >
    ```
  </Tab>
  <Tab value="Angular">
    ```ts
    provideGenerativeUI({ ui: standardUI, agentIds: ["shop"] }),
    ```
  </Tab>
  <Tab value="React Native">
    ```tsx
    <GenerativeUIProvider ui={shopUI} agentIds={["shop"]}>
    ```
  </Tab>
  <Tab value="Vue">
    ```vue
    <CopilotKitProvider
      runtime-url="/api/copilotkit"
      :generativeUI="{ ui: standardUI, agentIds: ['shop'] }"
    >
    ```
  </Tab>
</Tabs>

The other agents get no catalog, no guide, and no `render_ui` tool.

## Cost in tokens [#cost-in-tokens]

Each run carries the catalog and a guide. The guide has only the rules that your catalog needs, so a small catalog gets a short guide. The full standard catalog is the largest part. To keep runs small, drop the components that you do not need with [`omit`](/generative-ui/components/standard-catalog#drop-components).

Your agent now gets the UI tools it needs, in the transport that fits it.
