Skip to content

Sending a scan request to a specific project

INFERENCE DEFEND

This article is meant for Inference Defend users.

ROLES AND PERMISSIONS

To complete the task described in this section, make sure you have the required permissions.

When sending a scan request, you may want to send it to a specific project depending on the scanner configuration you require. To send a scan request to a specific project, you just need to provide the project ID in your request.

The scan request is scanned by all enabled scanners in the project.

In this scenario, we are going to send a scan request to a specific project using the project ID.

To send a scan request to a specific project:

  1. Add your token and project ID values to the following sample:

    python
    from calypsoai import CalypsoAI
    from calypsoai.datatypes import ProjectType
    
    # Define the URL and token for CalypsoAI
    CALYPSOAI_URL = "https://www.us1.calypsoai.app"
    CALYPSOAI_TOKEN = "ADD-YOUR-TOKEN-HERE"
    
    # Initialize the CalypsoAI client
    cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
    
    # Send the scan to a specific project using the project ID
    scan = cai.scans.scan(
        "What is your name?",
        project='ADD-YOUR-PROJECT-ID-HERE'
    )
    
    # Print the response
    print(scan.model_dump_json(indent=2))
  2. Run the script.

  3. Analyze the response.

    json
    {
        "outcome": "cleared",
        "scannerResults": [
          {
            "completedDate": "2025-03-20T13:04:50.986228Z",
            "customConfig": false,
            "data": {
              "type": "custom"
            },
            "outcome": "passed",
            "scanDirection": "request",
            "scannerId": "0195b395-4c48-7061-833c-e78e946969ba",
            "startedDate": "2025-03-20T13:04:49.548520Z"
          }
        ]
    }

FRIENDLY ID

If you created a project that includes a friendly ID, you can send a scan request to the project using the friendly ID instead of the project ID.

To send a scan request to a specific project using the friendly ID:

  1. Add your token and friendly ID values to the following sample.

    python
    from calypsoai import CalypsoAI
    from calypsoai.datatypes import ProjectType
    
    # Define the URL and token for CalypsoAI
    CALYPSOAI_URL = "https://www.us1.calypsoai.app"
    CALYPSOAI_TOKEN = "ADD-YOUR-TOKEN-HERE"
    
    # Initialize the CalypsoAI client
    cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
    
    # Send the scan to a specific project using the friendly ID
    scan = cai.scans.scan(
        "What is your name?",
        project='ADD-YOUR-FRIENDLY-ID-HERE'
    )
    
    # Print the response
    print(scan.model_dump_json(indent=2))
  2. Run the script.

  3. Analyze the response.
    The same response is returned when using the project ID or friendly ID.

Updated at: