.env file.
Environment variables
Set these variables in your shell or deployment environment to avoid hard coding credentials:
When environment variables are set, you can call
wrap() without passing credentials:
.env file support
Install the [dotenv] extra to load variables from a .env file automatically:
.env
.env from the current working directory on first use.
Precedence
When the same setting is provided in multiple places, the SDK uses this order:- Explicit parameters passed to
wrap()orinit() - Environment variables (
FLINTAI_*) .envfile (if[dotenv]is installed)
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 localhost, 127.0.0.1, and ::1 (local development). The SDK warns when using HTTP, even on loopback.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:
API keys
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:
LLM provider API key
By default, the gateway supplies its own upstream credentials — you don’t need to forward your provider key. If you need to use your own provider credentials, you have two options:llm_api_key— Explicitly pass the key. Required for Google GenAI if you want to forward your key (since its client doesn’t exposeapi_keyas an attribute). Omit to let the proxy use its own upstream credentials.forward_llm_key=True— Auto-extract the key fromclient.api_keyand forward it (wrap()only)
Policy ID
A policy ID tells the gateway which guardrails policy to enforce. Policies apply input/output detectors that can block, redact, or alert on unsafe content.FLINTAI_POLICY_ID environment variable.
Fail-closed behavior
The SDK defaults torequire_guardrails=True. If guardrails configuration is missing or can’t be applied — for example, missing credentials or an unrecognized client type — the SDK raises FlintAIGuardrailsError instead of sending traffic unguarded.
To allow operation without guardrails (for example, in local development), pass require_guardrails=False:
With
require_guardrails=False, the SDK logs a warning when guardrails are not configured but still wraps the client and allows it to make calls directly to the provider.Next steps
Usage
Wrapping patterns, advanced usage, and best practices
Integrations
Provider-specific setup for OpenAI, Anthropic, Google GenAI, LangChain, and ADK