DishEmbedClient Reference
Constructor
from dish_embed.client import DishEmbedClient
client = DishEmbedClient(base_url, api_key)
| Parameter | Type | Description |
|---|---|---|
base_url | str | API base URL (e.g., "https://embed.statode.com") |
api_key | str | Your API key |
Methods
health()
Check API availability.
result = client.health()
# {"status": "ok", "model": "dish-embed-v8", ...}
Returns: dict with status and model info.
embed(items, dimension=128)
Generate embeddings for a list of items. Automatically chunks large lists into multiple requests (512 items per chunk).
result = client.embed(["Butter Chicken", "Dal Tadka"], dimension=384)
embeddings = result["embeddings"] # list of float lists
| Parameter | Type | Default | Description |
|---|---|---|---|
items | list[str] | required | Menu items to embed (up to 512 per chunk) |
dimension | int | 128 | Embedding dimension: 128, 256, or 384 |
Returns: dict with embeddings (list of float lists) and items_preprocessed.
Auto-chunking: Lists longer than 512 items are transparently split into multiple HTTP requests. Results are concatenated in order.
embed_batch(items, dimension=128)
Embed up to 5,000 items in a single HTTP request. No chunking. Use this for bulk operations where you want one network round-trip.
result = client.embed_batch(large_menu, dimension=128)
| Parameter | Type | Default | Description |
|---|---|---|---|
items | list[str] | required | Menu items (up to 5,000) |
dimension | int | 128 | Embedding dimension: 128, 256, or 384 |
Returns: Same as embed().
match(pairs, cosine_threshold=0.85)
Check if pairs of items are duplicates.
result = client.match(
pairs=[("Butter Chicken", "Murgh Makhani"), ("Pizza", "Pasta")],
cosine_threshold=0.85
)
for m in result["matches"]:
print(f"{m['item_a']} vs {m['item_b']}: {m['is_match']}")
| Parameter | Type | Default | Description |
|---|---|---|---|
pairs | list[tuple] | required | Pairs of items to compare |
cosine_threshold | float | 0.85 | Minimum similarity to consider a match |
Returns: dict with matches (list of match results including is_match, cosine_score, reranker_score, dietary_conflict).
dedup(items, cosine_threshold=0.85)
Find and cluster duplicate items in a menu.
result = client.dedup(menu_items, cosine_threshold=0.85)
for cluster in result["clusters"]:
print(f"Canonical: {cluster['canonical']}, Members: {cluster['members']}")
| Parameter | Type | Default | Description |
|---|---|---|---|
items | list[str] | required | Menu items (up to 2,000) |
cosine_threshold | float | 0.85 | Similarity threshold for clustering |
Returns: dict with clusters, duplicate_items (count of excess items), and unique_items.
classify(items)
Classify items by cuisine.
result = client.classify(["Sushi Roll", "Butter Chicken", "Tacos"])
for c in result["classifications"]:
print(f"{c['item']}: {c['cuisine']} ({c['confidence']:.2f})")
| Parameter | Type | Default | Description |
|---|---|---|---|
items | list[str] | required | Menu items (up to 512) |
Returns: dict with classifications (list with item, cuisine, confidence).
search(query, corpus, top_k=10)
Semantic search over a corpus of menu items.
result = client.search("spicy noodles", corpus=menu_items, top_k=5)
for r in result["results"]:
print(f"{r['item']}: {r['score']:.3f}")
| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | required | Search query |
corpus | list[str] | required | Items to search over |
top_k | int | 10 | Number of results to return |
Returns: dict with results (list with item, score, reranker_score) and query_preprocessed.
report(items, restaurant_name="")
Generate a menu health report.
result = client.report(menu_items, restaurant_name="My Restaurant")
print(f"Quality score: {result['quality_score']}/100")
| Parameter | Type | Default | Description |
|---|---|---|---|
items | list[str] | required | Full menu (up to 2,000 items) |
restaurant_name | str | "" | Restaurant name for the report |
Returns: dict with quality_score, noise_analysis, dedup_summary, non_food_items, cuisine_breakdown.
suggest(cart, menu, top_k=5)
Get upsell suggestions based on cart contents.
result = client.suggest(
cart=["Chicken Biryani"],
menu=restaurant_menu,
top_k=3
)
for s in result["suggestions"]:
print(f"{s['item']} - {s['reason']}")
| Parameter | Type | Default | Description |
|---|---|---|---|
cart | list[str] | required | Current cart items (up to 50) |
menu | list[str] | required | Full restaurant menu (up to 500) |
top_k | int | 5 | Number of suggestions |
Returns: dict with suggestions (list with item, reason, category).
balance()
Check your API credit balance.
result = client.balance()
print(f"Credits remaining: {result['credits_remaining']}")
Returns: dict with credits_remaining and usage info.
Error handling
from dish_embed.client import DishEmbedError
try:
result = client.dedup(items)
except DishEmbedError as e:
print(e.status_code) # HTTP status code (401, 422, 429, 500, etc.)
print(e.detail) # Error message from the API
Common errors:
| Status | Meaning |
|---|---|
| 401 | Invalid or missing API key |
| 422 | Validation error (items too long, empty list, etc.) |
| 429 | Rate limit exceeded |
| 500 | Server error |