Official Python SDK for EmberLM. Run versioned prompts from your production code, evaluate LLM responses, and ship AI with confidence.
pip install emberlmRequires Python 3.8+. Zero third-party dependencies.
Get an API key from Settings → API Keys
in the dashboard. Keys start with pk_live_.
from emberlm import Client
client = Client(api_key="pk_live_...")
result = client.run(
"summarize_docs",
variables={"document": doc_text},
)
print(result["text"])
print("passed_evals:", result["passed_evals"])
print("confidence:", result["confidence"])
print("cost_usd:", result["cost_usd"])
print("latency_ms:", result["latency_ms"])client = Client(
api_key="pk_live_...",
base_url="https://emberlm.dev", # optional
timeout=60, # optional, seconds
)List every prompt in the API key's workspace.
data = client.list_prompts()
for p in data["prompts"]:
print(p["name"], p["current_version"])Fetch a single prompt by name. Returns the prod-tagged version if one exists,
otherwise the latest.
prompt = client.get_prompt("summarize_docs")
print(prompt["system_prompt"], prompt["user_prompt"])Run a saved prompt. Variables are substituted into {{placeholders}}. All
workspace eval rules are applied to the output. The run is persisted and counts
toward the workspace's analytics.
result = client.run(
"classify_ticket",
variables={"body": ticket_body},
model="claude-haiku-4-5", # optional override
)
# result keys:
# run_id, prompt, version, model,
# text,
# input_tokens, output_tokens, total_tokens,
# cost_usd, latency_ms,
# passed_evals, confidence, evals,
# errorEvaluate an arbitrary response against the workspace's active eval rules. Useful when the response was generated by a different SDK or model.
result = client.eval(
response=llm_response,
prompt=user_prompt, # optional
variables={"name": "Jane"}, # optional
rule_ids=["rule-id-1"], # optional, defaults to all active
)
print(result["passed"], result["confidence"])An alias client.evaluate(...) is also available for users who prefer to
avoid the eval name.
Any non-2xx response raises EmberLMError:
from emberlm import Client, EmberLMError
try:
client.run("missing_prompt")
except EmberLMError as e:
print(e.status, str(e))| Status | Meaning |
|---|---|
| 401 | Missing or invalid API key |
| 403 | API key's plan does not permit the SDK |
| 404 | Prompt not found in the workspace |
| 429 | Monthly call limit reached, or rate limited |
100 requests / minute per API key.
MIT