CortexHub Python SDK — Runtime governance for AI systems. One decorator, any tool, any framework.
Project description
CortexHub Python SDK
Runtime governance for AI systems. One decorator. Any tool. Any framework.
pip install cortexhub
Python 3.10–3.12.
Optional installs (match your agent stack)
Use bracket extras so peer dependencies install in one step — same shape as the demo app:
| Extra | Typical use | Pair with cortexhub.init(framework=...) |
|---|---|---|
openai-agents or openai-agent |
OpenAI Agents SDK | openai_agents |
langchain |
LangChain / shared ChatModel |
langchain |
langgraph |
LangGraph + OpenAI chat models (pulls langgraph, langchain-openai, …) |
langgraph |
anthropic or claude |
Claude / Anthropic Messages API | anthropic, claude, or claude_agents |
crewai, llama-index, autogen, pydantic-ai, semantic-kernel, google-adk |
Those ecosystems | llama_index: auto llm.call + cortexhub.llm.thought via callbacks; others: fleet label + cx.llm_call / record_llm_result / record_llm_thought unless you route via another hooked client |
agents |
LangGraph + OpenAI Agents together (demo-style) | Set framework= per vertical |
* Automatic llm.call hooks today: OpenAI Agents, LangChain / LangGraph (BaseChatModel.invoke / ainvoke), Anthropic (messages.create, non-streaming), LlamaIndex (CallbackManager / CBEventType.LLM, non-streaming turn completion). Same @cx.tool governance everywhere; other stacks use cx.llm_call / cx.record_llm_result / cx.record_llm_thought or a hooked client above.
pip install 'cortexhub[agents]' # LangGraph + OpenAI Agents (examples repo backend)
# pip also accepts: pip install 'cortexhub[langgraph,openai-agents]'
Quick start
Identity comes from your agent key only — the control plane assigns the canonical agent id. Set CORTEXHUB_AGENT_KEY (or pass agent_key= to init()).
import cortexhub
cx = cortexhub.init() # requires CORTEXHUB_AGENT_KEY (or pass agent_key=)
@cx.tool(classification="write")
def process_payment(customer_id: str, amount: str, reference: str) -> dict:
"""Process a payment."""
return payment_service.charge(customer_id, amount, reference)
# Policies, approvals, and audit trail are configured in the control plane.
Configuration
| Env var | Description |
|---|---|
CORTEXHUB_AGENT_KEY |
Agent identity secret (required for cloud enforcement) |
CORTEXHUB_DEBUG |
Set to 1 or true for readable SDK logs: tool + arguments, policy name + condition, and decision |
CORTEXHUB_LOG_LEVEL |
e.g. DEBUG, INFO (default INFO) |
Debug logging
With CORTEXHUB_DEBUG=1 (or CORTEXHUB_DEBUG_POLICY=1), the SDK logs in real time:
- Tool encountered — tool name and argument names/values (values redacted when privacy mode is on)
- Policy evaluated — policy name, condition/reasoning, and decision (allow / deny / escalate)
- Decision — final effect, policy, and reason for the current tool call
Useful for seeing exactly what CortexHub is evaluating and why a tool was allowed, blocked, or sent for approval.
OpenAI Agents SDK (llm.call telemetry)
If you use the OpenAI Agents SDK, initialise with framework="openai_agents" so each model turn is captured as llm.call spans (assistant reasoning text and tool-call intent), merged automatically with any hooks= you pass to Runner.run.
pip install 'cortexhub[openai-agents]'
# or: pip install 'cortexhub[openai-agent]'
cx = cortexhub.init(framework="openai_agents")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cortexhub-0.5.28.tar.gz.
File metadata
- Download URL: cortexhub-0.5.28.tar.gz
- Upload date:
- Size: 12.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9edcc11c26a3dce5a139ede377f110dbb627622a628dc7b4e922fde7a475cf
|
|
| MD5 |
9f3830890194e77f1606e8dfb92b0e54
|
|
| BLAKE2b-256 |
9c0536742bdd192636ab7fd87c2f525a346f6495a012da8d1e38c07ce8fcb4ff
|
File details
Details for the file cortexhub-0.5.28-py3-none-any.whl.
File metadata
- Download URL: cortexhub-0.5.28-py3-none-any.whl
- Upload date:
- Size: 12.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ff5145f87b8005149b462cbf7bf2f7aa48890ba5efc91ab0758cea6e34b7866
|
|
| MD5 |
559e2e0993a97271114fdb2eecc4edb4
|
|
| BLAKE2b-256 |
d4abdd0e6088cc4269c3d9b48857d71d1e09fe1d473ed27846f7704f1f5fa077
|