Skip to main content

@nest-native/ai-sdk

Decorator-first NestJS streaming primitive for the Vercel AI SDK that preserves the full Nest enhancer pipeline

Stream

Decorator-First Streaming

Replace the cookbook's raw @Res() + manual piping with a single @AiStream() decorator. The handler just returns an AI SDK stream result.

Nest

Full Enhancer Pipeline

Guards, pipes, interceptors, and exception filters all run before the stream opens, so a pre-stream rejection is an HTTP error, never an SSE error frame.

Both

Express + Fastify Parity

The same handler streams identically on both adapters. The package writes to the underlying Node response and hijacks Fastify's reply so the AI SDK owns the socket.

Abort

Real AbortSignal Plumbing

Inject @AiAbortSignal() and forward it into your AI SDK call. A client disconnect cancels the upstream model request so the provider stops billing — tested against real disconnects.

Errors

Pre-Stream vs In-Stream Errors

Errors before the first byte become HTTP responses through your filters. Errors during the stream become the AI SDK's documented, secret-safe error frame.

Zero

Zero Runtime Dependencies

The published package keeps "dependencies": empty. The AI SDK and NestJS packages stay peers, so your app installs only what it uses.