Repository navigation
Release 0.0.1
The first release of @nestjs/ai: language models for Nest applications, built on the AI SDK (ai 7).
- Models: registered by name in
AiModule.forRoot({ models }), from any@ai-sdk/*provider package, and called throughAiService.generateText(),generateObject()with a schema, andstreamText().@InjectModel()injects one for your own AI SDK calls. - Reliable calls: timeouts, retries that honor
retry-after, and fallback models, on@nestjs/resiliencepolicies or presets of your own. Budgets and usage events carry each call's tokens and cost. - Agent functions: provider methods with
@AgentFunction()are the tools a model may call. Guards, interceptors, pipes and exception filters run on every call, with the execution context type'ai', andAiExecutionContextreads the call in them. One method can also be an MCP tool, with@nestjs/mcp's@Tool(). - Streaming: answers stream to the AI SDK's
useChat()on Express, Fastify and the Node adapter, with keep-alive comments while a function runs. - Durable runs:
@nestjs/ai/workflowsruns agents on@nestjs/workflows. A run survives restarts, can wait for a person's approval, and gives each function call an idempotency key. - Testing:
@nestjs/ai/testing'sFakeModelanswers with text, tool calls, objects or errors, without a network. - Auth packages: with
@nestjs/authentication0.1.4 and@nestjs/authorization0.1.2 or later, their global guard,@CurrentUser()and@Can()policies work on agent function calls.