> This page is for version Latest (default).
> 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.

# Create a Guarded Response

POST /v1/responses
Content-Type: application/json

This page describes the built-in native OpenAI guard boundary at an
example URL. Provider mounts and path prefixes can change the route.
Set `store` to `false` and `stream` to `true` for SSE. Enabled Rails checks
depend on configuration.

Inspect the [request](/nemo/guardrails/latest/reference/gateway-guard-contracts/responses#request),
[response](/nemo/guardrails/latest/reference/gateway-guard-contracts/responses#response), and
[stream](/nemo/guardrails/latest/reference/gateway-guard-contracts/responses#stream) guard declarations.
The parameter list omits disabled fields; the request contract
retains their declarations.

See [field-policy meanings](/nemo/guardrails/latest/run-guardrailed-inference/using-gateway/guard-contracts#read-the-field-policy),
[supported input and output](/nemo/guardrails/latest/run-guardrailed-inference/using-gateway/providers-and-streaming#coverage-of-the-shipped-profiles),
and [streaming completion and errors](/nemo/guardrails/latest/run-guardrailed-inference/using-gateway/providers-and-streaming#completion-and-errors).
Field types describe gateway validation; consult the
[provider reference](https://developers.openai.com/api/reference/resources/responses/methods/create)
for upstream requirements. Replace `example-model` with a model available
from your provider.


Reference: https://docs.nvidia.com/nemo/guardrails/reference/gateway-api/responses

## Request

### Body (application/json)

This endpoint expects an object.

- `input` (string, required) — Guarded Text selected for input checks when enabled in the Rails configuration.
- `store` (false, required) — Constrained The gateway enforces the declared value and shape restrictions.
- `background` (false, optional, default: false) — Constrained The gateway enforces the declared value and shape restrictions.
- `max_output_tokens` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `max_tool_calls` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `metadata` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `model` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `moderation` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `parallel_tool_calls` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `prompt_cache_key` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `prompt_cache_options` (V1ResponsesPostRequestBodyContentApplicationJsonSchemaPromptCacheOptions, optional, nullable) — Constrained The gateway enforces the declared value and shape restrictions.
- `prompt_cache_retention` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `reasoning` (V1ResponsesPostRequestBodyContentApplicationJsonSchemaReasoning, optional, nullable) — Constrained The gateway enforces the declared value and shape restrictions.
- `safety_identifier` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `service_tier` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `stream` (boolean, optional, default: false) — Constrained The gateway enforces the declared value and shape restrictions.
- `stream_options` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `temperature` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `text` (V1ResponsesPostRequestBodyContentApplicationJsonSchemaText, optional, nullable) — Constrained The gateway enforces the declared value and shape restrictions.
- `top_logprobs` (integer, optional, nullable) — Constrained The gateway enforces the declared value and shape restrictions.
- `top_p` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `truncation` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `user` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.

## Response

### 200

Provider-native JSON or SSE. The JSON example is an illustrative excerpt. Output restrictions apply only when output inspection is enabled. After SSE headers, failures are reported in the stream rather than by changing the HTTP status.

- `any`

## Errors

### 400 Bad Request Error

Invalid request path or framing, malformed JSON, or content rejected by Guardrails.

- `error` (OpenAIProxyErrorDetails, required) — Describe OpenAI-compatible details generated by the proxy.

### 405 Method Not Allowed Error

Request method rejected for a guarded or reserved operation.

- `error` (OpenAIProxyErrorDetails, required) — Describe OpenAI-compatible details generated by the proxy.

### 413 Content Too Large Error

Request body rejected by the proxy size limit.

- `error` (OpenAIProxyErrorDetails, required) — Describe OpenAI-compatible details generated by the proxy.

### 415 Unsupported Media Type Error

Request representation unsupported by the guarded proxy path.

- `error` (OpenAIProxyErrorDetails, required) — Describe OpenAI-compatible details generated by the proxy.

### 422 Unprocessable Entity Error

Request path, shape, or configured Guardrails unsupported by the guarded proxy path.

- `error` (OpenAIProxyErrorDetails, required) — Describe OpenAI-compatible details generated by the proxy.

### 502 Bad Gateway Error

Upstream forwarding or Guardrails processing failed in the proxy.

- `error` (OpenAIProxyErrorDetails, required) — Describe OpenAI-compatible details generated by the proxy.

## Types

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaPromptCacheOptions

Keep prompt caching compatible with foreground text generation. Unlisted fields and case aliases of declared fields are rejected by default.

- `comparison_response_id` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `mode` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.
- `prewarm` (false, optional, default: false) — Constrained The gateway enforces the declared value and shape restrictions.
- `ttl` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaReasoning

Allow reviewed reasoning controls, but no separate reasoning text input. Unlisted fields and case aliases of declared fields are rejected by default.

- `effort` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaText

Retain verbosity while restricting any supplied format to plain text. Unlisted fields and case aliases of declared fields are rejected by default.

- `format` (V1ResponsesPostRequestBodyContentApplicationJsonSchemaTextFormat, optional, nullable) — Constrained The gateway enforces the declared value and shape restrictions.
- `verbosity` (any, optional) — Opaque Forwarded without inspecting or validating its value or nested contents. Provider requirements still apply.

### OpenAIProxyErrorDetails

Describe OpenAI-compatible details generated by the proxy.

- `code` (string, required)
- `message` (string, required)
- `param` (string, required, nullable)
- `type` (string, required)

### V1ResponsesPostRequestBodyContentApplicationJsonSchemaTextFormat

Disallow structured-output instructions outside the guarded input. Unlisted fields and case aliases of declared fields are rejected by default.

- `type` ("text", required) — Constrained The gateway enforces the declared value and shape restrictions.

## Examples

**Request**

```json
{
  "input": "Hello!",
  "store": false,
  "model": "example-model"
}
```

**Response**

```json
{
  "id": "resp_example",
  "object": "response",
  "output": [
    {
      "content": [
        {
          "annotations": [],
          "logprobs": [],
          "text": "Hello!",
          "type": "output_text"
        }
      ],
      "id": "msg_example",
      "role": "assistant",
      "type": "message"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/responses"

payload = {
    "input": "Hello!",
    "store": False,
    "model": "example-model"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/responses';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"input":"Hello!","store":false,"model":"example-model"}'
};

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.example.com/v1/responses"

	payload := strings.NewReader("{\n  \"input\": \"Hello!\",\n  \"store\": false,\n  \"model\": \"example-model\"\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
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/responses")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"Hello!\",\n  \"store\": false,\n  \"model\": \"example-model\"\n}"

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.example.com/v1/responses")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"Hello!\",\n  \"store\": false,\n  \"model\": \"example-model\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/responses', [
  'body' => '{
  "input": "Hello!",
  "store": false,
  "model": "example-model"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/responses");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"Hello!\",\n  \"store\": false,\n  \"model\": \"example-model\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "input": "Hello!",
  "store": false,
  "model": "example-model"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/responses")! 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()
```