Skip to main content
The Flint AI TypeScript SDK needs two pieces of information to route traffic through the guardrails proxy: a gateway URL and an API key. You can provide these as options passed to 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:
  1. Explicit options passed to wrap() or init()
  2. Environment variables (FLINTAI_*), including any loaded from a .env file

Gateway URL

The gateway URL is your Flint AI guardrails proxy endpoint. Find it in Flint AI Platform:
  1. Navigate to Agents and select your agent
  2. Open the Sessions tab
  3. 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 to app.flintai.dev. This prevents credentials from being accidentally sent to an unintended endpoint. To use a self-hosted gateway, set FLINTAI_ALLOWED_GATEWAY_HOSTS:
The * wildcard allows any host and cannot be enabled through the environment alone — you must also pass allowInsecureGateway: true in code. A wildcard host can redirect your API key, provider credentials, and all prompt and response traffic to an unintended endpoint, so reserve it for local development.

Flint AI API key

Create and manage API keys in Flint AI Platform: navigate to Settings, then select API Keys.
Copy your API key immediately when created — it is only shown once.
Pass the key directly or set the FLINTAI_API_KEY environment variable:
You still set your LLM provider key the way your agent normally does. That is usually the standard per-provider environment variable your framework expects (such as 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.
You can also set this with the FLINTAI_POLICY_ID environment variable.

Fail-closed behavior

The SDK defaults to requireGuardrails: 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.
Disabling guardrails is not silent. Either opt-out emits a SECURITY CONTROL DISABLED console warning — once per process, including the resolved agent identifier — so unguarded deployments stay detectable in your logs.

Inspect your posture

Call status() (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