> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.lakera.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.lakera.ai/_mcp/server.

# Creating a wrapper

Check Point AI Red Teaming tests AI systems by sending probes and analyzing the
responses. To do that, Red needs an HTTP endpoint it can call.

If your system already matches Red's supported contracts, connect it directly with an
[Agent target](/docs/red/connect-to-your-agent). If a **Stateful** endpoint only differs
in field names, reply location, streaming, or where the session id lives, map it in the
form with [Custom API formats](/docs/red/custom-api-formats) — no wrapper needed. Reach
for a wrapper when your API needs more than field mapping.

## What a wrapper does

A wrapper is a lightweight HTTP service between Red and your AI system. It translates
Red's request format into your system's format, waits for the full response, and returns
Red-compatible JSON.

```text
Red -> Wrapper -> Your API
Red <- Wrapper <- Your API
```

This is especially useful when your system is not directly OpenAI-compatible, streams
output, or needs custom auth handling.

Handle authentication in the way that best fits your system. Your wrapper can either
forward AI Red Teaming credentials upstream or use its own configured credentials when
calling the target system.

## Wrapper contract

Your wrapper must expose the [Stateful](/docs/red/connect-to-your-agent#stateful) agent
contract. Red uses a `sessionId` to maintain multi-turn conversations.

**Request** (Red → wrapper):

```json
{
  "message": "Tell me about your refund policy",
  "sessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

**Response** (wrapper → Red):

```json
{
  "message": "Our refund policy allows...",
  "sessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

On the first request, Red omits `sessionId`. Your wrapper should create a new session
and return its ID. Red then sends that `sessionId` on follow-up requests.

## Typical wrapper flow

1. Authenticate the inbound request from Red.
2. Resolve an existing session or create a new one.
3. Translate Red's request into the payload your upstream system expects.
4. Call the upstream API.
5. Collect the full response (buffer if upstream streams).
6. Return Red-compatible JSON with the `sessionId`.

## Generate a starter wrapper with AI

> **Note**
>
> For a quick starting point, paste this prompt into your AI coding tool along with a
> real upstream request example, response example, and auth details.

```md
Create a minimal HTTP wrapper for AI Red Teaming.

## Preferred language/framework

<e.g., Node + Express, Python + Flask, Go>

## AI Red Teaming endpoint

The wrapper must expose a Stateful endpoint:

POST /chat

Request: { "message": "string", "sessionId": "string (optional)" }

Response: { "message": "string", "sessionId": "string" }

## Requirements

- Require an Authorization: Bearer <TOKEN> header; reject requests without it with 401
- Store conversation history in memory, keyed by sessionId; persistence is not required
- Translate the AI Red Teaming request into my upstream API format
- Translate the upstream API response back into the AI Red Teaming response format
- Return the full response synchronously
- Keep the implementation minimal and easy to run locally

## My upstream API request example

<paste a full curl command or JSON request example, including headers>

## My upstream API response example

<paste a full JSON response example>

## My upstream auth details

<paste auth scheme, headers, token location, and any required fields>

## Please return

1. A complete working wrapper
2. A short explanation of where the translation happens
3. How to run it locally
4. How to deploy it so AI Red Teaming can reach it
5. An example curl request to test it
```

## Practical guidance

Secure the wrapper endpoint with authentication, such as a **Bearer Token** or **API
Key**. Once deployed, use the **Test Connection** option in Red to verify the setup. See
[Networking](/docs/red/networking) for how to make the wrapper reachable by Red.

## How to configure Red for a wrapper

Configure the wrapper as an **Agent** target:

| Field                    | Value                                                          |
| ------------------------ | -------------------------------------------------------------- |
| **Type**                 | **Agent**                                                      |
| **Conversation history** | **Stateful**                                                   |
| **URL**                  | Your wrapper URL, e.g. `https://your-wrapper.example.com/chat` |
| **Auth Type**            | Usually **Bearer Token** or **API Key**                        |

## Next steps

* [Agent target configuration](/docs/red/connect-to-your-agent) for full details on the
  request/response contracts.
* [Networking](/docs/red/networking) for making the wrapper reachable by Red.
* [Getting Started with AI Red Teaming](/docs/red/quickstart) to create the target and
  run your first scan.