Skip to main content

Drop-in wrapper for the OpenAI Python SDK that routes requests through the SemanticGuard gateway for intelligent caching, cost tracking, and analytics.

Project description

semanticguard

Drop-in Python wrapper for the OpenAI Python SDK that routes requests through the SemanticGuard gateway for intelligent caching, cost tracking, and analytics.

Installation

pip install semanticguard

Quick start

from openai import OpenAI
from semanticguard import SemanticGuard

sg = SemanticGuard(api_key="sg-...", gateway_url="https://semanticguard.dev")
client = sg.wrap_openai(OpenAI(api_key="sk-..."))

# Use the client exactly as you normally would
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)

Azure OpenAI

from openai import AzureOpenAI
from semanticguard import SemanticGuard

sg = SemanticGuard(api_key="sg-...", gateway_url="https://semanticguard.dev")
azure = AzureOpenAI(api_key="...", api_version="2024-02-01",
                     azure_endpoint="https://my-resource.openai.azure.com")
client = sg.wrap_azure(azure, resource="my-resource", deployment="gpt-4o")

AWS Bedrock

from openai import OpenAI
from semanticguard import SemanticGuard

sg = SemanticGuard(api_key="sg-...", gateway_url="https://semanticguard.dev")
client = sg.wrap_bedrock(
    OpenAI(api_key="not-used"),
    aws_access_key="AKIA...",
    aws_secret_key="...",
    region="us-east-1",
)

Project tagging

Pass a project argument to any wrapper to tag requests:

client = sg.wrap_openai(OpenAI(api_key="sk-..."), project="my-project")

License

MIT

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

semanticguard-0.3.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

semanticguard-0.3.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file semanticguard-0.3.0.tar.gz.

File metadata

  • Download URL: semanticguard-0.3.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for semanticguard-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8f5d320a8cc2509f1958ee3ffb02369a58541df3a002cd4296f3093316b56394
MD5 2b133bad20f1c03ae58b682fbdbf2b47
BLAKE2b-256 4df67f702fd56d854255ec1ee4a9b2141f2664a9e095f4f505eec63973bf4d62

See more details on using hashes here.

Provenance

The following attestation bundles were made for semanticguard-0.3.0.tar.gz:

Publisher: publish-python-sdk.yml on KB-AI-LLC/sg-ai

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

File details

Details for the file semanticguard-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: semanticguard-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for semanticguard-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8334bac77cb6ee80568457a4fceaf05188a98c3d939dcdea4b018bc6bc80c8ea
MD5 5d0aef8c95ee87cceea39b8b34367065
BLAKE2b-256 cde89a3d33b6042b11714b69c5ea3bb74c3bd8842196f245e9772fb47eddc37b

See more details on using hashes here.

Provenance

The following attestation bundles were made for semanticguard-0.3.0-py3-none-any.whl:

Publisher: publish-python-sdk.yml on KB-AI-LLC/sg-ai

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