Skip to main content

Install

withEra

Use withEra() for the simplest integration:
Before each model call, the wrapper:
  1. Extracts user and assistant messages from the prompt.
  2. Calls era.turnContext() with those messages.
  3. Adds the returned block to the system message.
  4. Calls the wrapped model.

eraMiddleware

Use eraMiddleware() when you need to compose multiple middleware:
Both helpers accept TurnContextOptions, including visitorId, partnerEndUserId, trusted email or phone, and sessionId.
The options are fixed when you create the wrapper. If identity changes per request, create the wrapper inside that request or call turnContext() directly.
The helpers wrap the Vercel AI SDK LanguageModel interface, so they work with any compatible model provider. See both function signatures.