REST API or Streaming or WebSocket Connection Method
Focus
Focus
Prisma AIRS

REST API or Streaming or WebSocket Connection Method

Table of Contents


REST API or Streaming or WebSocket Connection Method

Use Rest API or Streaming or WebSocket connection method for adding targets.
Use this information in this section to configure a custom method for connecting to the endpoint, either Rest API or Streaming or WebSocket.
About Rest API and Streaming Connection Methods
AI Red Teaming supports REST and streaming APIs as targets. If you are using a model hosted on Hugging Face or a model served by OpenAI there are pre-configured connection methods also available which will make it easier for you to configure your target.
If you are adding a REST or streaming API endpoint, you need to select if it is a public endpoint that can be accessed over the internet or a private endpoint. If you are using a private endpoint, you can select either:
  • IP Allowlist—A static IP address is shown that will be used by AI Red Teaming to access your target. Make a note of this IP address as it will have to be allowed by your infrastructure or IT team to be able to access the Target.
  • Network Channels—Private channels for endpoint connectivity.
WebSocket Connection Method
AI Red Teaming supports WebSocket as a connection method for AI targets, enabling you to scan real-time, streaming, and full-duplex AI applications with the same automated AI Red Teaming capabilities available for REST API targets. The WebSocket connection method provides AI Red Teaming connectivity to AI applications that communicate exclusively over WebSocket protocols. This native integration eliminates the need to create custom wrapper APIs or proxy services to translate between REST API and WebSocket communications.
WebSocket connection method is available for all AI Red Teaming target types: Models, Applications, and Agents.
WebSocket does not support:
  • Support Sessions
  • Multi-Turn Configuration
