> This page is for version v0.25.0.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.25.0: https://docs.nvidia.com/nemo/guardrails/v0.25.0/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.

# Check a NeMo Relay Tool Call

POST http://localhost:8100/v1/hooks/nemo-relay
Content-Type: application/json

Checks a NeMo Relay tool conditional-execution guardrail. Extra input fields
return `422`. An allow returns `{"decision": "allow"}`; a deny includes a
reason without a prefix. The plugin maps these to `Ok(None)` and
`Ok(Some(reason))`, and maps any error, timeout, or failed connection to `Err`.

See [Hooks Server Results and Errors](/nemo/guardrails/v0.25.0/run-guardrailed-inference/using-hooks-server/results-and-errors#errors)
for error codes and the `Retry-After: 30` header on a full queue.

See [Check NeMo Relay Tool Calls with the NVIDIA NeMo Guardrails Plugin](/nemo/guardrails/v0.25.0/run-guardrailed-inference/using-hooks-server/nemo-relay-plugin).

Reference: https://docs.nvidia.com/nemo/guardrails/reference/hooks-server-api/nemo-relay

## Request

### Body (application/json)

This endpoint expects a NemoRelayToolConditionalExecutionGuardrailRequest.

- `hook_event_name` ("NemoRelayToolConditionalExecutionGuardrail", required) — The event must be `NemoRelayToolConditionalExecutionGuardrail`. Other events return `422` with `unsupported_hook_event`.
- `tool_input` (NemoRelayToolConditionalExecutionGuardrailRequestToolInput, required, nullable) — Tool call arguments. A value that is not a JSON object is denied.
- `tool_name` (string, required) — The tool name, matched exactly by the policy and per-tool rails. It must not be empty.

## Response

### 200

Allow or deny decision

- `Hooks_checkNemoRelayToolCall_Response_200`
  - RelayAllow: RelayAllow
  - RelayDeny: RelayDeny

## Errors

### 422 Unprocessable Entity Error

Invalid request or unsupported event

- `error` (HookErrorError, required)

### 500 Internal Server Error

Check failed

- `error` (HookErrorError, required)

### 503 Service Unavailable Error

Admission queue full

- `error` (HookErrorError, required)

## Types

### NemoRelayToolConditionalExecutionGuardrailRequestToolInput

Tool call arguments. A value that is not a JSON object is denied.

- map from string to any
- list of any
- string
- double
- boolean

### RelayAllow

- `decision` ("allow", required)

### RelayDeny

- `decision` ("deny", required)
- `reason` (string, required)

### HookErrorError

- `code` (string, required, nullable) — `unsupported_hook_event`, `rail_failed`, `queue_full`, or `null`.
- `message` (string, required) — Human-readable message. Validation errors name each failing field as `body.<field>: <reason>`.
- `param` (string, required, nullable) — The request field the error relates to, or `null`.
- `type` (string, required) — `invalid_request_error` for `422`; `server_error` for `500` and `503`.

## Examples

### Deny

**Request**

```json
{
  "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
  "tool_input": {
    "query": ""
  },
  "tool_name": "search"
}
```

**Response**

```json
{
  "decision": "deny",
  "reason": "regex check tool call"
}
```

**SDK Code**

```python Deny
import requests

url = "http://localhost:8100/v1/hooks/nemo-relay"

payload = {
    "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
    "tool_input": { "query": "" },
    "tool_name": "search"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Deny
const url = 'http://localhost:8100/v1/hooks/nemo-relay';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"hook_event_name":"NemoRelayToolConditionalExecutionGuardrail","tool_input":{"query":""},"tool_name":"search"}'
};

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

```go Deny
package main

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

func main() {

	url := "http://localhost:8100/v1/hooks/nemo-relay"

	payload := strings.NewReader("{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"\"\n  },\n  \"tool_name\": \"search\"\n}")

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

	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 Deny
require 'uri'
require 'net/http'

url = URI("http://localhost:8100/v1/hooks/nemo-relay")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"\"\n  },\n  \"tool_name\": \"search\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8100/v1/hooks/nemo-relay")
  .header("Content-Type", "application/json")
  .body("{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"\"\n  },\n  \"tool_name\": \"search\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8100/v1/hooks/nemo-relay', [
  'body' => '{
  "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
  "tool_input": {
    "query": ""
  },
  "tool_name": "search"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Deny
using RestSharp;

var client = new RestClient("http://localhost:8100/v1/hooks/nemo-relay");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"\"\n  },\n  \"tool_name\": \"search\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Deny
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
  "tool_input": ["query": ""],
  "tool_name": "search"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8100/v1/hooks/nemo-relay")! 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()
```

### Allow

**Request**

```json
{
  "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
  "tool_input": {
    "query": "guardrails"
  },
  "tool_name": "search"
}
```

**Response**

```json
{
  "decision": "allow"
}
```

**SDK Code**

```python Allow
import requests

url = "http://localhost:8100/v1/hooks/nemo-relay"

payload = {
    "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
    "tool_input": { "query": "guardrails" },
    "tool_name": "search"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Allow
const url = 'http://localhost:8100/v1/hooks/nemo-relay';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"hook_event_name":"NemoRelayToolConditionalExecutionGuardrail","tool_input":{"query":"guardrails"},"tool_name":"search"}'
};

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

```go Allow
package main

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

func main() {

	url := "http://localhost:8100/v1/hooks/nemo-relay"

	payload := strings.NewReader("{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"guardrails\"\n  },\n  \"tool_name\": \"search\"\n}")

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

	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 Allow
require 'uri'
require 'net/http'

url = URI("http://localhost:8100/v1/hooks/nemo-relay")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"guardrails\"\n  },\n  \"tool_name\": \"search\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8100/v1/hooks/nemo-relay")
  .header("Content-Type", "application/json")
  .body("{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"guardrails\"\n  },\n  \"tool_name\": \"search\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8100/v1/hooks/nemo-relay', [
  'body' => '{
  "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
  "tool_input": {
    "query": "guardrails"
  },
  "tool_name": "search"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Allow
using RestSharp;

var client = new RestClient("http://localhost:8100/v1/hooks/nemo-relay");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"hook_event_name\": \"NemoRelayToolConditionalExecutionGuardrail\",\n  \"tool_input\": {\n    \"query\": \"guardrails\"\n  },\n  \"tool_name\": \"search\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Allow
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "hook_event_name": "NemoRelayToolConditionalExecutionGuardrail",
  "tool_input": ["query": "guardrails"],
  "tool_name": "search"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8100/v1/hooks/nemo-relay")! 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()
```