wrap() or init(), or as environment variables.
Environment variables
Set these variables in your shell or deployment environment to avoid hard coding credentials:
Environment variables are read automatically. When they are set, you can call
wrap() without passing credentials:
.env file support
A .env file is not read by default. Install dotenv as a peer dependency, then pass loadDotenv to load it:
.env
Precedence
When the same setting is provided in more than one place, the SDK uses this order:- Explicit options passed to
wrap()orinit() - Environment variables (
FLINTAI_*), including any loaded from a.envfile
Gateway URL
The gateway URL is your Flint AI guardrails proxy endpoint. Find it in Flint AI Platform:- Navigate to Agents and select your agent
- Open the Sessions tab
- The gateway URL is shown in the code snippet
The gateway URL must use
https://. Plaintext http:// is only allowed for loopback hosts (localhost, 127.0.0.1, ::1), and only when you pass allowInsecureGateway: true — intended for local development. The SDK warns when insecure access is enabled.Gateway host allowlist
By default, the SDK only allows connections toapp.flintai.dev. This prevents credentials from being accidentally sent to an unintended endpoint. To use a self-hosted gateway, set FLINTAI_ALLOWED_GATEWAY_HOSTS:
Flint AI API key
Create and manage API keys in Flint AI Platform: navigate to Settings, then select API Keys. Pass the key directly or set theFLINTAI_API_KEY environment variable:
OPENAI_API_KEY), or set on the provider client directly. The SDK does not require any additional LLM provider key of its own. The apiKey here is your Flint AI key.
Policy ID
A policy ID tells the gateway which guardrails policy to enforce. Policies apply input and output detectors that can block, redact, or alert on unsafe content.FLINTAI_POLICY_ID environment variable.
Fail-closed behavior
The SDK defaults torequireGuardrails: true. If a valid client is passed but guardrails configuration is missing — for example, missing credentials — wrap() and init() throw FlintAIGuardrailsError instead of sending traffic unguarded.
To allow operation without guardrails (for example, in local development), opt out explicitly:
dangerouslyDisableGuardrails: true is the preferred, self-documenting opt-out — it is easy to find in a code search. It is equivalent to requireGuardrails: false, and the two cannot be combined with requireGuardrails: true.
Inspect your posture
Callstatus() (or client.guardrailsStatus()) at runtime to read the effective posture rather than trusting the opt-out flag alone:
active is true only when traffic is actually routed through the gateway. status() returns null before init() runs.
Next steps
Usage
Wrapping patterns, advanced usage, and best practices
Integrations
Provider-specific setup for OpenAI, Anthropic, Google GenAI, LangChain, and ADK