Skip to main content

Pangea + OpenAI Python API library

A wrapper around the OpenAI Python library that wraps the Responses API with Pangea AI Guard. Supports Python v3.10 and greater.

Installation

pip install -U pangea-openai

Usage

import os
from pangea_openai import PangeaOpenAI

client = PangeaOpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),
    # Pangea options
    pangea_api_key=os.environ.get("PANGEA_API_KEY"),
    pangea_input_recipe="pangea_prompt_guard",
    pangea_output_recipe="pangea_llm_response_guard",
)

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 PangeaAzureOpenAI class instead of the PangeaOpenAI class.

from pangea_openai import PangeaAzureOpenAI

client = PangeaAzureOpenAI(
    # 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",
    # Pangea options
    pangea_api_key=os.environ.get("PANGEA_API_KEY"),
    pangea_input_recipe="pangea_prompt_guard",
    pangea_output_recipe="pangea_llm_response_guard",
)

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())

Metadata

Release files for pangea-openai 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pangea-openai 0.3.0
File Size Uploaded Provenance
pangea_openai-0.3.0.tar.gz 12.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pangea-openai 0.3.0
File Interpreter ABI Platform
pangea_openai-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.0 kB

Release files / pangea_openai-0.3.0.tar.gz

Download URL pangea_openai-0.3.0.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3cc2afc059923484e23f2a5676c8e69955fc93331b9df4d908f761981f199253
BLAKE2b-256 checksum
How to use checksums
1b718920ac0fa0ba7f0213afd01692ab9b4ded8d166c65a615aca998bae93eb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / pangea_openai-0.3.0-py3-none-any.whl

Download URL pangea_openai-0.3.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a90e153a0b67caf26ca0365a17e652b2330df1cd9a9d6f120289b5c91b57db2
BLAKE2b-256 checksum
How to use checksums
866cbfeee6c648f984803679aa3bdd6adf156fa1a4810daca0029c5fe543f25c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for pangea-openai 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page