Prisma AIRS
Prisma AIRS API Python SDK
Table of Contents
Prisma AIRS API Python SDK
Install the aisecurity package for Prisma AIRS API Python
SDK.
Where Can I Use This? | What Do I Need? |
---|
Prisma AIRS API Python SDK simplifies the integration of
advanced AI security scanning capabilities into Python applications. It provides a
streamlined way to detect and mitigate potential threats in AI applications and AI
agents, supporting synchronous and asynchronous scanning options.
It handles authentication, error management, and data parsing, allowing
developers to focus on core functionality.
Prisma AIRS API Python SDK offers easy
PyPI installation, open-source availability, and simplified API
integration across platforms. It provides synchronous and asynchronous scanning with
concurrent capabilities, comprehensive error handling, and clear type
definitions.
It enables real-time content scanning, threat detection, and detailed
reporting while incorporating flexible retry strategies. This makes it ideal for a
wide range of AI applications, including chatbots and content moderation systems,
ensuring robust security in AI-driven interactions.
Requirements for Python SDK Usage
- API key token: This token is generated when you onboard Onboard Prisma AIRS AI Runtime: API Intercept in Strata Cloud Manager.API security profile name or API security profile ID.Optional Use the default US endpoint or specify the EU endpoint if your operations are primarily in Europe.
Prerequisites
- Python 3.9 through 3.13
Installation
- Create and activate a virtual environment:python3 -m venv --prompt aisec-api-sdk-${USER} .venv && source .venv/bin/activateInstall the recent stable v1 compatible release version of `aisecurity` packagepython3 -m pip install pan-aisecurity
Configuration: Python SDK Usage
- API Key: Update the API key environment variable:
- Using an environment
variable:export PANW_AI_SEC_API_KEY=YOUR_API_KEY_GOES_HERE
- Load the API key through init by passing api_key as a parameter:
aisecurity.init(api_key="YOUR_API_KEY_GOES_HERE")API endpoint: You can set a custom API endpoint using the api_endpoint parameter:
If there is no custom API endpoint set, the Python SDK uses a default API endpoint: "https://service.api.aisecurity.paloaltonetworks.com".aisecurity.init(api_endpoint="https://api.example.com")Profile name or profile ID: Set either the profile name or profile ID is sufficient; both are not mandatoryai_profile = AiProfile(profile_id="DEMO_AI_PROFILE_ID") # or ai_profile = AiProfile(profile_name="DEMO_AI_PROFILE_NAME")Optinal `num_retries` value: the default value is 5.Next, follow the Python SDK API reference docs to trigger API scans using the Python code snippets. - Load the API key through init by passing api_key as a parameter:
- Using an environment
variable: