Installation
This guide walks you through installing Guardrails in your application using either the REST API or the official SDK.
Guardrails is designed to work with any language, framework, or LLM provider.
Installation options
You can integrate Guardrails in three ways:
- SDK (recommended) – Best developer experience
- REST API – Language-agnostic
- Self-hosted engine – Advanced / enterprise use cases
Install via npm (SDK)
npm install @guardrailz/sdkOr with Yarn:
yarn add @guardrailz/sdkInstall via CDN (browser usage)
<script src="https://your-domain.com/sdk/guardrails-sdk.js"></script>This exposes a global Guardrails object.
Environment variables
Create an API key in the dashboard and set it as an environment variable.
GUARDRAILS_API_KEY=gr_live_xxxxxxxxx
GUARDRAILS_BASE_URL=https://api.guardrails.devNever expose your API key in client-side code.
Verify installation
You should be able to run a basic validation request after installation.
import { GuardrailsClient } from '@guardrailz/sdk';
const client = new GuardrailsClient({
apiKey: process.env.GUARDRAILS_API_KEY!,
});
await client.validate({
text: 'Hello world',
profileName: 'default',
});If this runs without errors, Guardrails is installed correctly.
Next steps
- Learn how to run your first guardrail → Quickstart
- Explore profiles and policies → Core Concepts