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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
058757b884c27ae4a54eda626609c7a7524f5a168e10de1000bd6b8778f6eeca
|
|
| MD5 |
64f3c144a8d43e222cbccc9f95212db2
|
|
| BLAKE2b-256 |
517a9056130d0da384bc33bbc2b650247ee9d4a01fab9db72fac06d4e2c30923
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semanticguard-0.2.0.tar.gz -
Subject digest:
058757b884c27ae4a54eda626609c7a7524f5a168e10de1000bd6b8778f6eeca - Sigstore transparency entry: 1556771579
- Sigstore integration time:
-
Permalink:
KB-AI-LLC/sg-ai@4acc4638df7fa1ad7accdcfbbca5725ce093a75c -
Branch / Tag:
refs/tags/python-sdk-v0.2.0 - Owner: https://github.com/KB-AI-LLC
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@4acc4638df7fa1ad7accdcfbbca5725ce093a75c -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e3d14ab666f292ae67b78e39c252dfa9bf9528776a7b3d0d05a5a1456cb0371
|
|
| MD5 |
b2785167b150096da26208a17e70e411
|
|
| BLAKE2b-256 |
bb23143d1ad9890aa77a42fee68a7cf82771f65c360df9391a09e4f9148319bd
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semanticguard-0.2.0-py3-none-any.whl -
Subject digest:
5e3d14ab666f292ae67b78e39c252dfa9bf9528776a7b3d0d05a5a1456cb0371 - Sigstore transparency entry: 1556771801
- Sigstore integration time:
-
Permalink:
KB-AI-LLC/sg-ai@4acc4638df7fa1ad7accdcfbbca5725ce093a75c -
Branch / Tag:
refs/tags/python-sdk-v0.2.0 - Owner: https://github.com/KB-AI-LLC
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@4acc4638df7fa1ad7accdcfbbca5725ce093a75c -
Trigger Event:
push
-
Statement type: