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

# Get detailed detection results

POST https://api.lakera.ai/v2/guard/results
Content-Type: application/json

The `results` endpoint screens submitted content according to the policy assigned to the specified project. It then returns the confidence level results of the detectors. It doesn't make a flagging decision or create a request log in Guard. It can be used to analyze data and calibrate detector threshold levels for policies.You can use the `results` endpoint to analyze historic LLM prompt and response data without worrying about triggering alerts or affecting monitoring, as they are not logged as screening requests by AI Guardrails.If no project ID is passed in the request, then the default AI Guardrails policy is used, which runs all Guard defenses and detectors at the highest sensitivity level.A request must contain `messages`, `tools`, or both.`results` requests are not logged as screening requests in AI Guardrails and do not appear in the platform or exported logs. It should not be used in runtime GenAI application security decisions as it removes the ability to control your defenses using policies.

Reference: https://docs.lakera.ai/api-reference/lakera-api/guard-results/get-results

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication using API key. Generate an API key from the AI Guardrails Dashboard. Example: Bearer sk_123...

## Servers

- `https://api.lakera.ai` (Default, default)
- `https://eu.api.lakera.ai` (Eu)
- `https://us.api.lakera.ai` (Us)
- `https://ap-southeast-1.api.lakera.ai` (ApSoutheast)

## Request

### Body (application/json)

This endpoint expects a GuardResultsRequest.

- `messages` (list of Message, optional) — List of messages comprising the interaction history with the LLM in OpenAI API Chat Completions format. Can be multiple messages of any role: user, assistant, system, tool or developer. Required unless `tools` is provided.
- `tools` (list of ToolDefinition, optional) — List of tool definitions exposed to the model, in OpenAI function-calling format. Each definition is screened on every request if your policy applies Prompt Defense to the Tool Definition role (screening location `tool_definition::content`). Can be sent without `messages`. See [Tool definitions](/docs/api/screening-roles#tool-definitions).
- `project_id` (string, optional) — ID of the relevant project. The request will be screened according to the policy assigned to the project. If no project ID is passed then the AI Guardrails Default Policy will be used for screening.
- `metadata` (map from string to any, optional) — Metadata tags can be attached to screening requests as an object that can contain any arbitrary key-value pairs. Common use cases include specifying the user or session ID.
- `dev_info` (boolean, optional) — When true the response will return an object with developer information about the build of AI Guardrails.

## Response

### 200

Successful retrieval

- `results` (list of DetailedResultsResultsItems, optional) — List of detector results
- `tools` (DetailedResultsTools, optional) — Detector results for the tool definitions in the request's `tools` array. Only returned if the request contains `tools` and the policy applies a detector to the Tool Definition role.

## Types

### Message

A message in a conversation with the AI

- `role` (enum, required) — The role of the message sender
  - Allowed values: `system`, `user`, `assistant`, `tool`, `developer`
- `content` (MessageContent, optional) — The text content of the message. Required, except for assistant messages that include `tool_calls`, where it may be null or omitted.
- `tool_calls` (list of ToolCall, optional) — Optional tool calls (only valid for assistant messages)

### ToolDefinition

A tool definition exposed to the model, in OpenAI function-calling format

- `type` (enum, required)
  - Allowed values: `function`
- `function` (ToolDefinitionFunction, required) — The function a tool definition describes

### DetailedResultsResultsItems

- `project_id` (string, optional)
- `policy_id` (string, optional)
- `detector_id` (string, optional)
- `detector_type` (string, optional)
- `result` (string, optional) — Confidence level (l1_confident, l2_very_likely, l3_likely, l4_less_likely, l5_unlikely, no_level)
- `custom_matched` (boolean, optional) — Whether there is a match for custom regular expressions
- `message_id` (integer, optional) — Index of the message in the request that this result corresponds to

### DetailedResultsTools

Detector results for the tool definitions in the request's `tools` array. Only returned if the request contains `tools` and the policy applies a detector to the Tool Definition role.

- `flagged` (boolean, optional) — Whether any tool definition was flagged
- `results` (list of DetailedResultsToolsResultsItems, optional) — List of detector results for the tool definitions

### MessageContent

The text content of the message. Required, except for assistant messages that include `tool_calls`, where it may be null or omitted.

### ToolCall

A tool call made by the assistant

- `function` (Function, required) — The function to call
- `type` (enum, required)
  - Allowed values: `function`
- `id` (string, required)

### ToolDefinitionFunction

The function a tool definition describes

- `name` (string, required) — Name of the tool. Must not be empty.
- `description` (string, optional) — Description of what the tool does and when to use it
- `parameters` (map from string to any, optional) — JSON Schema object describing the tool's parameters
- `strict` (boolean, optional) — Whether the model is required to follow the parameter schema exactly

### DetailedResultsToolsResultsItems

- `project_id` (string, optional)
- `policy_id` (string, optional)
- `detector_id` (string, optional)
- `detector_type` (string, optional)
- `result` (string, optional) — Confidence level (l1_confident, l2_very_likely, l3_likely, l4_less_likely, l5_unlikely, no_level)
- `custom_matched` (boolean, optional) — Whether there is a match for custom regular expressions
- `tool_id` (integer, optional) — Zero-based index of the tool definition in the request's `tools` array

### Function

A function to call

- `name` (string, required)
- `arguments` (string, required)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "results": [
    {
      "project_id": "string",
      "policy_id": "string",
      "detector_id": "string",
      "detector_type": "string",
      "result": "string",
      "custom_matched": true,
      "message_id": 1
    }
  ],
  "tools": {
    "flagged": true,
    "results": [
      {
        "project_id": "string",
        "policy_id": "string",
        "detector_id": "string",
        "detector_type": "string",
        "result": "string",
        "custom_matched": true,
        "tool_id": 1
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.lakera.ai/v2/guard/results"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.lakera.ai/v2/guard/results';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.lakera.ai/v2/guard/results"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.lakera.ai/v2/guard/results")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.lakera.ai/v2/guard/results")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.lakera.ai/v2/guard/results', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.lakera.ai/v2/guard/results");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.lakera.ai/v2/guard/results")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```