> ## Documentation Index
> Fetch the complete documentation index at: https://docs.switchagents.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs moved from docs.flintai.dev to docs.switchagents.ai. Use docs.switchagents.ai for every link and request.
> To search these docs from an AI tool, connect the MCP server at https://docs.switchagents.ai/mcp. The page index is at https://docs.switchagents.ai/llms.txt.
> The source code for these products is public on GitHub. Switch Rooms: https://github.com/sandbox-quantum/switch. Switch Trust CLI: https://github.com/sandbox-quantum/switch-trust-cli. Switch Trust CodeScan action: https://github.com/sandbox-quantum/switch-trust-codescan-action. Switch Trust MCP server: https://github.com/sandbox-quantum/switch-trust-mcp. Switch Trust Python SDK: https://github.com/sandbox-quantum/switch-trust-sdk-py. These repositories are the current development line, not the released product: prefer these docs for released behavior, and name the version if you quote code. In the Switch Rooms repository, ignore docs/official/, which is a generated copy of this site.

# Monitor your agents at runtime

> Install the SDK and see your first traces in less than 10 minutes

Install the Switch Trust SDK for Python or TypeScript to capture live traces of your agents in production. Within minutes, see what your agents actually do — prompts, responses, models called, and guardrail events.

> [card] [Switch Trust CLI on GitHub](https://github.com/sandbox-quantum/flintai-cli)
>
> Source code, example agents, and issue tracking

Choose your language:

> [tab] Python
>
> > [!NOTE]
> >
> > **Requirements:** Python 3.10 or later
> >
> > **Supported with `switch_trust.wrap()`:** OpenAI, Anthropic, LangChain (`ChatOpenAI`, `ChatAnthropic`, `ChatGoogleGenerativeAI`), Google GenAI
> >
> > **Google ADK:** Use `ADKGuardrailsPlugin` instead of `wrap()` — see [SDK Usage guide](https://docs.switchagents.ai/switch-trust/sdk/python/usage.md)
>
> **1. Install the SDK in your agent's environment**
>
> On your local machine or wherever your agent code runs:
>
> ```bash theme={null}
> pip install switch-trust-sdk-py
> ```
>
> > [accordion] Optional: Install with provider extras
> >
> > If you need specific provider dependencies:
> >
> > ```bash theme={null}
> > pip install "switch-trust-sdk-py[openai]"     # OpenAI
> > pip install "switch-trust-sdk-py[anthropic]"  # Anthropic
> > pip install "switch-trust-sdk-py[genai]"      # Google GenAI
> > pip install "switch-trust-sdk-py[adk]"        # Google ADK
> > pip install "switch-trust-sdk-py[all]"        # All providers
> > ```
>
> **2. Register your agent and get credentials**
>
> Log into [Switch Trust](https://app.switchagents.ai) and register your agent for monitoring:
>
> 1. Go to **Agents** and select **Add agents**.
> 2. Select **Monitor & protect agents**, then **Install SDK**.
> 3. Enter a name for your agent (for example, "Customer Support Bot").
> 4. Select your agent to open its **Sessions** tab.
>
> The setup page shows the values you need:
>
> * **Gateway URL** - Shown in the code snippet on the Sessions tab.
>
> * **API key** - Use an existing Switch Trust API token, or create a new one by navigating to **Settings** and selecting **API keys**. Give the token the **Ingest only** role, or **Editor** or higher. The gateway refuses a **Viewer** token, or one with no role, with a 403 error.
>
> > [!NOTE]
> >
> > Copy your token immediately when created — it will only be shown once.
>
> **3. Wrap your LLM client in your agent code**
>
> Import `switch_trust` and wrap your existing LLM client.
>
> > [!TIP]
> >
> > **Using environment variables:** Instead of hardcoding credentials, set `SWITCH_TRUST_GATEWAY_URL` and `SWITCH_TRUST_API_KEY` as environment variables, then call `switch_trust.wrap(client)` without parameters.
>
> > [tab] OpenAI
> >
> > ```python theme={null}
> > import openai
> > import switch_trust
> >
> > client = openai.OpenAI(api_key="your-openai-api-key")
> > client = switch_trust.wrap(
> >     client,
> >     gateway_url="https://your-gateway-url",
> >     api_key="your-switch-trust-api-key",
> > )
> >
> > response = client.chat.completions.create(
> >     model="gpt-4",
> >     messages=[{"role": "user", "content": "Hello"}],
> > )
> > ```
>
> > [tab] Anthropic
> >
> > ```python theme={null}
> > import anthropic
> > import switch_trust
> >
> > client = anthropic.Anthropic(api_key="your-anthropic-api-key")
> > client = switch_trust.wrap(
> >     client,
> >     gateway_url="https://your-gateway-url",
> >     api_key="your-switch-trust-api-key",
> > )
> >
> > message = client.messages.create(
> >     model="claude-sonnet-4-20250514",
> >     max_tokens=1024,
> >     messages=[{"role": "user", "content": "Hello"}],
> > )
> > ```
>
> > [tab] LangChain
> >
> > ```python theme={null}
> > from langchain_openai import ChatOpenAI
> > import switch_trust
> >
> > llm = ChatOpenAI(model="gpt-4", api_key="your-openai-api-key")
> > llm = switch_trust.wrap(
> >     llm,
> >     gateway_url="https://your-gateway-url",
> >     api_key="your-switch-trust-api-key",
> > )
> >
> > response = llm.invoke("Hello")
> > ```
>
> > [tab] Google GenAI
> >
> > ```python theme={null}
> > import google.genai
> > import switch_trust
> >
> > client = google.genai.Client(api_key="your-gemini-api-key")
> > client = switch_trust.wrap(
> >     client,
> >     gateway_url="https://your-gateway-url",
> >     api_key="your-switch-trust-api-key",
> >     llm_api_key="your-gemini-api-key",  # Required for Google GenAI
> > )
> >
> > response = client.models.generate_content(
> >     model="gemini-2.5-flash",
> >     contents="Hello",
> > )
> > ```
>
> > [!NOTE]
> >
> > **Google ADK:** Use `ADKGuardrailsPlugin` instead of `wrap()` — see the [SDK Usage guide](https://docs.switchagents.ai/switch-trust/sdk/python/usage.md) for details.
>
> **4. Run your agent**
>
> Run your agent as you normally would. The SDK captures each LLM interaction automatically.
>
> **5. View your traces**
>
> Back in [Switch Trust](https://app.switchagents.ai), navigate to **Agents** and select your agent, then open the **Sessions** tab.
>
> Within moments, you'll see:
>
> * **Sessions** - Individual agent runs
>
> * **Traces** - Every LLM call with prompts, responses, model info, and latency
>
> * **Guardrail events** - Any policy actions (if configured)
>
> > [!TIP]
> >
> > **Add runtime protection:** Pass `policy_id="your-policy-id"` to `switch_trust.wrap()` to enforce guardrails. Policies apply input/output detectors that can block, redact, or alert on unsafe content before it reaches users. [Learn more →](https://docs.switchagents.ai/switch-trust/guardrails/policies.md)
>
> ## Next steps
>
> > [card] [SDK Configuration](https://docs.switchagents.ai/switch-trust/sdk/python/configuration.md)
> >
> > Environment variables, credentials, and configuration options
>
> > [card] [SDK Usage](https://docs.switchagents.ai/switch-trust/sdk/python/usage.md)
> >
> > Examples for all supported providers and frameworks

> [tab] TypeScript
>
> > [!NOTE]
> >
> > **Requirements:** Node.js 18 or later
> >
> > **Supported with `wrap()`:** OpenAI, Anthropic, LangChain (`ChatOpenAI`, `ChatAnthropic`, `ChatGoogleGenerativeAI`), Google GenAI
> >
> > **Google ADK:** Use `ADKGuardrailsPlugin` instead of `wrap()` — see [SDK Usage guide](https://docs.switchagents.ai/switch-trust/sdk/typescript/usage.md)
>
> **1. Install the SDK in your agent's environment**
>
> On your local machine or wherever your agent code runs:
>
> ```bash theme={null}
> npm install @sandboxaq/switch-trust-sdk-ts
> ```
>
> > [accordion] Optional: Install provider peer dependencies
> >
> > Each provider library is an optional peer dependency — install the ones you use:
> >
> > ```bash theme={null}
> > npm install @sandboxaq/switch-trust-sdk-ts openai              # OpenAI
> > npm install @sandboxaq/switch-trust-sdk-ts @anthropic-ai/sdk   # Anthropic
> > npm install @sandboxaq/switch-trust-sdk-ts @google/genai       # Google GenAI
> > npm install @sandboxaq/switch-trust-sdk-ts @google/adk         # Google ADK
> > ```
> >
> > For LangChain, install the matching `@langchain/*` package.
>
> **2. Register your agent and get credentials**
>
> Log into [Switch Trust](https://app.switchagents.ai) and register your agent for monitoring:
>
> 1. Go to **Agents** and select **Add agents**.
> 2. Select **Monitor & protect agents**, then **Install SDK**.
> 3. Enter a name for your agent (for example, "Customer Support Bot").
> 4. Select your agent to open its **Sessions** tab.
>
> The setup page shows the values you need:
>
> * **Gateway URL** - Shown in the code snippet on the Sessions tab.
>
> * **API key** - Use an existing Switch Trust API token, or create a new one by navigating to **Settings** and selecting **API keys**. Give the token the **Ingest only** role, or **Editor** or higher. The gateway refuses a **Viewer** token, or one with no role, with a 403 error.
>
> > [!NOTE]
> >
> > Copy your token immediately when created — it will only be shown once.
>
> **3. Wrap your LLM client in your agent code**
>
> Import `wrap` and wrap your existing LLM client. The SDK mutates the client in place, so use the same instance afterward.
>
> > [!TIP]
> >
> > **Using environment variables:** Instead of hardcoding credentials, set `SWITCH_TRUST_GATEWAY_URL` and `SWITCH_TRUST_API_KEY` as environment variables, then call `wrap(client)` without options.
>
> > [tab] OpenAI
> >
> > ```typescript theme={null}
> > import OpenAI from "openai";
> > import { wrap } from "@sandboxaq/switch-trust-sdk-ts";
> >
> > const client = new OpenAI({ apiKey: "your-openai-api-key" });
> > wrap(client, {
> >   gatewayUrl: "https://your-gateway-url",
> >   apiKey: "your-switch-trust-api-key",
> > });
> >
> > const response = await client.chat.completions.create({
> >   model: "gpt-4",
> >   messages: [{ role: "user", content: "Hello" }],
> > });
> > ```
>
> > [tab] Anthropic
> >
> > ```typescript theme={null}
> > import Anthropic from "@anthropic-ai/sdk";
> > import { wrap } from "@sandboxaq/switch-trust-sdk-ts";
> >
> > const client = new Anthropic({ apiKey: "your-anthropic-api-key" });
> > wrap(client, {
> >   gatewayUrl: "https://your-gateway-url",
> >   apiKey: "your-switch-trust-api-key",
> > });
> >
> > const message = await client.messages.create({
> >   model: "claude-sonnet-4-20250514",
> >   max_tokens: 1024,
> >   messages: [{ role: "user", content: "Hello" }],
> > });
> > ```
>
> > [tab] LangChain
> >
> > ```typescript theme={null}
> > import { ChatOpenAI } from "@langchain/openai";
> > import { wrap } from "@sandboxaq/switch-trust-sdk-ts";
> >
> > const llm = new ChatOpenAI({ model: "gpt-4" });
> > wrap(llm, {
> >   gatewayUrl: "https://your-gateway-url",
> >   apiKey: "your-switch-trust-api-key",
> > });
> >
> > const response = await llm.invoke("Hello");
> > ```
>
> > [tab] Google GenAI
> >
> > ```typescript theme={null}
> > import { GoogleGenAI } from "@google/genai";
> > import { wrap } from "@sandboxaq/switch-trust-sdk-ts";
> >
> > const client = new GoogleGenAI({ apiKey: "your-gemini-api-key" });
> > wrap(client, {
> >   gatewayUrl: "https://your-gateway-url",
> >   apiKey: "your-switch-trust-api-key",
> > });
> >
> > const response = await client.models.generateContent({
> >   model: "gemini-2.5-flash",
> >   contents: "Hello",
> > });
> > ```
>
> > [!NOTE]
> >
> > **Google ADK:** Use `ADKGuardrailsPlugin` instead of `wrap()` — see the [SDK Usage guide](https://docs.switchagents.ai/switch-trust/sdk/typescript/usage.md) for details.
>
> **4. Run your agent**
>
> Run your agent as you normally would. The SDK captures each LLM interaction automatically.
>
> **5. View your traces**
>
> Back in [Switch Trust](https://app.switchagents.ai), navigate to **Agents** and select your agent, then open the **Sessions** tab.
>
> Within moments, you'll see:
>
> * **Sessions** - Individual agent runs
>
> * **Traces** - Every LLM call with prompts, responses, model info, and latency
>
> * **Guardrail events** - Any policy actions (if configured)
>
> > [!TIP]
> >
> > **Add runtime protection:** Pass `policyId: "your-policy-id"` to `wrap()` to enforce guardrails. Policies apply input/output detectors that can block, redact, or alert on unsafe content before it reaches users. [Learn more →](https://docs.switchagents.ai/switch-trust/guardrails/policies.md)
>
> ## Next steps
>
> > [card] [SDK Configuration](https://docs.switchagents.ai/switch-trust/sdk/typescript/configuration.md)
> >
> > Environment variables, credentials, and configuration options
>
> > [card] [SDK Usage](https://docs.switchagents.ai/switch-trust/sdk/typescript/usage.md)
> >
> > Examples for all supported providers and frameworks
