This release is a pre-release and may not be stable for production use.
Check Point - AI Security Python SDK
Draft – This is a pre-release version of the SDK published for early testing. APIs and behavior may change before the official release.
This is the AI Security SDK for Python ecosystem.
The SDK is based on the public AI Security OpenAPI specifications.
With the SDK, you do not have to manage log in, send keep alive requests, or worry about session expiration.
The AI Security SDK supports simultaneous instances with different tenants.
SDK installation
To start using this SDK, add the SDK package to your project
Via PIP (PyPi registry)
pip install chkp-ai-security-sdk
Getting started
First, import the AISecurity object from the package.
from chkp_ai_security_sdk import AISecurity
Then, create a new instance of AISecurity, which provides CloudInfra API credentials and a gateway to connect to.
Obtaining API credentials
- Go to the Infinity Portal API Keys page.
- Click New > New Account API Key.
- In the Service dropdown select Workforce AI Security and create the key.
- Copy the Client ID, Secret Key, and Authentication URL (gateway).
For more information, see Infinity Portal Administration Guide.
Available gateways
| Region | Gateway URL |
|---|---|
| Europe | https://cloudinfra-gw.portal.checkpoint.com |
| United States | https://cloudinfra-gw-us.portal.checkpoint.com |
Once the Client ID, Secret Key, and Authentication URL are obtained, AI Security SDK can be used.
All API operations can be explored with the AISecurity instance, notice to the documentation on each API operation, what and where are the arguments it requires.
All APIs can be also explored in SwaggerHub
A complete example:
from chkp_ai_security_sdk import AISecurity, InfinityPortalAuth
# Create a new instance of AISecurity (we do support multiple instances in parallel)
ai = AISecurity()
# Connect to AI Security service using CloudInfra API credentials
ai.connect(infinity_portal_auth=InfinityPortalAuth(
client_id="place here your CI client-id", # The "Client ID"
access_key="place here your CI access-key", # The "Secret Key"
gateway="https://cloudinfra-gw-us.portal.checkpoint.com" # The "Authentication URL" (without /auth/external)
))
# Query the API operations
rulebase = ai.chats_policy_api.get_chats_rulebase_external_v1_chats_rulebase_get()
print(rulebase)
# Once finish, disconnect to stop all background session management.
ai.disconnect()
Async support
The SDK also provides an async variant for use in async Python applications:
import asyncio
from chkp_ai_security_sdk import AsyncAISecurity, InfinityPortalAuth
async def main():
ai = AsyncAISecurity()
await ai.connect(infinity_portal_auth=InfinityPortalAuth(
client_id="your-client-id",
access_key="your-secret-key",
gateway="https://cloudinfra-gw-us.portal.checkpoint.com",
))
# API calls are awaitable and run without blocking the event loop
rulebase = await ai.chats_policy_api.get_chats_rulebase_external_v1_chats_rulebase_get()
print(rulebase)
await ai.disconnect()
asyncio.run(main())
Troubleshooting and logging
The full version and build info of the SDK is available by AISecurity.info() see example:
from chkp_ai_security_sdk import AISecurity, WorkforceAISDKInfo
sdk_info: WorkforceAISDKInfo = AISecurity.info()
print(sdk_info) # sdk_build:"9728283", sdk_version:"1.0.0", spec:"checkpoint-ai-security", spec_version:"1.0.0", released_on:"2024-01-01T00:00:00"
AI Security SDK uses the official python logger package for logging.
There are 3 loggers, for general info, errors and to inspect network.
As default they will be disabled, in order to enable logging, set to the AI_SECURITY_SDK_LOGGER environment variable the following string before loading the SDK:
AI_SECURITY_SDK_LOGGER="*"
And for a specific/s logger set the logger name followed by a comma as following:
AI_SECURITY_SDK_LOGGER="info,error,network"
or activate logger programmatically using SDK methods:
from chkp_ai_security_sdk import activate_all_loggers, activate_info_logger, activate_error_logger, activate_network_logger
...
activate_all_loggers() # Will activate all loggers
activate_info_logger() # Will activate the info logger only
activate_error_logger() # Will activate the error logger only
activate_network_logger() # Will activate the network logger only
All Check Point AI Security API tools
| Tool | Package |
|---|---|
| Python SDK | chkp-ai-security-sdk |
| JS/TS SDK | @chkp/ai-security-sdk |
| OpenAPI Spec | SwaggerHub |
Report Bug
In case of an issue or a bug found in the SDK, please open an issue.
Contributors
- Haim Kastner - haimk@checkpoint.com
Metadata
Release files for haimkastner-ai-security-sdk 1.0.0rc6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| haimkastner_ai_security_sdk-1.0.0rc6.tar.gz | 88.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| haimkastner_ai_security_sdk-1.0.0rc6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 399.2 kB
Release files / haimkastner_ai_security_sdk-1.0.0rc6.tar.gz
| Download URL | haimkastner_ai_security_sdk-1.0.0rc6.tar.gz |
|---|---|
| Size | 88.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d2abd9c156f36310f4a5f19d922321fdc9294ab0b4bb378165f1667e734b50f
|
|
BLAKE2b-256 checksum How to use checksums |
ef29b8a730969597eddf4d7a3d1528333c1585507b1c92f4c1324af8162c85f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / haimkastner_ai_security_sdk-1.0.0rc6-py3-none-any.whl
| Download URL | haimkastner_ai_security_sdk-1.0.0rc6-py3-none-any.whl |
|---|---|
| Size | 311.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd82ee7768e12625f7177e5edd7fe14af9dd120e78cfac22a2434fb6cfdee335
|
|
BLAKE2b-256 checksum How to use checksums |
5a2e1a8835d6f24ac03d3d56d5911a39c3a1ac952c216b2e9a0a8aa1ee496e75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|