# Shield

Official client libraries for the Highflame AI security platform. **Shield** is a real-time guardrails layer that operates through a resource-based client and, in Python and TypeScript, a decorator/wrapper API for low-boilerplate integration into existing agent frameworks.

The Python `highflame` package and the TypeScript `@highflame/sdk` package also expose additional namespaces, including `ZeroIDClient`, but this API reference page is focused on the Shield client surface that is common to the current SDK docs.

### Available SDKs

<table><thead><tr><th width="202.91015625">Language</th><th width="166.03125">Package</th><th width="242.8046875">Install</th><th>Min Version</th></tr></thead><tbody><tr><td>Python</td><td><code>highflame</code></td><td><code>pip install highflame</code></td><td>Python 3.10+</td></tr><tr><td>JavaScript / TypeScript</td><td><code>@highflame/sdk</code></td><td><code>npm install @highflame/sdk</code></td><td>Node 18+</td></tr></tbody></table>

### Quick Comparison

| Feature                 | Python            | TypeScript          |
| ----------------------- | ----------------- | ------------------- |
| Resource-based client   | Yes               | Yes                 |
| Decorator / wrapper API | Yes               | Yes                 |
| SSE streaming           | Yes               | Yes                 |
| Async support           | Yes (async/await) | Native (Promise)    |
| Runtime dependencies    | httpx, pydantic   | None (native fetch) |
| ZeroID client exported  | Yes               | Yes                 |

### Framework Support

| Framework integration surface                       | Python                       | TypeScript                   |
| --------------------------------------------------- | ---------------------------- | ---------------------------- |
| Generic `Shield` wrappers and `client.guard.*` APIs | Yes                          | Yes                          |
| LangGraph packaged adapter                          | `HighflameMiddleware`        | `HighflameMiddleware`        |
| CrewAI packaged adapter                             | `HighflameCrewHooks`         | `HighflameCrewHooks`         |
| AWS Strands packaged adapter                        | `HighflameStrandsHooks`      | `HighflameStrandsHooks`      |
| Azure AI Foundry packaged adapter                   | `HighflameFoundryMiddleware` | `HighflameFoundryMiddleware` |

### Core Concepts

#### Resource-Based API

All SDKs provide resources on the client:

<table><thead><tr><th width="193.4140625">Resource</th><th>Methods</th><th>Description</th></tr></thead><tbody><tr><td><code>client.guard</code></td><td>Guard evaluation, prompt shorthand, tool-call shorthand, SSE streaming</td><td>Full detection + Cedar policy evaluation</td></tr><tr><td><code>client.detect</code></td><td><code>run()</code></td><td>Detection only, no policy evaluation</td></tr><tr><td><code>client.detectors</code></td><td><code>list()</code></td><td>List available detectors</td></tr><tr><td><code>client.debug</code></td><td><code>policies()</code></td><td>Inspect loaded policies</td></tr></tbody></table>

#### REST Endpoint Parity

| REST endpoint            | Python SDK                | TypeScript SDK            | Rust SDK                    | Notes                                                               |
| ------------------------ | ------------------------- | ------------------------- | --------------------------- | ------------------------------------------------------------------- |
| `POST /v1/guard`         | `client.guard.evaluate()` | `client.guard.evaluate()` | `client.guard().evaluate()` | Full request/response surface                                       |
| `POST /v1/guard/stream`  | `client.guard.stream()`   | `client.guard.stream()`   | `client.guard().stream()`   | SSE stream support                                                  |
| `POST /v1/detect`        | `client.detect.run()`     | `client.detect.run()`     | `client.detect().run()`     | Detection only, no Cedar evaluation                                 |
| `GET /v1/detectors`      | `client.detectors.list()` | `client.detectors.list()` | `client.detectors().list()` | Detector metadata and health                                        |
| `GET /v1/debug/policies` | `client.debug.policies()` | `client.debug.policies()` | `client.debug().policies()` | Loaded Cedar policy metadata                                        |
| `GET /v1/health`         | Not currently surfaced    | Not currently surfaced    | Not currently surfaced      | Use the REST endpoint directly when you need service health details |

#### Decorator / Wrapper API

Python and TypeScript support wrapping functions with guardrails:

| Wrapper                | Guards                 | Behavior                               |
| ---------------------- | ---------------------- | -------------------------------------- |
| Prompt wrapper         | Incoming user messages | Blocks **before** function runs        |
| Tool wrapper           | Outgoing tool calls    | Blocks **before** function runs        |
| Tool-response wrapper  | Tool return values     | Function runs; blocks **return value** |
| Model-response wrapper | LLM output             | Function runs; blocks **return value** |

#### Enforcement Modes

| Mode      | Behavior                          |
| --------- | --------------------------------- |
| `enforce` | Block on deny (default)           |
| `monitor` | Allow + log silently              |
| `alert`   | Allow + trigger alerting pipeline |

#### Authentication

All SDKs accept a service key (`hf_sk_...`) that is automatically exchanged for a short-lived JWT. The JWT is cached and transparently refreshed — concurrent calls share a single in-flight exchange.

#### Framework Integrations

Both SDKs include optional integration helpers for common agent frameworks. These intercept model calls and tool executions at the framework level.

| Integration      | Class                        | Python                               | TypeScript                   |
| ---------------- | ---------------------------- | ------------------------------------ | ---------------------------- |
| LangGraph        | `HighflameMiddleware`        | `pip install 'highflame[langgraph]'` | `npm install @highflame/sdk` |
| CrewAI           | `HighflameCrewHooks`         | `pip install 'highflame[crewai]'`    | `npm install @highflame/sdk` |
| AWS Strands      | `HighflameStrandsHooks`      | `pip install 'highflame[strands]'`   | `npm install @highflame/sdk` |
| Azure AI Foundry | `HighflameFoundryMiddleware` | `pip install 'highflame[foundry]'`   | `npm install @highflame/sdk` |

See [Framework Integrations](/api-reference/sdk/shield/integrations.md) for full documentation on each integration.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.highflame.ai/api-reference/sdk/shield.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
