Python SDK
Python SDK
The Python SDK is a lightweight wrapper around the dish-embed REST API. It handles authentication, auto-chunking, and error handling.
Installation
The SDK has a single dependency:
pip install requests
The client is a single file. Either copy it into your project or install the dish-embed package:
pip install dish-embed
Setup
from dish_embed.client import DishEmbedClient
client = DishEmbedClient("https://embed.statode.com", api_key="YOUR_KEY")
Quick example
# Health check
print(client.health())
# Embed items
result = client.embed(["Butter Chicken", "Murgh Makhani", "Dal Tadka"], dimension=384)
print(f"Got {len(result['embeddings'])} embeddings of dimension {len(result['embeddings'][0])}")
# Search
results = client.search("spicy chicken", corpus=["Chicken Vindaloo", "Butter Chicken", "Paneer Tikka"])
for r in results["results"]:
print(f" {r['item']}: {r['score']:.3f}")
# Dedup
dedup = client.dedup(["Chicken Biryani", "Chiken Biryani", "Mutton Biryani"])
print(f"Found {len(dedup['clusters'])} duplicate clusters")
Error handling
All methods raise DishEmbedError on failure:
from dish_embed.client import DishEmbedClient, DishEmbedError
try:
result = client.search("pizza", corpus=[])
except DishEmbedError as e:
print(f"API error {e.status_code}: {e.detail}")
Next steps
See the DishEmbedClient Reference for all available methods and parameters.