> ## 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](https://docs.promptguard.co/api-reference/guard.md) before it leaves. Your client keeps calling the provider directly with its own key; only the scan goes to PromptGuard.

```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
```

Options such as `mode` and `fail_open` are in the [Python SDK](https://docs.promptguard.co/guides/python-sdk.md) and [Node.js SDK](https://docs.promptguard.co/guides/node-sdk.md) 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](https://docs.promptguard.co/integrations/providers/openai.md), [Azure OpenAI](https://docs.promptguard.co/integrations/providers/azure-openai.md) |
| `anthropic` | `anthropic`: `messages.create`, sync and async | `@anthropic-ai/sdk`: `messages.create` | [Anthropic](https://docs.promptguard.co/integrations/providers/anthropic.md) |
| `google-genai` | `google-genai`: `models.generate_content`, its streaming form, sync and async | `@google/genai`: `models.generateContent` | [Gemini](https://docs.promptguard.co/integrations/providers/gemini.md) |
| `google-generativeai` | `google-generativeai` (deprecated by Google): `GenerativeModel.generate_content` | `@google/generative-ai` (deprecated by Google): `GenerativeModel.generateContent` | [Gemini](https://docs.promptguard.co/integrations/providers/gemini.md) |
| `cohere` | `cohere`: `Client.chat`, `ClientV2.chat`, sync and async | `cohere-ai`: `Client.chat`, `ClientV2.chat` | [Cohere](https://docs.promptguard.co/integrations/providers/cohere.md) |
| `bedrock` | `boto3` / `botocore`: Bedrock Runtime `InvokeModel`, `Converse`, `ConverseStream` | `@aws-sdk/client-bedrock-runtime`: `send` of `InvokeModelCommand`, `ConverseCommand` and their streaming variants | [AWS Bedrock](https://docs.promptguard.co/integrations/providers/bedrock.md) |

The exact surfaces, including which parts of a Responses API input are read, are in each SDK's README: [Python](https://github.com/promptguardhq/promptguard-python), [Node.js](https://github.com/promptguardhq/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](https://docs.promptguard.co/integrations/frameworks/langgraph.md) 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](https://docs.promptguard.co/integrations/frameworks/vercel-ai.md) or the proxy for those.

For the framework-specific hooks, which add chain, tool and agent context to each scan, see [Frameworks](https://docs.promptguard.co/integrations/overview.md#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](https://docs.promptguard.co/integrations/overview.md) 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:

```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)}`);
}
```

`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](https://docs.promptguard.co/integrations/frameworks/fastapi.md) 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. Load the provider with `createRequire`, or use an API that does not depend on patching: [ES module apps](https://docs.promptguard.co/guides/node-sdk.md#es-module-apps).


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