Create a new Briyah SDK instance
Optionaloptions: BriyahConfigOptions
Configuration options for Briyah
Get AppService for a specific user
The AppService provides full access to:
The user ID managed by your application
AppService instance for the specified user
Get cache statistics
Provides information about cached user services:
Cache statistics object
Get the configuration service
Provides access to configuration values. Primarily for internal use or debugging.
The BriyahConfigService instance
Initialize Briyah system Must be called before using getAppService()
Promise that resolves when initialization is complete
Check if Briyah is initialized
True if init() has been called, false otherwise
List the native tools registered in this process.
The registered native tool definitions
Register a native tool that agents can invoke with the EXECUTE action.
A native tool is a real function you implement in your host code — with
full access to your imports, database connections, and filesystem. Grant
it to an agent by adding its name to agent.toolNames. The handler
receives the LLM-supplied args, Briyah's helpers (e.g. an abort-wired
fetch), and the opaque context you pass to sendRoomMessage — use
context for per-interaction data the model must not be able to set
(e.g. a database handle and the record the user has selected).
Tools are registered globally (available to every user's agents) and are
not persisted. Can be called before or after init().
The native tool definition
briyah.registerTool({
name: 'lookup_record',
description: 'Fetch the current record',
parameters: [],
handler: async (args, helpers, context) => {
const { db, recordId } = context as { db: Db; recordId: string };
return db.getRecord(recordId); // recordId comes from context, not the LLM
},
});
Register multiple native tools. See registerTool.
The native tool definitions
Manually remove a user's service from the cache
Useful when you want to force a fresh AppService instance for a user, or when a user logs out and you want to clean up their cached data.
The user ID to remove from cache
Shutdown Briyah system
Cleans up resources and clears all cached user services. Should be called when your application is shutting down.
Promise that resolves when shutdown is complete
Remove a previously registered native tool.
The tool name
True if a tool was removed
Briyah SDK - Main entry point for integrating Briyah AI system
Provides multi-user access to AI agents, rooms, and stories without requiring NestJS dependency injection setup.
Example