Skip to main content

Python SDK for CrowdStrike AIDR.

Project description

CrowdStrike AIDR Python SDK

Python SDK for CrowdStrike AIDR.

Installation

pip install crowdstrike-aidr

Requirements

Python v3.12 or greater.

Usage

from crowdstrike_aidr import AIGuard

client = AIGuard(
  base_url_template="https://api.crowdstrike.com/aidr/{SERVICE_NAME}",
  token="my API token"
)

response = client.guard_chat_completions(
    guard_input={
        "messages": [
            {"role": "user", "content": "Hello, world!"}
        ]
    }
)

Timeouts

The SDK uses httpx.Timeout for timeout configuration. By default, requests have a timeout of 60 seconds with a 5 second connection timeout.

You can configure timeouts in two ways:

Client-level timeout

Set a default timeout for all requests made by the client:

import httpx
from crowdstrike_aidr import AIGuard

# Using a float (total timeout in seconds).
client = AIGuard(
    base_url_template="https://api.crowdstrike.com/aidr/{SERVICE_NAME}",
    token="my API token",
    timeout=30.0,
)

# Using httpx.Timeout for more granular control.
client = AIGuard(
    base_url_template="https://api.crowdstrike.com/aidr/{SERVICE_NAME}",
    token="my API token",
    timeout=httpx.Timeout(timeout=60.0, connect=10.0),
)

Request-level timeout

Override the timeout for a specific request:

# Using a float (total timeout in seconds).
response = client.guard_chat_completions(
    guard_input={"messages": [...]},
    timeout=120.0
)

# Using httpx.Timeout for more granular control.
response = client.guard_chat_completions(
    guard_input={"messages": [...]},
    timeout=httpx.Timeout(timeout=120.0, connect=15.0)
)

Retries

The SDK automatically retries failed requests with exponential backoff. By default, the client will retry up to 2 times. Set max_retries during client creation to change this.

from crowdstrike_aidr import AIGuard

client = AIGuard(
    base_url_template="https://api.crowdstrike.com/aidr/{SERVICE_NAME}",
    max_retries=5  # Retry up to 5 times.
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crowdstrike_aidr-0.4.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crowdstrike_aidr-0.4.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file crowdstrike_aidr-0.4.1.tar.gz.

File metadata

  • Download URL: crowdstrike_aidr-0.4.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for crowdstrike_aidr-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d00e5144e359a17f9158011a8c42fec4c89126e301619d6d5e2bf3932d33773f
MD5 5dcdd90a1acc9fbafbea5c05c8d71c32
BLAKE2b-256 48e2f5c208861e7e0411fa0a11ca737a54269d95e520e65ac7ecebc22f13595d

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_aidr-0.4.1.tar.gz:

Publisher: publish.yml on CrowdStrike/aidr-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crowdstrike_aidr-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crowdstrike_aidr-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12003c87240dfcc68c8e8f7c54ca31d43dbc3c33a9d3e4ca7cc08616eb365c94
MD5 13f9e4c254280a95b858292922b49f51
BLAKE2b-256 d5b78ded1cc5d47a4e86b9d94ba4d75d2b7691df1be7807b789047d6ea322da6

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_aidr-0.4.1-py3-none-any.whl:

Publisher: publish.yml on CrowdStrike/aidr-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page