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.1.0.tar.gz (5.4 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.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for semanticguard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aae16a28e5911d9bbe360e9af88a9a94d99af9aaa33ea0e674b56f9273a01740
MD5 944f5e64c8c56d64058a3bef319232c0
BLAKE2b-256 07f6bbef5635e7e79de25afc11c4e4a46285f16f23c2a8e48dda2eb69f6da0d7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: semanticguard-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a4cf47f9bdd027aeb11b293503be76832866e45878a598dfda303abdd3ecc5a
MD5 6d63a3c3c069564d24f576dc95108ead
BLAKE2b-256 59105f00d52f5ae75cb9862ba2c4724c9b27467267c9764f6b7770768be967dc

See more details on using hashes here.

Provenance

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