Python SDK for Semantys AI - Semantic LLM Cache
Project description
Semantys Python SDK
Drop-in replacement for the OpenAI Python client with automatic semantic caching.
Installation
pip install semantys
For automatic OpenAI fallback when Semantys is unreachable:
pip install semantys[openai]
Quick Start
from semantys import SemantysCache
cache = SemantysCache(api_key="sc-myorg-xxxxxxxx")
# OpenAI-compatible interface
response = cache.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "What is machine learning?"}],
)
print(response.choices[0].message.content)
print(f"Cache: {response.meta.hit} | Similarity: {response.meta.similarity}")
Zero-Code Integration (Proxy Mode)
Point your existing OpenAI client at Semantys:
import openai
client = openai.OpenAI(
base_url="https://api.semantys.ai/v1",
api_key="sc-myorg-xxxxxxxx",
)
# Existing code works unchanged - caching is transparent
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "What is ML?"}],
)
Self-Hosted
cache = SemantysCache(
api_key="sc-myorg-xxxxxxxx",
base_url="http://localhost:8000",
)
Features
- OpenAI-compatible: Drop-in replacement, same interface
- Automatic retry: Exponential backoff on 429/5xx errors
- Fallback: If Semantys is unreachable, falls back to direct OpenAI (with
[openai]extra) - Cache metadata: Every response includes
meta.hit,meta.similarity,meta.latency_ms - Context manager: Use with
withfor automatic cleanup
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
semantys-0.1.0.tar.gz
(5.7 kB
view details)
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 semantys-0.1.0.tar.gz.
File metadata
- Download URL: semantys-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7bb368d698a602890ae8041c8412e5e217fb0482ff44601663ed8b73d9bf071
|
|
| MD5 |
b221f27cdc0761e0adb1ca19402acf96
|
|
| BLAKE2b-256 |
e010be1b07c10514d00e079aae308857001fd581739f7f8b76a35901ea73faff
|
File details
Details for the file semantys-0.1.0-py3-none-any.whl.
File metadata
- Download URL: semantys-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f99e41ae499d78b99a5f7dbb67384c039ebf6352882fda7bbcd4e2c1f72c0fe5
|
|
| MD5 |
9acab35eb13e39719570423ade95083b
|
|
| BLAKE2b-256 |
aa52f46d82619e6ab121a7e0a85c0ebd0d5b208c9137f4095770079156b061a6
|