API reference
Cortexhub
Construct the client with either an agent API key or a programmatic MCP OAuth credential.
import cortexhub
cx = cortexhub.init("cxh_key_...") # alias for Cortexhub(api_key=...)
# or
from cortexhub import Cortexhub
cx = Cortexhub(api_key="cxh_key_...")
cx = Cortexhub(client_id="...", client_secret="...")
cortexhub.init(api_key=None, **kwargs) is a thin alias for Cortexhub(...). It accepts the key positionally (cortexhub.init("cxh_key_...")); the Cortexhub(...) constructor is keyword-only (use Cortexhub(api_key="cxh_key_..."), not Cortexhub("cxh_key_...")).
If both credential paths are configured, the API-key path is used.
Constructor
| Argument | Description |
|---|---|
| api_key | Agent API key beginning with cxh_key_ |
| client_id, client_secret | Programmatic MCP OAuth credentials |
| token_url | Override the OAuth token endpoint |
Methods and properties
| Member | Description |
|---|---|
| session(...) | Creates one conversation/run handle |
| mcp(...) | Shortcut for session(...).mcp |
| fetch_token(...) | Gets an OAuth token; OAuth path only |
| ai | AI gateway URL and key; API-key path only |
| llm | OpenAI client convenience property; API-key path only. Use session.llm when attribution and grouping are required. |
| mode | Active credential path |
session requires agent for MCP connections. mcp_session_id is the caller-owned conversation or run ID. end_user_subject is required for API-key requests. end_user_display_hint is optional presentation text.
McpKeySession
Fields include api_key, agent, mcp_session_id, end_user_subject, end_user_display_hint, mcp, session_id, and llm.
decide(approval_id, decision, note=None) relays an end user's approve/deny for a
governed tool call that parked for consent. decision is "approve" or "deny";
note is optional. Authenticated by this session's org key, agent, and
end_user_subject; the decision is recorded as that end user's consent. See
Approvals.
McpOAuthSession
Fields include access_token, agent, mcp_session_id, conversation_title, last_user_message, and mcp.
SessionMcp
SessionMcp exposes url and headers for your MCP transport. SessionMcp.open() opens the Streamable HTTP transport and yields read/write streams for mcp.ClientSession. It requires the mcp extra.
Configuration
| Variable | Default |
|---|---|
| CORTEXHUB_API_KEY | none |
| CORTEXHUB_URL | https://mcp.cortexhub.ai |
| CORTEXHUB_ROUTER_URL | https://api.cortexhub.ai/v1 |
| CORTEXHUB_CLIENT_ID | none |
| CORTEXHUB_CLIENT_SECRET | none |
See Errors.