Skip to main content
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

FakeModel is for tests and labs only — never ship it as the production default model.

generate_text

generate_object (fail-closed)

Validation checks JSON parse, type, required, and optional additionalProperties: false.

Agent tools

When the model returns 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