Supported Authentication Methods
AI Red Teaming supports multiple authentication methods to securely connect to target APIs during red teaming scans. You can configure authentication using one of three methods:
  • Using Headers—Static header-based authentication for APIs that accept long-lived credentials such as API keys or bearer tokens.
  • Using Payload—Credentials included directly in the JSON request body alongside the prompt, for APIs that expect username and password fields in the request payload.
  • OAuth 2.0—OAuth 2.0 client credentials flow for APIs that issue short-lived access tokens, with automatic token refresh to ensure uninterrupted scan execution.
  1. After specifying Target Details, set the Connection Method to Rest API or Streaming or WebSocket.
  2. Configure Endpoint Accessibility. This field indicates if your endpoint is Public or Private (secured within a private network).
    1. Select IP Allowlist. To establish a successful connection, certain IP addresses must be allowed by your firewall. These IP addresses are region-specific, so you should allow the specific IP addresses shown in the tooltip within your interface.
    2. Select Network Channels to configure private channels for endpoint connectivity. If a network channel was previously configured, it appears as an option in a drop-down menu.
  3. (Rest API and Streaming connections only) Select Next: Choose Method. Use this page to select whether you want to import a cURL string, or enter the details manually.
    To configure the API request, you can use a cURL to import a sample request, or manually configure the request:
    • Using a cURL to import sample Request—The easiest method to import the request format is to use a cURL string that captures all the necessary headers for your request. Once you click next AI Red Teaming will extract all the necessary information from the cURL string.
    • Manually configure all headers—You can configure the API endpoint and all necessary headers by selecting the Manual Entry option.
    1. Configure the input request JSON based on the requirement of your application. Make sure the value where the user prompt is expected is replaced with {INPUT}. This is the value where AI Red Teaming will add its attack prompts and send to the target application.
      For example, if your cURL string is as follows:
      curl \ -X POST \ -H "Authorization: <api_token>" \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "<prompt>" } ], "temperature": 0.7 }' \ https://<model_endpoint_url>
      Replace the <prompt> with {INPUT}.
      To accommodate testing with different system prompts and hyperparameters without modifying the original request, the following approach can be implemented:
      • Multiple Targets with Different System Prompts. When testing different system prompts on the same model, you can create multiple target configurations with identical settings except for the system prompt. This allows for direct comparison of the impact of different system prompts while keeping other variables constant.
      • Hyperparameter Testing. For testing other hyperparameters:
        1. Create separate target configurations for each set of hyperparameters you want to test.
        2. Keep all other settings identical across these targets, changing only the specific hyperparameter(s) you're evaluating.
  4. Select Next: Add/Verify Parameters.
    1. In the Add/Verify Parameters page, enter API Details. This URL represents the API endpoint. For example, https://api.openai.com/v1/chat/completions.
    2. (For WebSocket Connection Only) Enable Supports Streaming to allow WebSocket targets to send streamed responses (that complies with OpenAI standard of streaming over websocket connections).
    3. (For Manual Entry method only) (Rest API and Streaming connections only) Configure the Multi-Turn session parameters. The Multi-Turn session enables sophisticated AI Red Teaming scenarios by maintaining conversation context across multiple turns for LLM target types. Unlike single-turn attacks that send isolated prompts, multi-turn attacks simulate real-world conversational interactions, allowing security teams to test how LLMs handle context, memory, and state across multiple conversation turns. Configure Supports Sessions option to specify whether the API end point supports session management for maintaining conversation context.
      This Multi-Turn session supports two distinct operational modes: stateless mode and stateful mode.
      • To enable stateful mode where session IDs maintain context across requests with the API managing conversation history server-side, set Supports Sessions to Yes. When configured as Yes, you must edit the Multi-Turn Session Configuration settings in Verify & Edit JSON step.
      • To enable stateless mode where the full conversation history is sent with each request, set Supports Sessions to No. When configured as No, you must add the Multi-Turn Configuration settings in Verify & Edit JSON step.
    4. Next, determine if you want to enable HTTP Headers. Use this option to enter any custom HTTP headers required for connection or authentication. Once enabled, a list of configured HTTP Headers appears.
      You can delete an existing header, or, click Add New for a new HTTP header.
    5. (Optional) Configure authentication for the target.
      You can configure authentication for AI Red Teaming to connect to the target API using header-based credentials, payload credentials, or OAuth 2.0.
  5. In the Verify & Edit JSON page, configure the API Response.
    Specify the JSON structure of the request and response.
    The easiest way to configure the Response is to first get a sample response from your target and paste the entire JSON here. Then replace the LLM output with {RESPONSE}. This is the value that will be used to determine if the response was a successful attack or a failed attack. For example, if the response structure is as follows:
    { "id": "", "object": "chat.completion", "created": 1732070187, "model": "meta-llama-3.1", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "It seems like you haven't provided any input yet. Could you please provide more context or information about what you need help with?" }, "finish_reason": "stop", "logprobs": null } ] }
    Paste the payload as it and replace the value for the key content with {RESPONSE}, like as follows:
    { "id": "", "object": "chat.completion", "created": 1732070187, "model": "meta-llama-3.1", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "{RESPONSE}" }, "finish_reason": "stop", "logprobs": null } ] }
    (Optional) (Rest API and Streaming connections only) Multi-Turn Configuration
    (When Supports Sessions is configured as No) Configure the Multi-Turn Configuration parameters optionally. You can enable or disable Multi-Turn Configuration.
    Refer the relevant target API documentation to determine the appropriate roles for each specific target. Below are sample targets with their corresponding roles provided as examples.
    • For OpenAI target types, edit the Multi-Turn Configuration by setting the "assistant_role" field to "assistant" in the JSON configuration.
    • For Gemini target types, edit the Multi-Turn Configuration by setting the "assistant_role" field to "model" in the JSON configuration.
    (Optional) (Rest API and Streaming connections only) Multi-Turn Session Configuration
    (When Supports Sessions is configured as Yes) Configure the Multi-Turn Session Configuration optionally. This configuration enables AI Red Teaming capabilities for the target Interactions API endpoint with session management and streaming response support. You can enable or disable Multi-Turn Session Configuration.
    Refer the relevant target API documentation to determine the appropriate session fields for each specific target. Below are sample targets with their corresponding session fields provided as examples.
    The below example configuration is provided for Gemini and OpenAI target types.
    Multi-Turn Session ConfigurationDescription
    response_id_fieldThe unique identifier for the response.
    request_id_fieldThe ID of the previous interaction (if any).
  6. (Optional) Enable Supports File Upload if your target accepts file uploads and to perform file-based attack Testing. It enables AI Red Teaming to deliver documents with malicious prompts alongside text-based attacks when running an Attack Library scan against this target. PDF and Markdown (MD) file formats are supported.
    File-based Attack Testing is supported for REST API, Streaming, and WebSocket connection methods on Application and Agent target types.
    When you enable Supports File Upload, configure how AI Red Teaming delivers file content in the API request body. The configuration section expands below the Request JSON body.
    1. (If you used cURL import) Review the auto-detected file field mapping. AI Red Teaming detects the file content field and MIME type field from your cURL command and displays them for confirmation. Select Edit Mapping to adjust the detected field names if the auto-detection result is incorrect.
    2. (If you used Manual Entry) Configure the file delivery fields manually in the the Request JSON body:
      Request JSON FieldDescription
      files
      The JSON key in your request body where AI Red Teaming places the file content.
      It is an array of file objects that AI Red Teaming delivers to the target as part of a file-based attack. When a scan runs with Supports File Upload enabled, AI Red Teaming populates this array with malicious documents from its curated library (PDFs or MD files).
      mime_typeThe JSON key in your request body where AI Red Teaming places the file MIME type. The {mime_type} placeholder is replaced with the appropriate type at scan time.
      dataThe actual content of the file with malicious prompts that is base64-encoded. The {data} placeholder is replaced at scan time with the base64-encoded contents of the attack document.
    3. Review the request JSON preview to confirm how a file attack will be formatted in the API request body before saving.
  7. Click Next: Advanced Configurations.
    In the Advanced Configurations page you'll configure Rate Limits and set Guardrails/Content Filters.
    For WebSocket connections, only endpoint rate limiting can be configured. Rate limits and content guardrails error handling are not currently supported.
  8. (Optional) Enable Rate Limits for applications on the target endpoint.
    1. Specify the Endpoint Rate Limit. This value represents the maximum number of allowed requests per minute for the specified endpoint.
    2. (Rest API and Streaming Connection Method only) Specify the Endpoint Rate Limit Error Code. This field represents the error code your system uses for rate limiting violations.
    3. (Rest API and Streaming Connection Method only) Provide a Sample Exception JSON.
  9. (Optional) (Rest API and Streaming Connection Method only) Enable Guardrails/Content Filters. These fields are used for output guardrails or content filters applicable on the target endpoint.
    1. (Rest API and Streaming Connection Method only) Specify the Error code for Guardrails or Content Filters. This field represents the error code your system uses when a response is prevented by filters or safeguards.
    2. (Rest API and Streaming Connection Method only) Provide a Sample Exception JSON.
    3. Select Validate Target.
      Only after a target is successfully validated, you can add target background information.
  10. (Mandatory) Configure Target Background.
    AI Red Teaming collects and organizes the Target background information about your target endpoint. Target background encompasses mandatory elements such as, industry classification, use case definition, and competitive landscape analysis, along with optional documentation uploads including company policy documents and other relevant materials.
    Target background information is mandatory for all the target types.
    1. Add Industry information.
    2. Add Use Case, that is specific role of the target such as customer service or additional comments.
    3. (Optional) Select Add Competitor to add the list of Competitors.
    4. Enable Agentic Profiling.
      Agentic Profiling in AI Red Teaming helps gather all relevant context about a target endpoint such as its business use case, background, key capabilities, technical architecture and other critical information. This is carried out by an autonomous agent probing the target endpoint with the right prompts. All information gathered through this exercise is presented as the Target's profile and is used downstream in AI Red Teaming Scans using the Agent.
  11. Select Submit.
    Once the target is created you can start a scan, or view previously created targets: