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

Uploaded Python 3

File details

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

File metadata

  • Download URL: crowdstrike_aidr_openai-0.1.1.tar.gz
  • Upload date:
  • Size: 12.4 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.1.1.tar.gz
Algorithm Hash digest
SHA256 5f296d293046aa523a2d07591fb616abf3ea108f167c892587c5ab38157e835b
MD5 e0f1118c4199e61b78c3a33be4d29319
BLAKE2b-256 97c5f4dd59397de504dcfb9130d765560547a8c29be2a7c87631d3e14e1ed964

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_aidr_openai-0.1.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crowdstrike_aidr_openai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4a8b4c2fd495d171dfa3da417a0a692d5d53b4ebd54c083dcffdb67cd65b9eb
MD5 d275a86a1a53aafe59097851e9257006
BLAKE2b-256 d3b3000a25112a6a1deb4ad84f0cbcd20414882bdafddb35408b03deb3b3a6ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_aidr_openai-0.1.1-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