SDK Reference
SDK Reference
Hivenora provides SDK packages for Python and TypeScript. Both are framework-agnostic and have no LLM dependencies. Both are currently in private preview.
Private Preview. These packages are not yet published to npm or PyPI. Contact us for access to the preview builds, or call the
REST API directly.
Installation
bash
# Python 3.8+
pip install hivenora
# No required dependencies.
# Optional:
pip install hivenora[httpx] # async support via httpx
pip install hivenora[anthropic] # wrap() helper for Anthropic clients
Client initialization
python
from hivenora import HivenoraClient
# API key from environment (recommended)
hivenora = HivenoraClient()
# Or pass explicitly
hivenora = HivenoraClient(
api_key="hvn_test_example_never_use_real",
base_url="https://api.hivenora.com", # default
timeout=10.0, # seconds, default 10
max_retries=2, # default 2
)
evaluate()
The primary method. Submits a proposed action and returns a decision.
Parameters
actionREQUIRED
str | stringThe action identifier. Use dot notation: crm.delete_contacts, stripe.refund, gmail.bulk_send.
intent
str | stringNatural language description of what the user asked the agent to do. Used for intent mismatch detection.
resource
str | stringIdentifier for the primary resource being acted on.
context
dict | objectStructured metadata: records_affected, amount, environment, data_sensitivity, reversibility, recipients.
environment
"production" | "sandbox"Overrides the environment in context if provided.
idempotency_key
str | stringIf provided, duplicate calls with the same key return the cached decision for 5 minutes.
Return value
request_id
strUUID identifying this evaluation. Use for approval polling.
decision
"allow" | "require_approval" | "block"The policy decision.
effective_decision
"allow" | "require_approval" | "block"The decision actually applied. In Shadow Mode, always "allow".
shadow_mode
boolTrue when the agent is in Shadow Mode.
blast_radius
"critical" | "high" | "medium" | "low"Estimated impact level.
blast_radius_factors
list[str]Human-readable reasons for the blast radius classification.
intent_mismatch
boolTrue if action scope appears to exceed stated intent.
reasons
list[str]Reasons for the decision.
matched_policy
PolicyInfo | nullThe policy that produced the decision, if any.
safer_alternative
SaferAlternative | nullA lower-impact alternative action suggested by Hivenora.
is_allowed
boolConvenience: effective_decision === "allow".
requires_approval
boolConvenience: effective_decision === "require_approval".
is_blocked
boolConvenience: effective_decision === "block".
Async support
Python async
TypeScript (always async)
python
# Requires: pip install hivenora[httpx]
result = await hivenora.evaluate_async(
action="crm.delete_contacts",
context={"records_affected": 4821},
)
# Without httpx installed, evaluate_async() falls back
# to a thread pool executor (stdlib urllib).
Error handling
python
from hivenora import (
HivenoraError, # base class
HivenoraAuthError, # 401/403 — bad API key
HivenoraApiError, # 4xx/5xx — e.attrs: status_code, body
HivenoraNetworkError, # network failure — e.cause
HivenoraTimeoutError, # extends NetworkError
)
try:
result = hivenora.evaluate(action="...", ...)
except HivenoraAuthError:
# Rotate the API key
pass
except HivenoraNetworkError:
# Fail closed — do not proceed
raise RuntimeError("Cannot evaluate: Hivenora unreachable")
except HivenoraApiError as e:
print(f"API error {e.status_code}: {e.body}")
Idempotency
Pass an idempotency_key to ensure that duplicate requests within a 5-minute window return the cached response instead of creating a new evaluation:
python
result = hivenora.evaluate(
action="stripe.refund",
context={"amount": 8400},
idempotency_key=f"refund-{order_id}-{attempt}",
)
The cache key is scoped to the agent. The same idempotency key submitted by a different agent produces a different cache entry.
REST API
You can call the API directly without the SDK:
bash
POST https://api.hivenora.com/v1/evaluate
X-Api-Key: hvn_test_example_never_use_real
Content-Type: application/json
{
"action": "crm.delete_contacts",
"intent": "Clean old test contacts",
"context": {
"records_affected": 4821,
"environment": "production"
}
}