Python SDK for Semantis AI - Semantic LLM Cache
Project description
Semantis Python SDK
Drop-in replacement for the OpenAI Python client with automatic semantic caching.
Installation
pip install semantis
For automatic OpenAI fallback when Semantis is unreachable:
pip install semantis[openai]
Quick Start
from semantis import SemantisCache
cache = SemantisCache(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 Semantis:
import openai
client = openai.OpenAI(
base_url="https://api.semantis.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 = SemantisCache(
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 Semantis 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
semantis-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 semantis-0.1.0.tar.gz.
File metadata
- Download URL: semantis-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 |
cba5a2449a394c3bf575f31ec7deec91f9d40e49df85fd8107ad74fb1a655282
|
|
| MD5 |
11a4446d5810cd9b025df6b74e1d5f80
|
|
| BLAKE2b-256 |
6a8e0b34d26676427ae4e9acb70b4e1421ee873da03ebc5d0a2de173888a4a22
|
File details
Details for the file semantis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: semantis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 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 |
94f7f2bef538d60f5b6fe5b662f4276f7155349b2f01effbdb6c50b21bc9831b
|
|
| MD5 |
56ff78958b39896db8be00290e6d5c77
|
|
| BLAKE2b-256 |
87520cc95ba01739461830fc80df40f1fec24e4c3e5f6e4f1a63e41fe15b6fd4
|