"""Server-side Python 3 example using only the standard library.""" import json import os import urllib.request def analyze(question, *, api_key=None, where=None, timeout=50): key = api_key or os.environ.get("JYLUS_API_KEY") if not key: raise ValueError("Set JYLUS_API_KEY to a read-scoped workspace key") body = {"source": "current", "text": question, "vector": {"text": question}, "where": where or {}, "context": {"mode": "decision", "token_budget": 4000}, "include_results": False} request = urllib.request.Request("https://api.jylus.ai/api/v1/analyze", data=json.dumps(body).encode("utf-8"), method="POST", headers={"Authorization": "Bearer " + key, "Content-Type": "application/json"}) # HTTPError preserves the status and Retry-After header for caller handling. with urllib.request.urlopen(request, timeout=timeout) as response: return json.load(response)