Skip to main content
The Flint AI Python 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 function parameters, environment variables, or in a .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
The SDK reads .env from the current working directory on first use.

Precedence

When the same setting is provided in multiple places, the SDK uses this order:
  1. Explicit parameters passed to wrap() or init()
  2. Environment variables (FLINTAI_*)
  3. .env file (if [dotenv] is installed)

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 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 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:
Loopback hosts are always allowed regardless of this setting.

API keys

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:

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 expose api_key as an attribute). Omit to let the proxy use its own upstream credentials.
  • forward_llm_key=True — Auto-extract the key from client.api_key and 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.
You can also set this via the FLINTAI_POLICY_ID environment variable.

Fail-closed behavior

The SDK defaults to require_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