Skip to main content
The Flint AI Python SDK supports five LLM integrations. Standard LLM clients use flintai.wrap(), while Google ADK uses a dedicated plugin.

OpenAI

Wrap an openai.OpenAI() client to route completions through the guardrails proxy.
After wrapping, use the client exactly as before — the SDK redirects traffic transparently.

Anthropic

Wrap an anthropic.Anthropic() client the same way.

Google GenAI

Google GenAI clients don’t expose api_key as an attribute, so llm_api_key can’t be auto-extracted. Pass it explicitly if you want to forward your key, or omit it to let the proxy use its own upstream credentials:
The SDK automatically normalizes the gateway URL with a trailing slash for Google GenAI — do not add one yourself.

LangChain

flintai.wrap() auto-detects LangChain chat models, extracts the underlying SDK client, and applies guardrails routing. Supported models:
  • ChatOpenAI (from langchain-openai)
  • ChatAnthropic (from langchain-anthropic)
  • ChatGoogleGenerativeAI (from langchain-google-genai)
For LangChain agents with deeper lifecycle integration (session tracking, agent identity headers), use LangChainGuardrailsMiddleware instead:
See Usage for more details.

Google ADK

ADK agents lazily create their GenAI client at runtime, so flintai.wrap() cannot be used. Use ADKGuardrailsPlugin to configure guardrails routing at the agent level:
Set FLINTAI_GATEWAY_URL, FLINTAI_API_KEY, and FLINTAI_LLM_API_KEY as environment variables (or in a .env file), then create the plugin with no arguments: ADKGuardrailsPlugin().
The plugin handles three concerns:
  • Routingcontent_config directs LLM traffic through the guardrails proxy
  • Identitybefore_model_callback injects agent name, agent ID, and session ID headers on each call
  • Error handlingon_model_error converts guardrails blocks into an LlmResponse the agent can handle gracefully
See Usage for more details on the plugin’s behavior and configuration.

Version compatibility

Pin your provider SDK to the tested ranges to avoid breakage from private API changes: The SDK logs a warning if your installed provider version is outside these ranges.

Known limitations

  • Private attribute mutationflintai.wrap() modifies internal attributes of LLM SDK clients (_base_url, _custom_headers, _api_client._http_options) to redirect traffic. These are not part of the providers’ public APIs and may change without notice.
  • Async clientsAsyncOpenAI and AsyncAnthropic are not supported. Use sync clients only.
  • Google GenAI api_key — Google GenAI clients don’t expose api_key as an attribute, so llm_api_key can’t be auto-extracted. Pass it explicitly to forward your key, or omit it to use the proxy’s own credentials.
  • Multiple provider keys in environment — If multiple provider API keys are set (OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY), auto-detection fails. Pass provider explicitly to flintai.init().

Next steps

Usage

Advanced patterns, error handling, and best practices

Configuration

Environment variables, credentials, and gateway setup