openapi: 3.1.0
info:
  title: LLM Proxy
  description: >-
    HiddenLayer LLM-Proxy is a service that provides detection and response
    capabilities for Generative AI solutions in the HiddenLayer AI Security
    Platform.


    {% admonition type="warning" name="Locally deployed AIDR proxy in Hybrid
    mode" %}

    - The LLM Proxy API endpoint is supported only for a locally deployed AIDR
    proxy running in Hybrid mode. This API is not supported in HiddenLayer SaaS.

    - The documentation is presented here on the documentation portal to help
    reduce confusion between a locally running proxy and the SaaS proxy.

    - For more API documentation, see the <a href="https://dev.hiddenlayer.ai/"
    target="_blank">HiddenLayer Developer Portal</a>.

    {% /admonition %}
  version: '1'
servers:
  - url: https://<YOUR-SELF-HOSTED-AIDR-INSTANCE-ENDPOINT>/
    description: Self-hosted server
security:
  - {}
paths:
  /metrics:
    get:
      summary: Metrics
      description: Return prometheus formatted metrics
      operationId: metrics
      responses:
        '200':
          description: Response with prometheus formatted metrics
          content:
            text/plain:
              schema:
                type: string
      tags:
        - Health and Metrics
  /v1/chat/completions:
    parameters:
      - $ref: '#/components/parameters/ProjectParameter'
      - $ref: '#/components/parameters/RequesterIdParameter'
      - $ref: '#/components/parameters/BlockUnsafeHeader'
      - $ref: '#/components/parameters/BlockUnsafeInputHeader'
      - $ref: '#/components/parameters/BlockUnsafeOutputHeader'
      - $ref: '#/components/parameters/SkipPromptInjectionDetectionHeader'
      - $ref: '#/components/parameters/BlockPromptInjectionHeader'
      - $ref: '#/components/parameters/PromptInjectionScanTypeHeader'
      - $ref: '#/components/parameters/SkipInputDOSDetectionHeader'
      - $ref: '#/components/parameters/BlockInputDOSDetectionHeader'
      - $ref: '#/components/parameters/InputDOSDetectionThresholdHeader'
      - $ref: '#/components/parameters/SkipInputPIIDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockInputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/RedactInputPIIHeader'
      - $ref: '#/components/parameters/RedactOutputPIIHeader'
      - $ref: '#/components/parameters/RedactTypeHeader'
      - $ref: '#/components/parameters/EntityTypeHeader'
      - $ref: '#/components/parameters/SkipInputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockInputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipGuardrailDetectionHeader'
      - $ref: '#/components/parameters/BlockGuardrailDetectionHeader'
      - $ref: '#/components/parameters/SkipInputURLDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputURLDetectionHeader'
    post:
      summary: Reverse Proxy OpenAI Chat completions
      description: Generate completions for a given prompt
      operationId: reverseProxyOpenAICompletions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIChatCompletionsRequest'
            example:
              model: gpt-3.5-turbo
              messages:
                - role: user
                  content: Hello World!
              temperature: 1
              max_tokens: 256
              top_p: 1
              frequency_penalty: 0
              presence_penalty: 0
      responses:
        '200':
          description: Successful chat completions response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIChatCompletionsResponse'
              example:
                choices:
                  - finish_reason: stop
                    index: 0
                    message:
                      - role: assistant
                        content: Hello, how can I help you today?
                    logprobs: null
                created: 1640000000
                id: chatcmpl-7QyqpwdfhqwajicIEznoc6Q47XAyW
                model: gpt-3.5-turbo-0613
                object: chat.completion
                usage:
                  completion_tokens: 17
                  prompt_tokens: 15
                  total_tokens: 32
        '502':
          description: Error from upstream service
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'OpenAI returned a non 200 response code: 400'
      tags:
        - OpenAI
  /api/v1/proxy/openai/chat/completions:
    parameters:
      - $ref: '#/components/parameters/ProjectParameter'
      - $ref: '#/components/parameters/RequesterIdParameter'
      - $ref: '#/components/parameters/BlockUnsafeHeader'
      - $ref: '#/components/parameters/BlockUnsafeInputHeader'
      - $ref: '#/components/parameters/BlockUnsafeOutputHeader'
      - $ref: '#/components/parameters/SkipPromptInjectionDetectionHeader'
      - $ref: '#/components/parameters/BlockPromptInjectionHeader'
      - $ref: '#/components/parameters/PromptInjectionScanTypeHeader'
      - $ref: '#/components/parameters/SkipInputDOSDetectionHeader'
      - $ref: '#/components/parameters/BlockInputDOSDetectionHeader'
      - $ref: '#/components/parameters/InputDOSDetectionThresholdHeader'
      - $ref: '#/components/parameters/SkipInputPIIDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockInputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/RedactInputPIIHeader'
      - $ref: '#/components/parameters/RedactOutputPIIHeader'
      - $ref: '#/components/parameters/RedactTypeHeader'
      - $ref: '#/components/parameters/EntityTypeHeader'
      - $ref: '#/components/parameters/SkipInputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockInputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipGuardrailDetectionHeader'
      - $ref: '#/components/parameters/BlockGuardrailDetectionHeader'
      - $ref: '#/components/parameters/SkipInputURLDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputURLDetectionHeader'
    post:
      summary: Proxy OpenAI Chat completions
      description: Generate completions for a given prompt and return response and analysis
      operationId: proxyOpenAIChatCompletions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIChatCompletionsRequest'
            example:
              model: gpt-3.5-turbo
              messages:
                - role: user
                  content: Hello World!
              temperature: 1
              max_tokens: 256
              top_p: 1
              frequency_penalty: 0
              presence_penalty: 0
      responses:
        '200':
          description: Successful chat completions and analysis response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/HiddenLayerProxyOpenAIResponse'
        '502':
          description: Error from upstream service
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'OpenAI returned a non 200 response code: 400'
      tags:
        - OpenAI
  /api/v1/proxy/azure/{endpoint_name}/score:
    parameters:
      - $ref: '#/components/parameters/ProjectParameter'
      - $ref: '#/components/parameters/RequesterIdParameter'
      - $ref: '#/components/parameters/AzureEndpointNamePathParameter'
      - $ref: '#/components/parameters/BlockUnsafeHeader'
      - $ref: '#/components/parameters/BlockUnsafeInputHeader'
      - $ref: '#/components/parameters/BlockUnsafeOutputHeader'
      - $ref: '#/components/parameters/SkipPromptInjectionDetectionHeader'
      - $ref: '#/components/parameters/BlockPromptInjectionHeader'
      - $ref: '#/components/parameters/PromptInjectionScanTypeHeader'
      - $ref: '#/components/parameters/SkipInputDOSDetectionHeader'
      - $ref: '#/components/parameters/BlockInputDOSDetectionHeader'
      - $ref: '#/components/parameters/InputDOSDetectionThresholdHeader'
      - $ref: '#/components/parameters/SkipInputPIIDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockInputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/RedactInputPIIHeader'
      - $ref: '#/components/parameters/RedactOutputPIIHeader'
      - $ref: '#/components/parameters/RedactTypeHeader'
      - $ref: '#/components/parameters/EntityTypeHeader'
      - $ref: '#/components/parameters/SkipInputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockInputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipGuardrailDetectionHeader'
      - $ref: '#/components/parameters/BlockGuardrailDetectionHeader'
      - $ref: '#/components/parameters/SkipInputURLDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputURLDetectionHeader'
      - in: query
        name: region
        required: false
        schema:
          type: string
        description: The region of the Azure endpoint
    post:
      summary: Proxy Azure endpoint
      description: >-
        Generate text or chat completions for a given Azure endpoint and return
        response and analysis
      operationId: proxyAzureEndpointScore
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/AzureChatCompletionsRequest'
                - $ref: '#/components/schemas/AzureTextCompletionsRequest'
      responses:
        '200':
          description: Successful chat completions and analysis response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/HiddenLayerProxyAzureTextCompletionsResponse
                  - $ref: >-
                      #/components/schemas/HiddenLayerProxyAzureChatCompletionsResponse
        '502':
          description: Error from upstream service
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'Azure returned a non 200 response code: 400'
      tags:
        - Azure
  /api/v1/proxy/azure/{endpoint_name}/{deployment_name}:
    parameters:
      - $ref: '#/components/parameters/ProjectParameter'
      - $ref: '#/components/parameters/RequesterIdParameter'
      - $ref: '#/components/parameters/AzureEndpointNamePathParameter'
      - $ref: '#/components/parameters/BlockUnsafeHeader'
      - $ref: '#/components/parameters/BlockUnsafeInputHeader'
      - $ref: '#/components/parameters/BlockUnsafeOutputHeader'
      - $ref: '#/components/parameters/SkipPromptInjectionDetectionHeader'
      - $ref: '#/components/parameters/BlockPromptInjectionHeader'
      - $ref: '#/components/parameters/PromptInjectionScanTypeHeader'
      - $ref: '#/components/parameters/SkipInputDOSDetectionHeader'
      - $ref: '#/components/parameters/BlockInputDOSDetectionHeader'
      - $ref: '#/components/parameters/InputDOSDetectionThresholdHeader'
      - $ref: '#/components/parameters/SkipInputPIIDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockInputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/RedactInputPIIHeader'
      - $ref: '#/components/parameters/RedactOutputPIIHeader'
      - $ref: '#/components/parameters/RedactTypeHeader'
      - $ref: '#/components/parameters/EntityTypeHeader'
      - $ref: '#/components/parameters/SkipInputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockInputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipGuardrailDetectionHeader'
      - $ref: '#/components/parameters/BlockGuardrailDetectionHeader'
      - $ref: '#/components/parameters/SkipInputURLDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputURLDetectionHeader'
      - in: path
        name: deployment_name
        required: true
        schema:
          type: string
        description: The name of the Azure endpoint deployment to use
      - in: query
        name: subscription_id
        required: true
        schema:
          type: string
        description: The subscription id of the Azure endpoint
      - in: query
        name: resource_group
        required: true
        schema:
          type: string
        description: The resource group of the Azure endpoint
      - in: query
        name: workspace
        required: true
        schema:
          type: string
        description: The workspace of the Azure endpoint
      - in: query
        name: region
        required: true
        schema:
          type: string
        description: The region of the Azure endpoint
    post:
      summary: Proxy Azure endpoint and deployment using Azure Entra
      description: >-
        Generate text or chat completions for a given Azure endpoint and return
        response and analysis
      operationId: proxyAzureEndpointEntra
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/AzureChatCompletionsRequest'
                - $ref: '#/components/schemas/AzureTextCompletionsRequest'
      responses:
        '200':
          description: Successful chat completions and analysis response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/HiddenLayerProxyAzureTextCompletionsResponse
                  - $ref: >-
                      #/components/schemas/HiddenLayerProxyAzureChatCompletionsResponse
        '502':
          description: Error from upstream service
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'Azure returned a non 200 response code: 400'
      tags:
        - Azure
  /tgi{name}/v1/chat/completions:
    parameters:
      - $ref: '#/components/parameters/ProjectParameter'
      - $ref: '#/components/parameters/RequesterIdParameter'
      - $ref: '#/components/parameters/BlockUnsafeHeader'
      - $ref: '#/components/parameters/BlockUnsafeInputHeader'
      - $ref: '#/components/parameters/BlockUnsafeOutputHeader'
      - $ref: '#/components/parameters/SkipPromptInjectionDetectionHeader'
      - $ref: '#/components/parameters/BlockPromptInjectionHeader'
      - $ref: '#/components/parameters/PromptInjectionScanTypeHeader'
      - $ref: '#/components/parameters/SkipInputDOSDetectionHeader'
      - $ref: '#/components/parameters/BlockInputDOSDetectionHeader'
      - $ref: '#/components/parameters/InputDOSDetectionThresholdHeader'
      - $ref: '#/components/parameters/SkipInputPIIDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockInputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/RedactInputPIIHeader'
      - $ref: '#/components/parameters/RedactOutputPIIHeader'
      - $ref: '#/components/parameters/RedactTypeHeader'
      - $ref: '#/components/parameters/EntityTypeHeader'
      - $ref: '#/components/parameters/SkipInputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockInputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipGuardrailDetectionHeader'
      - $ref: '#/components/parameters/BlockGuardrailDetectionHeader'
      - $ref: '#/components/parameters/SkipInputURLDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputURLDetectionHeader'
      - $ref: '#/components/parameters/HuggingFaceTGIEndpointNamePathParameter'
    post:
      summary: Reverse Proxy HuggingFace TGI endpoint
      description: Generate completions for a HuggingFace TGI endpoint
      operationId: reverseProxyHuggingFaceTGICompletions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIChatCompletionsRequest'
            example:
              model: tgi-model
              messages:
                - role: user
                  content: Hello World!
              temperature: 1
              max_tokens: 256
              top_p: 1
              frequency_penalty: 0
              presence_penalty: 0
      responses:
        '200':
          description: Successful HuggingFace TGI response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIChatCompletionsResponse'
              example:
                choices:
                  - finish_reason: stop
                    index: 0
                    message:
                      - role: assistant
                        content: Hello, how can I help you today?
                    logprobs: null
                created: 1640000000
                id: null
                model: tgi-model
                object: chat.completion
                usage:
                  completion_tokens: 17
                  prompt_tokens: 15
                  total_tokens: 32
        '502':
          description: Error from upstream service
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'OpenAI returned a non 200 response code: 400'
      tags:
        - HuggingFace TGI
  /api/v1/proxy/tgi/{name}:
    parameters:
      - $ref: '#/components/parameters/ProjectParameter'
      - $ref: '#/components/parameters/RequesterIdParameter'
      - $ref: '#/components/parameters/BlockUnsafeHeader'
      - $ref: '#/components/parameters/BlockUnsafeInputHeader'
      - $ref: '#/components/parameters/BlockUnsafeOutputHeader'
      - $ref: '#/components/parameters/SkipPromptInjectionDetectionHeader'
      - $ref: '#/components/parameters/BlockPromptInjectionHeader'
      - $ref: '#/components/parameters/PromptInjectionScanTypeHeader'
      - $ref: '#/components/parameters/SkipInputDOSDetectionHeader'
      - $ref: '#/components/parameters/BlockInputDOSDetectionHeader'
      - $ref: '#/components/parameters/InputDOSDetectionThresholdHeader'
      - $ref: '#/components/parameters/SkipInputPIIDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockInputPIIDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputPIIDetectionHeader'
      - $ref: '#/components/parameters/RedactInputPIIHeader'
      - $ref: '#/components/parameters/RedactOutputPIIHeader'
      - $ref: '#/components/parameters/RedactTypeHeader'
      - $ref: '#/components/parameters/EntityTypeHeader'
      - $ref: '#/components/parameters/SkipInputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockInputCodeDetectionHeader'
      - $ref: '#/components/parameters/BlockOutputCodeDetectionHeader'
      - $ref: '#/components/parameters/SkipGuardrailDetectionHeader'
      - $ref: '#/components/parameters/BlockGuardrailDetectionHeader'
      - $ref: '#/components/parameters/SkipInputURLDetectionHeader'
      - $ref: '#/components/parameters/SkipOutputURLDetectionHeader'
      - $ref: '#/components/parameters/HuggingFaceTGIEndpointNamePathParameter'
    post:
      summary: Proxy HuggingFace TGI Endpoint
      description: >-
        Proxy chat completions for a given HuggingFace TGI endpoint and return
        response and analysis
      operationId: proxyHuggingFaceTGICompletions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIChatCompletionsRequest'
            example:
              model: tgi-model
              messages:
                - role: user
                  content: Hello World!
              temperature: 1
              max_tokens: 256
              top_p: 1
              frequency_penalty: 0
              presence_penalty: 0
      responses:
        '200':
          description: Successful chat completions and analysis response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/HiddenLayerProxyHuggingFaceTGIResponse
        '502':
          description: Error from upstream service
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'OpenAI returned a non 200 response code: 400'
      tags:
        - HuggingFace TGI
components:
  parameters:
    HuggingFaceTGIEndpointNamePathParameter:
      in: path
      name: name
      required: true
      schema:
        type: string
      description: The name of the TGI endpoint defined in service settings
    RequesterIdParameter:
      in: header
      name: X-Requester-Id
      required: false
      schema:
        type: string
      description: The identifier for the requester to be used if MLDR is enabled
    AzureEndpointNamePathParameter:
      in: path
      name: endpoint_name
      required: true
      schema:
        type: string
      description: The name of the Azure endpoint to use
    BlockUnsafeHeader:
      in: header
      name: X-LLM-Block-Unsafe
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block unsafe input and output
    BlockUnsafeInputHeader:
      in: header
      name: X-LLM-Block-Unsafe-Input
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block unsafe input
    BlockUnsafeOutputHeader:
      in: header
      name: X-LLM-Block-Unsafe-Output
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block unsafe output
    SkipPromptInjectionDetectionHeader:
      in: header
      name: X-LLM-Skip-Prompt-Injection-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip prompt injection detection
    BlockPromptInjectionHeader:
      in: header
      name: X-LLM-Block-Prompt-Injection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block prompt injection
    PromptInjectionScanTypeHeader:
      in: header
      name: X-LLM-Prompt-Injection-Scan-Type
      required: false
      schema:
        $ref: '#/components/schemas/HiddenLayerAnalysisPromptInjectionEnum'
      description: The type of prompt injection scan to use
    SkipInputDOSDetectionHeader:
      in: header
      name: X-LLM-Skip-Input-DOS-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip input denial of service detection
    BlockInputDOSDetectionHeader:
      in: header
      name: X-LLM-Block-Input-DOS-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block input denial of service detection
    InputDOSDetectionThresholdHeader:
      in: header
      name: X-LLM-Input-DOS-Detection-Threshold
      required: false
      schema:
        type: string
        default: '4096'
      description: The threshold for input denial of service detection
    SkipInputPIIDetectionHeader:
      in: header
      name: X-LLM-Skip-Input-PII-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip input personally identifiable information detection
    SkipOutputPIIDetectionHeader:
      in: header
      name: X-LLM-Skip-Output-PII-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip output personally identifiable information detection
    BlockInputPIIDetectionHeader:
      in: header
      name: X-LLM-Block-Input-PII
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block input personally identifiable information detection
    BlockOutputPIIDetectionHeader:
      in: header
      name: X-LLM-Block-Output-PII
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block output personally identifiable information detection
    RedactInputPIIHeader:
      in: header
      name: X-LLM-Redact-Input-PII
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to redact input personally identifiable information
    RedactOutputPIIHeader:
      in: header
      name: X-LLM-Redact-Output-PII
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to redact output personally identifiable information
    RedactTypeHeader:
      in: header
      name: X-LLM-Redact-Type
      required: false
      schema:
        $ref: '#/components/schemas/HiddenLayerAnalysisRedactTypeEnum'
      description: The type of redaction to use
    EntityTypeHeader:
      in: header
      name: X-LLM-Entity-Type
      required: false
      schema:
        $ref: '#/components/schemas/HiddenLayerAnalysisEntityTypeEnum'
      description: The type of entity to redact
    SkipInputCodeDetectionHeader:
      in: header
      name: X-LLM-Skip-Input-Code-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip input code detection
    SkipOutputCodeDetectionHeader:
      in: header
      name: X-LLM-Skip-Output-Code-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip output code detection
    BlockInputCodeDetectionHeader:
      in: header
      name: X-LLM-Block-Input-Code-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block input code detection
    BlockOutputCodeDetectionHeader:
      in: header
      name: X-LLM-Block-Output-Code-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block output code detection
    SkipGuardrailDetectionHeader:
      in: header
      name: X-LLM-Skip-Guardrail-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip guardrail detection
    BlockGuardrailDetectionHeader:
      in: header
      name: X-LLM-Block-Guardrail-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to block guardrail detection
    SkipInputURLDetectionHeader:
      in: header
      name: X-LLM-Skip-Input-URL-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip input URL detection
    SkipOutputURLDetectionHeader:
      in: header
      name: X-LLM-Skip-Output-URL-Detection
      required: false
      schema:
        type: boolean
        default: false
      description: Whether to skip output URL detection
    ProjectParameter:
      in: header
      name: HL-Project-Id
      required: false
      schema:
        type: string
      description: The ID or alias for the Project to govern the request processing.
      example: internal-search-chatbot
  schemas:
    AzureCompletionParams:
      type: object
      description: The parameters to use for Azure completions
      properties:
        top_p:
          type: number
          description: The top p value to use for completions
        temperature:
          type: number
          description: The temperature to use for completions
        max_tokens:
          type: integer
          description: The maximum number of tokens to generate
        do_sample:
          type: boolean
          description: Whether to use sampling for completions
        return_full_text:
          type: boolean
          description: Whether to return the full text for completions
    AzureTextCompletionsRequest:
      type: object
      description: The request to an Azure Text Completions endpoint
      properties:
        input_data:
          type: array
          items:
            type: string
            description: The input data to use for text completions
        params:
          $ref: '#/components/schemas/AzureCompletionParams'
      example:
        input_data:
          - Hello World
        params:
          top_p: 1
          temperature: 1
          max_tokens: 256
          do_sample: true
          return_full_text: true
    AzureChatCompletionsRequest:
      type: object
      description: The request to an Azure Chat Completions endpoint
      properties:
        input_data:
          type: object
          properties:
            input_string:
              type: array
              items:
                type: object
                description: The input string by role to use for chat completions
                properties:
                  role:
                    type: string
                    description: The role of the message
                  content:
                    type: string
                    description: The content of the message
            params:
              $ref: '#/components/schemas/AzureCompletionParams'
      example:
        input_data:
          input_string:
            - role: user
              content: Hello World
          params:
            top_p: 1
            temperature: 1
            max_tokens: 256
            do_sample: true
            return_full_text: true
    OpenAIChatCompletionsRequest:
      type: object
      description: The request to an OpenAI Chat Completions endpoint
      properties:
        model:
          type: string
          description: The model to use for completions
        messages:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
                description: The role of the message
              content:
                type: string
                description: The content of the message
        temperature:
          type: number
          description: The temperature to use for completions
        max_tokens:
          type: number
          description: The maximum number of tokens to generate
        top_p:
          type: number
          description: The top p value to use for completions
        frequency_penalty:
          type: number
          description: The frequency penalty to use for completions
        presence_penalty:
          type: number
          description: The presence penalty to use for completions
    OpenAIChatCompletionsResponse:
      type: object
      description: The response from an OpenAI Chat Completions endpoint
      properties:
        choices:
          type: array
          items:
            type: object
            properties:
              finish_reason:
                type: string
                description: The reason the completion finished
              index:
                type: number
                description: The index of the completion
              message:
                type: array
                items:
                  type: object
                  properties:
                    role:
                      type: string
                      description: The role of the message
                    content:
                      type: string
                      description: The content of the message
              logprobs:
                type:
                  - 'null'
                  - string
                description: The logprobs of the completion
        created:
          type: number
          description: The timestamp of the completion
        id:
          type:
            - 'null'
            - string
          description: The id of the completion
        model:
          type: string
          description: The model used for the completion
        object:
          type: string
          description: The object of the completion
        usage:
          type: object
          properties:
            completion_tokens:
              type: number
              description: The number of completion tokens
            prompt_tokens:
              type: number
              description: The number of prompt tokens
            total_tokens:
              type: number
              description: The total number of tokens
    AzureTextCompletionsResponse:
      type: array
      description: The response from an Azure Text Completions endpoint
      items:
        type: string
        description: The response from an Azure Text Completions endpoint
      example:
        - Hello, how can I help you today?
    AzureChatCompletionsResponse:
      type: object
      description: The response from an Azure Chat Completions endpoint
      properties:
        output:
          type: string
          description: The output from an Azure Chat Completions endpoint
      example:
        output: Hello, how can I help you today?
    HiddenLayerAnalysisCategories:
      type: object
      description: The analysis detection categories
      properties:
        unsafe_input:
          type: boolean
          description: The input is unsafe
        unsafe_output:
          type: boolean
          description: The output is unsafe
        prompt_injection:
          type: boolean
          description: The input contains prompt injection
        input_dos:
          type: boolean
          description: The input contains a denial of service attack
        input_pii:
          type: boolean
          description: The input contains personally identifiable information
        output_pii:
          type: boolean
          description: The output contains personally identifiable information
        input_code:
          type: boolean
          description: The input contains code
        output_code:
          type: boolean
          description: The output contains code
        guardrail:
          type: boolean
          description: The input activated the upstream guardrails
    HiddenLayerAnalysisResults:
      type: object
      description: The analysis results
      properties:
        input_block_list_results:
          type: object
          description: The input block list results
          properties:
            verdict:
              type: boolean
              description: The verdict of the input block list analysis
            matches:
              type: array
              items:
                type: string
                description: The matches from the input block list analysis
            elapsed_ms:
              type: number
              description: The time in milliseconds it took to process the input block list
          example:
            verdict: true
            matches:
              - badToken
            elapsed_ms: 10
        prompt_injection_classifier_results:
          type: array
          items:
            type: object
            properties:
              version:
                type: number
                description: The version of the prompt injection classifier
              verdict:
                type: boolean
                description: The verdict of the prompt injection classifier
              probabilities:
                type: array
                items:
                  type: number
                  description: The probabilities of the prompt injection classifier
              elapsed_ms:
                type: number
                description: >-
                  The time in milliseconds it took to process the prompt
                  injection classifier
          example:
            - version: 1
              verdict: true
              probabilities:
                - 1
              elapsed_ms: 100
        input_dos_results:
          type: object
          description: The input denial of service results
          properties:
            verdict:
              type: boolean
              description: The verdict of the input denial of service analysis
            elapsed_ms:
              type: number
              description: >-
                The time in milliseconds it took to process the input denial of
                service
        input_pii_results:
          type: object
          description: The input personally identifiable information results
          properties:
            verdict:
              type: boolean
              description: >-
                The verdict of the input personally identifiable information
                analysis
            entities:
              type: array
              items:
                type: string
                description: >-
                  The entities that were identified from the input personally
                  identifiable information analysis
            elapsed_ms:
              type: number
              description: >-
                The time in milliseconds it took to process the input personally
                identifiable information
          example:
            verdict: true
            entities:
              - PHONE_NUMBER
            elapsed_ms: 20
        output_pii_results:
          type: object
          description: The output personally identifiable information results
          properties:
            verdict:
              type: boolean
              description: >-
                The verdict of the output personally identifiable information
                analysis
            entities:
              type: array
              items:
                type: string
                description: >-
                  The entities that were identified from the output personally
                  identifiable information analysis
            elapsed_ms:
              type: number
              description: >-
                The time in milliseconds it took to process the output
                personally identifiable information
          example:
            verdict: true
            entities:
              - LOCATION
            elapsed_ms: 20
        input_code_results:
          type: object
          description: The input code results
          properties:
            verdict:
              type: boolean
              description: The verdict of the input code analysis
            elapsed_ms:
              type: number
              description: The time in milliseconds it took to process the input code
        output_code_results:
          type: object
          description: The output code results
          properties:
            verdict:
              type: boolean
              description: The verdict of the output code analysis
            elapsed_ms:
              type: number
              description: The time in milliseconds it took to process the output code
        guardrail_results:
          type: object
          description: The guardrail results
          properties:
            verdict:
              type: boolean
              description: The verdict of the guardrail analysis
            elapsed_ms:
              type: number
              description: The time in milliseconds it took to process the guardrail
        input_urls:
          type: object
          description: The input URL results
          properties:
            urls:
              type: array
              items:
                type: string
                description: URLs found in the input
            elapsed_ms:
              type: number
              description: The time in milliseconds it took to process the guardrail
        output_urls:
          type: object
          description: The output URL results
          properties:
            urls:
              type: array
              items:
                type: string
                description: URLs found in the output
            elapsed_ms:
              type: number
              description: The time in milliseconds it took to process the guardrail
    HiddenLayerAnalysisPromptInjectionEnum:
      type: string
      description: The type of prompt injection scan to use
      enum:
        - quick
        - full
      default: quick
      example: quick
    HiddenLayerAnalysisRedactTypeEnum:
      type: string
      description: The type of redaction to use
      enum:
        - entity
        - strict
      default: entity
      example: entity
    HiddenLayerAnalysisEntityTypeEnum:
      type: string
      description: The type of entity to redact
      enum:
        - strict
        - all
      default: strict
      example: strict
    HiddenLayerAnalysisPolicy:
      type: object
      description: The policy used during analysis
      properties:
        block_unsafe:
          type: boolean
          description: Block unsafe input and output
          default: false
        block_unsafe_input:
          type: boolean
          description: Block unsafe input
          default: false
        block_unsafe_output:
          type: boolean
          description: Block unsafe output
        skip_prompt_injection_detection:
          type: boolean
          description: Skip prompt injection detection
        block_prompt_injection:
          type: boolean
          description: Block prompt injection
        prompt_injection_scan_type:
          $ref: '#/components/schemas/HiddenLayerAnalysisPromptInjectionEnum'
        skip_input_pii_detection:
          type: boolean
          description: Skip input personally identifiable information detection
        skip_output_pii_detection:
          type: boolean
          description: Skip output personally identifiable information detection
        block_input_pii:
          type: boolean
          description: Block input personally identifiable information
        block_output_pii:
          type: boolean
          description: Block output personally identifiable information
        redact_input_pii:
          type: boolean
          description: Redact input personally identifiable information
        redact_output_pii:
          type: boolean
          description: Redact output personally identifiable information
        redact_type:
          $ref: '#/components/schemas/HiddenLayerAnalysisRedactTypeEnum'
        entity_type:
          $ref: '#/components/schemas/HiddenLayerAnalysisEntityTypeEnum'
        skip_input_code_detection:
          type: boolean
          description: Skip input code detection
        skip_output_code_detection:
          type: boolean
          description: Skip output code detection
        block_input_code_detection:
          type: boolean
          description: Block input code detection
        block_output_code_detection:
          type: boolean
          description: Block output code detection
        skip_guardrail_detection:
          type: boolean
          description: Skip guardrail detection
        block_guardrail_detection:
          type: boolean
          description: Block guardrail detection
        skip_input_url_detection:
          type: boolean
          description: Skip input URL detection
        skip_output_url_detection:
          type: boolean
          description: Skip output URL detection
        skip_input_dos_detection:
          type: boolean
          description: Skip input denial of service detection
        block_input_dos_detection:
          type: boolean
          description: Block input denial of service detection
        input_dos_detection_threshold:
          type: number
          description: The threshold for input denial of service detection
          default: 4096
          example: 4096
    HiddenLayerAnalysisFrameworks:
      type: object
      description: The framework labels identified during analysis
      properties:
        mitre:
          type: array
          items:
            type: object
            description: The MITRE Atlas framework labels identified during analysis
            properties:
              name:
                type: string
                description: The name of the MITRE Atlas framework label
              label:
                type: string
                description: The label of the MITRE Atlas framework label
          example:
            - name: LLM Prompt Injection
              label: AML.T0051
        owasp:
          type: array
          items:
            type: object
            description: The OWASP framework labels identified during analysis
            properties:
              name:
                type: string
                description: The name of the OWASP framework label
              label:
                type: string
                description: The label of the OWASP framework label
          example:
            - name: Prompt Injection
              label: LLM01
    HiddenLayerProxyResponse:
      type: object
      properties:
        verdict:
          type: boolean
          description: The overall verdict of the analysis
        categories:
          $ref: '#/components/schemas/HiddenLayerAnalysisCategories'
        results:
          $ref: '#/components/schemas/HiddenLayerAnalysisResults'
        policy:
          $ref: '#/components/schemas/HiddenLayerAnalysisPolicy'
        frameworks:
          $ref: '#/components/schemas/HiddenLayerAnalysisFrameworks'
        elapsed_ms:
          type: number
          description: The time in milliseconds it took to process the request
        upstream_elapsed_ms:
          type: number
          description: >-
            The time in milliseconds the upstream LLM took to process the
            request
    HiddenLayerProxyOpenAI:
      type: object
      properties:
        response:
          $ref: '#/components/schemas/OpenAIChatCompletionsResponse'
        provider:
          type: string
          description: The provider of the upstream service
          example: openai
        model:
          type: string
          description: The name of the model
          example: gpt-3.5-turbo
    HiddenLayerProxyHuggingFaceTGI:
      type: object
      properties:
        response:
          $ref: '#/components/schemas/OpenAIChatCompletionsResponse'
        provider:
          type: string
          description: The provider of the upstream service
          example: huggingface-tgi
        model:
          type: string
          description: The name of the model
          example: tgi-model
    HiddenLayerProxyOpenAIResponse:
      allOf:
        - $ref: '#/components/schemas/HiddenLayerProxyOpenAI'
        - $ref: '#/components/schemas/HiddenLayerProxyResponse'
    HiddenLayerProxyHuggingFaceTGIResponse:
      allOf:
        - $ref: '#/components/schemas/HiddenLayerProxyHuggingFaceTGI'
        - $ref: '#/components/schemas/HiddenLayerProxyResponse'
    HiddenLayerProxyAzureTextCompletions:
      type: object
      properties:
        response:
          $ref: '#/components/schemas/AzureTextCompletionsResponse'
        provider:
          type: string
          description: The provider of the upstream service
          example: azure
        model:
          type: string
          description: The name of the model
          example: azure-endpoint/llama-2-deployment
    HiddenLayerProxyAzureChatCompletions:
      type: object
      properties:
        response:
          $ref: '#/components/schemas/AzureChatCompletionsResponse'
        provider:
          type: string
          description: The provider of the upstream service
          example: azure
        model:
          type: string
          description: The name of the model
          example: azure-endpoint/mistral-deployment
    HiddenLayerProxyAzureTextCompletionsResponse:
      allOf:
        - $ref: '#/components/schemas/HiddenLayerProxyAzureTextCompletions'
        - $ref: '#/components/schemas/HiddenLayerProxyResponse'
    HiddenLayerProxyAzureChatCompletionsResponse:
      allOf:
        - $ref: '#/components/schemas/HiddenLayerProxyAzureChatCompletions'
        - $ref: '#/components/schemas/HiddenLayerProxyResponse'
