In-app Mode for JavaScript

Add AI Runtime protection to a Node.js application through the ByteHide App runtime SDK. The SDK intercepts your application's model calls in-process and AI Runtime judges them with your policy.


Prerequisites

  • A ByteHide App runtime project and its project token. Create the project in the console under App runtime; the setup screen shows the token.
  • AI Runtime access for your organization, and AI Security included in your plan.

1. Install the Package

For Express applications:

Bash
npm install @bytehide/monitor-express

For any other Node.js application:

Bash
npm install @bytehide/monitor

2. Initialize App runtime

Express

JavaScript
import express from 'express';
import { byteHideMonitor } from '@bytehide/monitor-express';

const app = express();

// Add ByteHide Monitor middleware
app.use(byteHideMonitor({
  projectToken: 'YOUR_PROJECT_TOKEN'
}));

// Your routes here...

app.listen(3000);

Other Node.js Applications

JavaScript
import { Monitor } from '@bytehide/monitor';

// Initialize Monitor
Monitor.initialize({
  projectToken: 'YOUR_PROJECT_TOKEN'
});

// Your application code here...

Initialize App runtime before your application creates its LLM clients, so their calls are intercepted from the first request.

Keep the token out of source control

Read the project token from your configuration or secret store, for example process.env.BYTEHIDE_MONITOR_TOKEN, instead of committing it.


3. Enable AI Security

In the console, open the App runtime project, go to Rules, click Add Rule and pick AI Security. Then choose the AI Runtime policy that governs the project's LLM traffic. See Enable AI Security.


4. Run and Verify

Bash
npm start

Send a request that reaches your LLM code, then open AI runtime → Incidences. The checks of your application appear there, linked to the project's in-process route.


Next Steps

Policies

Choose which detectors run on your application's LLM traffic

Incidences

Investigate what AI Runtime caught

Previous
Python