ArthurAI Default Validation API

Endpoints to validate prompt and response on default rules

OpenAPI Specification

arthurai-default-validation-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Arthur GenAI Engine Agent Discovery Default Validation API
  version: 2.1.688
  description: Endpoints to validate prompt and response on default rules
tags:
- name: Default Validation
  description: Endpoints to validate prompt and response on default rules
paths:
  /api/v2/validate_prompt:
    post:
      tags:
      - Default Validation
      summary: Default Validate Prompt
      description: '[Deprecated] Validate a non-task related prompt based on the configured default rules.'
      operationId: default_validate_prompt_api_v2_validate_prompt_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PromptValidationRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationResult'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      deprecated: true
      security:
      - API Key: []
  /api/v2/validate_response/{inference_id}:
    post:
      tags:
      - Default Validation
      summary: Default Validate Response
      description: '[Deprecated] Validate a non-task related generated response based on the configured default rules. Inference ID corresponds to the previously validated associated prompt’s inference ID. Must provide context if a Hallucination Rule is an enabled default rule.'
      operationId: default_validate_response_api_v2_validate_response__inference_id__post
      deprecated: true
      security:
      - API Key: []
      parameters:
      - name: inference_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
          title: Inference Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseValidationRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationResult'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    HallucinationClaimResponse:
      properties:
        claim:
          type: string
          title: Claim
        valid:
          type: boolean
          title: Valid
        reason:
          type: string
          title: Reason
        order_number:
          anyOf:
          - type: integer
          - type: 'null'
          title: Order Number
          description: This field is a helper for ordering the claims
          default: -1
      type: object
      required:
      - claim
      - valid
      - reason
      title: HallucinationClaimResponse
    KeywordDetailsResponse:
      properties:
        score:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Score
        message:
          anyOf:
          - type: string
          - type: 'null'
          title: Message
        keyword_matches:
          items:
            $ref: '#/components/schemas/KeywordSpanResponse'
          type: array
          title: Keyword Matches
          description: Each keyword in this list corresponds to a keyword that was both configured in the rule that was run and found in the input text.
          default: []
      additionalProperties: false
      type: object
      title: KeywordDetailsResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RuleType:
      type: string
      enum:
      - KeywordRule
      - ModelHallucinationRuleV2
      - ModelSensitiveDataRule
      - PIIDataRule
      - PromptInjectionRule
      - RegexRule
      - ToxicityRule
      title: RuleType
    RuleScope:
      type: string
      enum:
      - default
      - task
      title: RuleScope
    HallucinationDetailsResponse:
      properties:
        score:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Score
        message:
          anyOf:
          - type: string
          - type: 'null'
          title: Message
        claims:
          items:
            $ref: '#/components/schemas/HallucinationClaimResponse'
          type: array
          title: Claims
      type: object
      required:
      - claims
      title: HallucinationDetailsResponse
    RuleResultEnum:
      type: string
      enum:
      - Pass
      - Fail
      - Skipped
      - Unavailable
      - Partially Unavailable
      - Model Not Available
      title: RuleResultEnum
    BaseDetailsResponse:
      properties:
        score:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Score
        message:
          anyOf:
          - type: string
          - type: 'null'
          title: Message
      type: object
      title: BaseDetailsResponse
    PromptValidationRequest:
      properties:
        prompt:
          type: string
          title: Prompt
          description: Prompt to be validated by GenAI Engine
        conversation_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Conversation Id
          description: The unique conversation ID this prompt belongs to. All prompts and responses from this         conversation can later be reconstructed with this ID.
        user_id:
          anyOf:
          - type: string
          - type: 'null'
          title: User Id
          description: The user ID this prompt belongs to
      type: object
      required:
      - prompt
      title: PromptValidationRequest
    ResponseValidationRequest:
      properties:
        response:
          type: string
          title: Response
          description: LLM Response to be validated by GenAI Engine
        context:
          anyOf:
          - type: string
          - type: 'null'
          title: Context
          description: Optional data provided as context for the validation.
        model_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Model Name
          description: The model name and version being used for this response (e.g., 'gpt-4', 'gpt-3.5-turbo', 'claude-3-opus', 'gemini-pro').
      type: object
      required:
      - response
      title: ResponseValidationRequest
    PIIEntityTypes:
      type: string
      enum:
      - CREDIT_CARD
      - CRYPTO
      - DATE_TIME
      - EMAIL_ADDRESS
      - IBAN_CODE
      - IP_ADDRESS
      - NRP
      - LOCATION
      - PERSON
      - PHONE_NUMBER
      - MEDICAL_LICENSE
      - URL
      - US_BANK_NUMBER
      - US_DRIVER_LICENSE
      - US_ITIN
      - US_PASSPORT
      - US_SSN
      title: PIIEntityTypes
    ToxicityViolationType:
      type: string
      enum:
      - benign
      - harmful_request
      - toxic_content
      - profanity
      - unknown
      title: ToxicityViolationType
    RegexDetailsResponse:
      properties:
        score:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Score
        message:
          anyOf:
          - type: string
          - type: 'null'
          title: Message
        regex_matches:
          items:
            $ref: '#/components/schemas/RegexSpanResponse'
          type: array
          title: Regex Matches
          description: Each string in this list corresponds to a matching span from the input text that matches the configured regex rule.
          default: []
      additionalProperties: false
      type: object
      title: RegexDetailsResponse
    KeywordSpanResponse:
      properties:
        keyword:
          type: string
          title: Keyword
          description: The keyword from the rule that matched within the input string.
      type: object
      required:
      - keyword
      title: KeywordSpanResponse
    ExternalRuleResult:
      properties:
        id:
          type: string
          title: Id
          description: ' ID of the rule'
        name:
          type: string
          title: Name
          description: Name of the rule
        rule_type:
          $ref: '#/components/schemas/RuleType'
          description: Type of the rule
        scope:
          $ref: '#/components/schemas/RuleScope'
          description: Scope of the rule. The rule can be set at default level or task level.
        result:
          $ref: '#/components/schemas/RuleResultEnum'
          description: Result if the rule
        latency_ms:
          type: integer
          title: Latency Ms
          description: Duration in millisesconds of rule execution
        details:
          anyOf:
          - $ref: '#/components/schemas/KeywordDetailsResponse'
          - $ref: '#/components/schemas/RegexDetailsResponse'
          - $ref: '#/components/schemas/HallucinationDetailsResponse'
          - $ref: '#/components/schemas/PIIDetailsResponse'
          - $ref: '#/components/schemas/ToxicityDetailsResponse'
          - $ref: '#/components/schemas/BaseDetailsResponse'
          - type: 'null'
          title: Details
          description: Details of the rule output
      type: object
      required:
      - id
      - name
      - rule_type
      - scope
      - result
      - latency_ms
      title: ExternalRuleResult
      example:
        id: 90f18c69-d793-4913-9bde-a0c7f3643de0
        name: PII Rule
        result: Pass
    RegexSpanResponse:
      properties:
        matching_text:
          type: string
          title: Matching Text
          description: The subtext within the input string that matched the regex rule.
        pattern:
          anyOf:
          - type: string
          - type: 'null'
          title: Pattern
          description: Pattern that yielded the match.
      type: object
      required:
      - matching_text
      title: RegexSpanResponse
    PIIDetailsResponse:
      properties:
        score:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Score
        message:
          anyOf:
          - type: string
          - type: 'null'
          title: Message
        pii_entities:
          items:
            $ref: '#/components/schemas/PIIEntitySpanResponse'
          type: array
          title: Pii Entities
      type: object
      required:
      - pii_entities
      title: PIIDetailsResponse
    ValidationResult:
      properties:
        inference_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Inference Id
          description: ID of the inference
        rule_results:
          anyOf:
          - items:
              $ref: '#/components/schemas/ExternalRuleResult'
            type: array
          - type: 'null'
          title: Rule Results
          description: List of rule results
        user_id:
          anyOf:
          - type: string
          - type: 'null'
          title: User Id
          description: The user ID this prompt belongs to
        model_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Model Name
          description: The model name and version used for this validation (e.g., 'gpt-4', 'gpt-3.5-turbo', 'claude-3-opus', 'gemini-pro').
      type: object
      title: ValidationResult
      example:
        inference_id: 4dd1fae1-34b9-4aec-8abe-fe7bf12af31d
        rule_results:
        - id: 90f18c69-d793-4913-9bde-a0c7f3643de0
          name: PII Check
          result: Pass
        - id: 946c4a44-b367-4229-84d4-1a8e461cb132
          name: Sensitive Data Check
          result: Pass
    ToxicityDetailsResponse:
      properties:
        score:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Score
        message:
          anyOf:
          - type: string
          - type: 'null'
          title: Message
        toxicity_score:
          anyOf:
          - type: number
          - type: 'null'
          title: Toxicity Score
        toxicity_violation_type:
          $ref: '#/components/schemas/ToxicityViolationType'
      additionalProperties: false
      type: object
      required:
      - toxicity_violation_type
      title: ToxicityDetailsResponse
    PIIEntitySpanResponse:
      properties:
        entity:
          $ref: '#/components/schemas/PIIEntityTypes'
        span:
          type: string
          title: Span
          description: The subtext within the input string that was identified as PII.
        confidence:
          anyOf:
          - type: number
          - type: 'null'
          title: Confidence
          description: Float value representing the confidence score of a given PII identification.
      type: object
      required:
      - entity
      - span
      title: PIIEntitySpanResponse
  securitySchemes:
    API Key:
      type: http
      description: Bearer token authentication with an API key
      scheme: bearer