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.2.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.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: semanticguard-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 058757b884c27ae4a54eda626609c7a7524f5a168e10de1000bd6b8778f6eeca
MD5 64f3c144a8d43e222cbccc9f95212db2
BLAKE2b-256 517a9056130d0da384bc33bbc2b650247ee9d4a01fab9db72fac06d4e2c30923

See more details on using hashes here.

Provenance

The following attestation bundles were made for semanticguard-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: semanticguard-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e3d14ab666f292ae67b78e39c252dfa9bf9528776a7b3d0d05a5a1456cb0371
MD5 b2785167b150096da26208a17e70e411
BLAKE2b-256 bb23143d1ad9890aa77a42fee68a7cf82771f65c360df9391a09e4f9148319bd

See more details on using hashes here.

Provenance

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