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.0.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.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crowdstrike_aidr_openai-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 077f371eab208213a9f27548ddc10e197c5a398b658684012355750def81e34e
MD5 5871633c8a27be8fe79df2a5d8d9e7f6
BLAKE2b-256 f77446244a9f302e7966930d4442042580f65b96a5d43c03236bdbf38f83614b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for crowdstrike_aidr_openai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73c2167ea5a01b6b8028ff643017df37dbc8f6a27c7d17d79a78752e81d68f1a
MD5 bdd735ef7cc67a1da6990977817d53fe
BLAKE2b-256 e5ba8cb65b0e9b1521d4563ac7acc98d7e0fc4f82ba83e5223d3ef538a52ad16

See more details on using hashes here.

Provenance

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