# OpenAI Agents SDK

Stream an OpenAI Agents SDK response into the Vercel AI SDK view.

## Stream UI messages from the server

Install the SDK and its UI-message extension on your server.

```bash
npm install @openai/agents@0.21.0 @openai/agents-extensions@0.21.0
```

Use the ai-sdk-ui extension to emit a UI-message stream from your agent.

```tsx
import { run, type Agent } from "@openai/agents";
import { createAiSdkUiMessageStreamResponse } from "@openai/agents-extensions/ai-sdk-ui";
export async function streamAgent(agent: Agent, input: string, signal: AbortSignal) {
  const result = await run(agent, input, { stream: true, signal });
  return createAiSdkUiMessageStreamResponse(result);
}

```

Call this from your authenticated server route with an application-configured agent, validated input and the request signal. Return its Response unchanged so stream headers survive. Persist and authorize conversation/session state in your server owner; a client-provided transcript is not authenticated history.

## Connect Ghost

Point the [Vercel AI SDK client](/libraries/ai-runtime-vercel) at your route with DefaultChatTransport({ api: "/api/chat" }). The adapter renders the response through MessageParts.

## Native capabilities and troubleshooting

Agents SDK owns handoffs, sessions, tools, guardrails and interruptions. The stream bridge only exposes what its UI-message protocol can express. Keep richer native run/interruption state in your application and bind a deliberate approval/resumption command when needed; a displayed tool call does not execute it.

A successful text stream alone does not prove approval, handoff or session recovery. Check those native flows separately if your application uses them. See the [official extension](https://github.com/openai/openai-agents-js/tree/main/extensions/ai-sdk-ui) for bridge behavior and [SDK integration boundaries](/libraries/ai-adapters).
