Agent Overview

An Agent target lets Lakera Red call your own agent endpoint. Use it when you want Red to test your system through that endpoint.

Configure an agent target

Red target form: agent target configuration
Agent target configuration
1

Open Create target

Go to Create target.

2

Set Target name

Under Information, enter Target name.

3

Switch to Agent

Under Target configuration, select Agent. The section heading changes to API Connection.

4

Fill out your API Endpoint

Set API Endpoint and choose Auth Type: None, API Key, Basic Auth, or Bearer Token.

5

Choose conversation handling

In conversation history, choose:

  • Stateless for APIs that accept the full conversation on every request and follow the OpenAI-compatible chat completions format
  • Stateful for APIs that keep session state on the server. If your endpoint does not match either contract, you may need to create a wrapper.

Your endpoint must match one of Red’s supported contracts. See Supported contracts below for the exact request and response formats.

6

Review Advanced settings

Use Additional Fields if you need to merge extra JSON into requests. Use Max Concurrent Requests to control how many requests Red sends in parallel.

If your application refuses with specific language (e.g. “This topic is outside my scope”), add those phrases under Refusal Detection so Red recognizes them as refusals. Standard phrases like I cannot help are already detected. During adaptive scans, matched phrases trigger backtracking to try a different approach.

7

Run Test Connection

In Test Target Connection, click Test Connection. Create Target stays disabled until the connection test succeeds.

8

Create the target

Click Create Target.

Credentials are stored securely and not shown after saving, so you must re-enter them if you later make changes.

Supported contracts

Red supports two Agent contracts. If your endpoint does not match either of those, see Need a wrapper instead?.

Stateless

Use Stateless when your endpoint accepts the full conversation history on every request, returns the final response in the same HTTP response, following the OpenAI-compatible chat completions format.

Request

1{
2 "model": "string",
3 "messages": [{ "role": "user | assistant | system", "content": "string" }]
4}

Any Additional Fields you configure are merged into the request body.

Response

1{
2 "choices": [
3 {
4 "message": {
5 "role": "assistant",
6 "content": "string"
7 }
8 }
9 ]
10}

Stateful

Use Stateful when your endpoint keeps conversation state on the server and continues the exchange with a sessionId.

Request

1{
2 "message": "string",
3 "sessionId": "string (optional)"
4}

Any Additional Fields you configure are merged into the request body.

Response

1{
2 "message": "string",
3 "sessionId": "string"
4}

On the first request, Red omits sessionId. Your endpoint should create a new session and return its ID. Red then sends that sessionId on follow-up requests. During Test Connection, Red sends two messages and verifies that the second response returns the same sessionId.

Need a wrapper instead?

If your endpoint needs custom handling or uses a different request or response format, put a wrapper in front of it and connect Red to that wrapper instead.

See the Creating a wrapper guide.

Auth and settings

Red supports these auth options for Agent targets:

Auth TypeHow it is sent
NoneNo auth header or query parameter
API KeyHeader or query parameter
Basic AuthAuthorization: Basic <base64(user:password)>
Bearer TokenAuthorization: Bearer <token>

For Additional Fields, use a valid JSON object. If your endpoint is rate-limited or resource-constrained, lower Max Concurrent Requests to avoid timeouts or overload.

If your endpoint runs inside a private network (e.g. EKS in a private VPC), see Networking for exposure patterns and the Lakera Red egress IPs to allowlist.

Next steps