nestrs-ai is the NestJS @nestjs/ai analogue for NestRS: register named LanguageModel implementations, call generate_text / generate_object, and optionally run an agent loop with tools. Model calls go through nestrs-resilience (timeout + jittered retry).
Install
FakeModel for tests
generate_text
generate_object (fail-closed)
type, required, and optional additionalProperties: false.
Agent tools
tool_calls, generate_text invokes registered tools and continues until a final text response or max_steps.
Custom LanguageModel
Security
- Tool handlers must enforce the caller’s principal / Ability.
- Fail closed on structured output.
- Details: security notes.
See also
- Resilience (underlying timeout/retry)
- API reference
- Lab:
POST /lab/n12/ai