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

# Auto-instrumentation

> Which provider SDKs promptguard.init() patches in Python and Node, which it does not, and how to check at runtime

`init()` patches the provider SDKs installed in your process, so each call they make is scanned by the [Guard API](/api-reference/guard) before it leaves. Your client keeps calling the provider directly with its own key; only the scan goes to PromptGuard.

<CodeGroup>
  ```python Python theme={"system"}
  import promptguard
  promptguard.init()  # reads PROMPTGUARD_API_KEY; call once, before creating clients
  ```

  ```typescript Node.js theme={"system"}
  import { init } from 'promptguard-sdk';
  init(); // reads PROMPTGUARD_API_KEY; call once, before creating clients
  ```
</CodeGroup>

Options such as `mode` and `fail_open` are in the [Python SDK](/guides/python-sdk) and [Node.js SDK](/guides/node-sdk) guides.

## What is patched

Patching is per call surface, not per package. A call not listed here is not scanned, even when its package is patched: the OpenAI embeddings, audio and image endpoints, for example.

| Name reported | Python package and calls | Node package and calls | Provider page |
| - | - | - | - |
| `openai` | `openai`: `chat.completions.create`, `chat.completions.parse`, `responses.create`, sync and async | `openai`: `chat.completions.create`, `responses.create` | [OpenAI](/integrations/providers/openai), [Azure OpenAI](/integrations/providers/azure-openai) |
| `anthropic` | `anthropic`: `messages.create`, sync and async | `@anthropic-ai/sdk`: `messages.create` | [Anthropic](/integrations/providers/anthropic) |
| `google-genai` | `google-genai`: `models.generate_content`, its streaming form, sync and async | `@google/genai`: `models.generateContent` | [Gemini](/integrations/providers/gemini) |
| `google-generativeai` | `google-generativeai` (deprecated by Google): `GenerativeModel.generate_content` | `@google/generative-ai` (deprecated by Google): `GenerativeModel.generateContent` | [Gemini](/integrations/providers/gemini) |
| `cohere` | `cohere`: `Client.chat`, `ClientV2.chat`, sync and async | `cohere-ai`: `Client.chat`, `ClientV2.chat` | [Cohere](/integrations/providers/cohere) |
| `bedrock` | `boto3` / `botocore`: Bedrock Runtime `InvokeModel`, `Converse`, `ConverseStream` | `@aws-sdk/client-bedrock-runtime`: `send` of `InvokeModelCommand`, `ConverseCommand` and their streaming variants | [AWS Bedrock](/integrations/providers/bedrock) |

The exact surfaces, including which parts of a Responses API input are read, are in each SDK's README: [Python](https://github.com/acebot712/promptguard-python), [Node.js](https://github.com/acebot712/promptguard-node).

### Frameworks on top of these SDKs

A framework is covered when it calls one of the patched surfaces underneath. LangChain's `ChatOpenAI` calls the `openai` package, so its calls are scanned, including inside a [LangGraph](/integrations/frameworks/langgraph) graph. Frameworks that make their own HTTP calls are not: the **Vercel AI SDK**'s providers (`@ai-sdk/openai` and the rest) do not use the `openai` package, so `init()` does not see them. Use the [Vercel AI integration](/integrations/frameworks/vercel-ai) or the proxy for those.

For the framework-specific hooks, which add chain, tool and agent context to each scan, see [Frameworks](/integrations/overview#frameworks).

## What is not patched

When `init()` finds a provider library installed that it did not hook, it logs a warning naming it, with a link to this page. Calls through these are **not scanned** by `init()`; point their base URL at the [proxy](/integrations/overview) instead.

| Python | Node |
| - | - |
| `groq`, `mistralai`, `together`, `ollama`, `google-cloud-aiplatform` | `groq-sdk`, `@mistralai/mistralai`, `together-ai`, `ollama`, `@google-cloud/aiplatform`, `@aws-sdk/client-bedrock-agent-runtime`, `@ai-sdk/openai`, `@ai-sdk/anthropic`, `@ai-sdk/google` |

## Checking it at runtime

A warning is only read by someone watching the logs at startup. The same facts are available as data, so you can fail a deploy on them:

<CodeGroup>
  ```python Python theme={"system"}
  import promptguard

  promptguard.init()
  report = promptguard.instrumentation_report()
  assert "openai" in report["patched"]
  assert report["detected_unpatched"] == [], report["detected_unpatched"]
  ```

  ```typescript Node.js theme={"system"}
  import { init, instrumentationReport } from 'promptguard-sdk';

  init();
  const report = instrumentationReport();
  if (!report.patched.includes('openai') || report.detectedUnpatched.length > 0) {
    throw new Error(`PromptGuard instrumentation incomplete: ${JSON.stringify(report)}`);
  }
  ```
</CodeGroup>

`patched` holds the names in the first column of the table above, the same in both SDKs.

`middleware` lists the request-edge middleware running in the process, whether or not `init()` was called: `fastapi` when the Python SDK's [FastAPI and ASGI middleware](/integrations/frameworks/fastapi) is mounted. A middleware is never a patch, so it never appears in `patched`. An SDK with none reports an empty list, so the same check reads the same in both languages.

<Warning>
  **Node.js ESM apps.** The Node SDK patches the provider modules that CommonJS `require()` resolves. In a native ESM app (`"type": "module"`), a provider that ships a separate ESM build gives your `import` a different module object, which is not patched, so its calls go unscanned. There, use a [framework integration](/integrations/overview#frameworks), the proxy, or `GuardClient.scan()` directly.
</Warning>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.