Skip to main content

What’s changed

v3.0.0 introduces two main changes: Nunjucks templating is now a separate package. If you use templateFormat: "nunjucks" with prompts, you must install @braintrust/templates-nunjucks-js and register the plugin at startup. Mustache templating continues to work without any changes. Improved support for restricted environments. The SDK now provides dedicated builds for Node.js, browsers, edge runtimes (such as Cloudflare Workers and Next.js Edge), and workerd. Bundlers automatically choose the correct build for your target environment, so most users won’t need to make any changes.

Migration steps

1

Upgrade the SDK

npm install braintrust@latest
2

Install the Nunjucks plugin (if applicable)

If you use templateFormat: "nunjucks", install the plugin package:
npm install @braintrust/templates-nunjucks-js
If you only use Mustache templates or no templating at all, skip this step.
3

Register the Nunjucks plugin (if applicable)

At the entry point of your application, import and register the plugin before using any Braintrust prompts:
import { registerTemplatePlugin } from "braintrust";
import { nunjucksPlugin } from "@braintrust/templates-nunjucks-js";

registerTemplatePlugin(nunjucksPlugin);
This only needs to be called once. After that, templateFormat: "nunjucks" works as before.

Troubleshooting

“Nunjucks templating requires @braintrust/templates-nunjucks” — You are using templateFormat: "nunjucks" but haven’t installed or registered the plugin. Follow steps 2 and 3 above. Type errors after upgrading — If you reference TemplateRendererPlugin in your own code, it is exported directly from braintrust:
import { type TemplateRendererPlugin } from "braintrust";
If you encounter issues during migration, please open an issue with details about your setup.