Skip to main content

A wrapper around the OpenAI Python library that wraps the Responses API with CrowdStrike AIDR

Project description

CrowdStrike AIDR + OpenAI Python API library

A wrapper around the OpenAI Python library that wraps the Responses API with CrowdStrike AIDR. Supports Python v3.12 and greater.

Installation

pip install -U crowdstrike-aidr-openai

Usage

import os
from crowdstrike_aidr_openai import CrowdStrikeOpenAI

client = CrowdStrikeOpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),
    # CrowdStrike AIDR options
    crowdstrike_aidr_api_key=os.environ.get("CS_AIDR_API_TOKEN"),
    crowdstrike_aidr_base_url_template=os.environ.get("CS_AIDR_BASE_URL_TEMPLATE"),
)

response = client.responses.create(
    model="gpt-4o",
    instructions="You are a coding assistant that talks like a pirate.",
    input="How do I check if a Python object is an instance of a class?",
)

print(response.output_text)

Microsoft Azure OpenAI

To use this library with Azure OpenAI, use the CrowdStrikeAzureOpenAI class instead of the CrowdStrikeOpenAI class.

from crowdstrike_aidr_openai import CrowdStrikeAzureOpenAI

client = CrowdStrikeAzureOpenAI(
    # https://learn.microsoft.com/azure/ai-services/openai/reference#rest-api-versioning
    api_version="2023-07-01-preview",
    # https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
    azure_endpoint="https://example-endpoint.openai.azure.com",
    # CrowdStrike AIDR options
    crowdstrike_aidr_api_key=os.environ.get("CS_AIDR_API_TOKEN"),
    crowdstrike_aidr_base_url_template=os.environ.get("CS_AIDR_BASE_URL_TEMPLATE"),
)

completion = client.chat.completions.create(
    model="deployment-name",  # e.g. gpt-35-instant
    messages=[
        {
            "role": "user",
            "content": "How do I output all files in a directory using Python?",
        },
    ],
)
print(completion.to_json())

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_openai-0.2.0.tar.gz (12.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_openai-0.2.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file crowdstrike_aidr_openai-0.2.0.tar.gz.

File metadata

  • Download URL: crowdstrike_aidr_openai-0.2.0.tar.gz
  • Upload date:
  • Size: 12.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_openai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 01170607e6a08f2a07c9c88ca712ccff6ebe8a34be89d2e6157a24854cff6856
MD5 d56bb3c4d3d95b0ab1b22bce15b93104
BLAKE2b-256 b5cbdc1dfe954636990c72eedb17b4028eccdcdc6ed3e355ab48805c9c899029

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_aidr_openai-0.2.0.tar.gz:

Publisher: publish.yml on CrowdStrike/aidr-openai-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_openai-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for crowdstrike_aidr_openai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19bbeaf7f265e9837b8aa29d81928e7219e60282a5d49e46802b7effe741a1ee
MD5 f7ceaea2d97ddbc57af7b03b42539435
BLAKE2b-256 4f2e78d229a6956573ff3828202576ab34f9cbe5737ee0e81038453cd6b443ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_aidr_openai-0.2.0-py3-none-any.whl:

Publisher: publish.yml on CrowdStrike/aidr-openai-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