Registry Index

Search the catalog

Type to search items across every indexed registry, or pick a page.

PageOtherregistry:page3 dependencies

AI SDK Backend

ai-sdk-backend

Next.js route handler that streams chat completions through the AI SDK.

app/api/chat/route.tsapp/api/chat/route.ts
32 lines
import { openai } from "@ai-sdk/openai";
import { frontendTools } from "@assistant-ui/ai-sdk";
import {
  streamText,
  convertToModelMessages,
  type UIMessage,
  type JSONSchema7,
} from "ai";

export async function POST(req: Request) {
  const {
    messages,
    system,
    tools,
  }: {
    messages: UIMessage[];
    system?: string;
    tools?: Record<string, { description?: string; parameters: JSONSchema7 }>;
  } = await req.json();

  const result = streamText({
    model: openai("gpt-5.6-luna"),
    messages: await convertToModelMessages(messages),
    tools: {
      ...frontendTools(tools ?? {}),
    },
    ...(system === undefined ? {} : { system }),
  });

  return result.toUIMessageStreamResponse();
}
Used by 1 item

Built on AI SDK Backend

Other @assistant-ui items that list this one as a dependency.

@assistant-ui

More from @assistant-ui

Streaming never steals your scroll position; a pill offers the way back down.

A checklist the agent works through, with progress you can glance.

Work measured in minutes: weighted stages, an ETA, and a way out.

A read-only transcript someone sent you, with a way to pick it up yourself.

Human in the loop: the agent asks before it runs anything with side effects.

A pixel matrix that keeps time while the model has nothing to show yet.

Citations collapsed into a pill, expanding into scannable source cards.

Work still going somewhere else, and the results waiting to be collected.