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

# Testing internal agents

Check Point AI Red Teaming connects to an agent in one of two ways. The right one
depends on whether Red can reach your agent from the internet.

![Left: AI Red Teaming sends attacks inbound to your agent's public HTTPS URL, optionally through a firewall that allows Red's IP ranges. Right: the SDK runner inside your private network connects outbound to AI Red Teaming, pulls attacks, passes them to your private agent with a local call, and returns the replies. Red never opens a connection into the private network.](/_fern-files/lakera.docs.buildwithfern.com/773b41e4edb9b5c1ca3fe3b2e8528762768a7829765f9904821d8a2583c85a6a/docs/assets/red-connection-modes.svg)

|                                    | Agent target (platform)                                 | SDK runner                                      |
| ---------------------------------- | ------------------------------------------------------- | ----------------------------------------------- |
| Who starts the connection          | Red calls your endpoint                                 | Your runner calls Red                           |
| Inbound access to your network     | Required: Red must reach the endpoint from the internet | None                                            |
| Outbound access from your network  | None                                                    | HTTPS on port 443 to your region's Red API host |
| Where the agent's credentials live | Stored on the target in Red                             | In your handler, inside your network            |
| How a scan starts                  | From the Red console                                    | From the runner, for example a CI/CD job        |
| Setup                              | Fill in a form                                          | Install a package and write a short handler     |

If your agent is public, or you can expose it through an ingress or proxy, use an
[Agent target](/docs/red/connect-to-your-agent) and see [Network connectivity](/docs/red/networking).
If the agent is internal and inbound connections to your network aren't allowed, use the
SDK runner described on this page.

> **Note**
>
> "SDK" covers two separate things. The SDK runner carries Red's attacks to your agent
> and returns the agent's replies. It runs next to your agent and doesn't change it.
> [Tool tracing](/docs/red/trace-agent-tools) is optional: it adds a call inside your
> agent's code, and your agent then reports its tool calls to Red. You don't need tool
> tracing to test an internal agent. If you turn it on, the agent's runtime also needs
> outbound HTTPS to the same Red API host.

## How the runner works

The runner is a short script you write with the `lakera-red-sdk` package (TypeScript
or Python). It works like this:

1. You run it inside your network, on any host that can reach the agents under test.
   One host can test many agents.
2. It opens an outbound HTTPS connection to the Red API for your region:
   `red-webhooks.lakera.ai` in the US or `red-webhooks-eu.lakera.ai` in the EU. It
   pulls each attack prompt, passes the prompt to your agent with a local call, and
   returns the agent's reply on the same connection.
3. The runner doesn't listen on any port, and Check Point never opens a connection into
   your network.

Red generates the attacks, judges the replies, and stores the results. The runner only
relays: it passes each prompt to your agent and sends the reply back to Red.

## How authentication works

The runner uses two separate credentials:

1. Runner to Red. The runner authenticates with a Red Team API Key, which the
   quickstart reads from the `LAKERA_RED_API_KEY` environment variable. Each key is
   scoped to one folder and only reaches the targets, scans, and results in that folder.
   See [Red Team API Keys](/docs/red/management-api-keys).
2. Runner to your agent. Your handler calls the agent, so it holds the agent's address
   and credentials, for example a bearer token from your secrets manager. The SDK never
   sends them to Check Point.

[Data shared with Red](/docs/red/data-shared) lists everything the runner sends.

## What you write: the handler

The handler is the only code specific to your agent. It receives each attack prompt,
calls your agent, and returns the reply:

#### TypeScript

```typescript
const handler = async (session) => {
  for await (const { attack, respond } of session) {
    const res = await fetch("https://support-agent.internal.example/chat", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.AGENT_TOKEN}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ message: attack }),
    })
    if (!res.ok) throw new Error(`Agent returned ${res.status}`)
    const { reply } = await res.json()
    await respond(reply)
  }
}
```

#### Python

```python
import os

import httpx

async def handler(session):
    async with httpx.AsyncClient() as http:
        async for message in session:
            res = await http.post(
                "https://support-agent.internal.example/chat",
                headers={"Authorization": f"Bearer {os.environ['AGENT_TOKEN']}"},
                json={"message": message.attack},
            )
            res.raise_for_status()
            await message.respond(res.json()["reply"])
```

Replace the URL, auth header, and request and response fields with your agent's own.
The rest of the script (create the client, create or reuse a target, create a scan, and
call `scan.run(handler)`) is the same for every agent. See the
[SDK Quickstart](/docs/red/sdk-quickstart) for the full script.

## Requirements

1. A host inside your network that can reach the agent, such as a VM, a container, or a
   CI/CD runner, with Node.js 22+ or Python 3.11+. See
   [Deployment](/docs/red/sdk-deployment) for runtime details.
2. Outbound HTTPS on port 443 to your region's Red API host. See
   [Network connectivity](/docs/red/networking#sdk-runner-outbound-only) for the
   hostnames. Corporate proxies and TLS
   interception are supported. See
   [Running behind a corporate proxy](/docs/red/sdk-deployment#running-behind-a-corporate-proxy).
3. A Red Team API Key for the folder that holds the target and its scans.

You don't need inbound firewall rules, a public endpoint, or an allowlist of Red's IP
addresses.

## Where results appear

The Red console shows the runner's targets, scan progress, and scan reports like any
other scan. Each scan also returns a direct link to its report in `scan.dashboardLink`
(TypeScript) or `scan.dashboard_link` (Python). To keep a local copy, the runner can
write the results to a JSON file.

## Upgrades

You pin the `lakera-red-sdk` version in your project and choose when to upgrade. The
[Changelog](/docs/red/sdk-changelog) lists each release, and the docs for earlier
versions stay available under **SDK › Previous versions**.

## Current limitations

1. **Scans start from the runner, not the console.** To scan on a schedule, run the
   runner as a scheduled job, for example in your CI/CD pipeline. See
   [Run Scans in CI/CD](/docs/red/sdk-how-tos/run-scans-in-ci-cd). Starting or
   scheduling runner scans from the console isn't available.
2. **No packaged image.** The runner isn't available as a prebuilt container image or
   Helm chart. You install the package and write the handler. To run it in a container,
   use any Node.js 22+ or Python 3.11+ base image.

## Next steps

1. [SDK Quickstart](/docs/red/sdk-quickstart) to run a first scan.
2. [Deployment](/docs/red/sdk-deployment) for network, proxy, and runtime details.
3. [Run Scans in CI/CD](/docs/red/sdk-how-tos/run-scans-in-ci-cd) to scan on every
   release or on a schedule.