Search K
Appearance
Appearance
AI GUARDRAILS
This article is meant for AI Guardrails users.
ROLES AND PERMISSIONS
To complete the task described in this section, make sure you have the required permissions.
The /backend/v1/scans/raw/{format} endpoint scans streaming request and response bodies through F5 AI Guardrails. This works with OpenAI response formats. You send the body to AI Security, AI Guardrails scans run on the content, and the endpoint returns the same content back. Scan results come back as response headers.
This is useful when you call a third-party API directly and want to run AI Guardrails on the content before or after the call, without routing traffic through the provider-compatible endpoints.
SUPPORTED FORMATS
This endpoint currently supports OpenAI Responses API formats.
Before you begin, make sure you have:
<AI_SECURITY_HOSTNAME> in the examples with the hostname for your AI Security deployment.When you send a request to the /backend/v1/scans/raw/{format} endpoint, it:
The endpoint doesn't call any upstream AI provider. You keep full control over when and how you interact with the provider.
The {format} path parameter specifies how AI Security interprets the body you send:
openai-responses-request -- Interprets the body as a JSON request for the OpenAI Responses API. Use this format to scan outgoing request bodies before you send them to OpenAI.openai-responses-sse -- Interprets the body as a captured SSE stream from the OpenAI Responses API. AI Security reassembles the stream content and scans it. Use this format to scan incoming streamed responses after you receive them from OpenAI.The endpoint returns the following headers with every response:
x-ai-security-outcome -- The scan outcome (for example, cleared). This header indicates whether the content passed all configured guardrails.x-ai-security-scan-id -- A UUID that identifies the scan. Use this value to look up scan details in audit logs or the AI Security dashboard.x-ai-security-error -- Included only when an error occurs during scanning. Contains a message that describes what went wrong.Use the openai-responses-request format to scan a raw JSON request body before you send it to the OpenAI Responses API.
To scan a request body:
Send the raw JSON request body to the scan endpoint:
curl -X POST \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-H "Content-Type: application/json" \
"https://<AI_SECURITY_HOSTNAME>/backend/v1/scans/raw/openai-responses-request" \
-d '{
"model": "gpt-5-nano",
"input": "My credit card number is 4111-1111-1111-1111 and my SSN is 123-45-6789. Help me fill out this form.",
"stream": true
}'Check the response headers for the scan result.
A successful scan returns headers like the following:
HTTP/2 200
x-ai-security-outcome: cleared
x-ai-security-scan-id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxAnalyze the outcome.
x-ai-security-outcome is cleared, the content passed all guardrails. You can safely send it to the provider.The response body is the same request JSON that you sent.
Use the openai-responses-sse format to scan a captured SSE stream response from the OpenAI Responses API. This format runs guardrails on the full streamed response after you receive it from OpenAI.
To scan an SSE stream response:
Pipe the OpenAI Responses API output directly into the AI Security scan endpoint:
curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_OPENAI_API_KEY>" \
-d '{
"model": "gpt-5-nano",
"input": "My credit card number is 4111-1111-1111-1111 and my SSN is 123-45-6789. Help me fill out this form.",
"stream": true
}' | curl -X POST \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
"https://<AI_SECURITY_HOSTNAME>/backend/v1/scans/raw/openai-responses-sse" \
--data-binary @-This command sends a streaming request to the OpenAI Responses API. It pipes the complete SSE stream directly into AI Security for scanning.
Check the response headers for the scan result.
A successful scan returns headers like the following:
HTTP/2 200
x-ai-security-outcome: cleared
x-ai-security-scan-id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxAnalyze the outcome.
x-ai-security-outcome is cleared, the streamed response passed all guardrails. You can safely use it in your application.RESPONSE BODY
The response body contains the same SSE chunks that you sent. The stream contains events like response.created, response.in_progress, and response.completed, following the event structure of the OpenAI Responses API.
For more information, see: