Hippocortex SDK Overview

The Hippocortex SDKs provide client libraries for integrating agent memory into any AI application. Available in TypeScript and Python with framework-specific adapters.


Integration Methods

The SDK offers three integration paths, from zero-effort to full manual control:

MethodEffortDescriptionBest For
import auto1 lineSentry-style monkey-patching of OpenAI/Anthropic SDKsFastest start, prototyping
wrap(client)1 lineTransparent client wrapping with full type safetyProduction apps, explicit control
new Hippocortex()ManualDirect capture/learn/synthesize callsCustom agent loops, non-OpenAI/Anthropic LLMs

Auto-Instrumentation (Easiest)

// TypeScript: one import, zero config
import '@hippocortex/sdk/auto'
# Python: one import, zero config
import hippocortex.auto

Every OpenAI and Anthropic SDK call automatically gets memory context injection and conversation capture. No other code changes required.

wrap() (Recommended)

import { wrap } from '@hippocortex/sdk'
import OpenAI from 'openai'

const openai = wrap(new OpenAI())
// Use exactly as before. Memory is transparent.
from hippocortex import wrap
from openai import OpenAI

client = wrap(OpenAI())
# Use exactly as before. Memory is transparent.

Manual Client (Advanced)

The manual client exposes three core operations:

OperationWhat It DoesWhen to Call It
capture()Record an agent interaction eventAfter every significant agent action
learn()Trigger memory compilationPeriodically or after a batch of events
synthesize()Retrieve relevant context for a queryBefore the agent needs to make a decision

This three-function model keeps integration simple: instrument your agent with capture calls, periodically compile knowledge, and retrieve context when needed.


Zero-Config

All integration methods support automatic configuration resolution:

  1. Explicit arguments passed to wrap(), new Hippocortex(), etc.
  2. Environment variables: HIPPOCORTEX_API_KEY, HIPPOCORTEX_BASE_URL
  3. Config file: .hippocortex.json (searched from cwd upward to filesystem root)

.hippocortex.json

{
  "apiKey": "hx_live_your_key_here",
  "baseUrl": "https://api.hippocortex.dev/v1"
}

Language Support

LanguagePackageInstall CommandMin Version
TypeScript@hippocortex/sdknpm install @hippocortex/sdkNode 18+
Pythonhippocortexpip install hippocortexPython 3.10+

Both SDKs provide identical functionality and API parity.


Framework Adapters

Adapters wrap the core SDK to integrate with popular AI agent frameworks. They handle event translation from framework-specific formats to Hippocortex event types.

AdapterFrameworkLanguageAuto-captures
OpenAI AgentsOpenAI AgentsPythonMessages, tool calls, tool results
LangGraphLangGraphPythonNode events, tool calls, state
CrewAICrewAIPythonTask events, agent actions
AutoGenAutoGenPythonMessages, function calls
OpenClawOpenClawBothAll event types

Adapters are installed as optional dependencies alongside the core SDK.


Authentication

All SDK operations require an API key:

const hx = new Hippocortex({
  apiKey: 'hx_live_your_key_here'
});

API Key Formats

PrefixEnvironmentPurpose
hx_live_ProductionProduction data operations
hx_test_TestTest environment, no billing

API keys are created in the Hippocortex Dashboard or via the API Keys endpoint.

Key Permissions

Each API key carries read and/or write permissions:

PermissionOperations
readsynthesize, listArtifacts, getArtifact, getMetrics
writecapture, captureBatch, learn

Error Handling

Both SDKs throw typed errors with structured error information:

TypeScript

import { HippocortexError } from '@hippocortex/sdk';

try {
  await hx.capture(event);
} catch (error) {
  if (error instanceof HippocortexError) {
    console.error(`Code: ${error.code}`);
    console.error(`Status: ${error.statusCode}`);
    console.error(`Message: ${error.message}`);
    console.error(`Details:`, error.details);
  }
}

Python

from hippocortex import HippocortexError

try:
    await hx.capture(event)
except HippocortexError as e:
    print(f"Code: {e.code}")
    print(f"Status: {e.status_code}")
    print(f"Message: {e}")
    print(f"Details: {e.details}")

Error Codes

CodeHTTP StatusDescription
validation_error400Invalid request body
unauthorized401Missing or invalid API key
forbidden403Insufficient permissions
not_found404Resource does not exist
rate_limited429Too many requests
internal_error500Server-side error
duplicate_event409Event already captured (idempotency)

Rate Limits

Rate limits are enforced per API key based on the account plan:

PlanRequests/MinuteBurst Allowance
Free6010
Developer600100
Pro3,000500
EnterpriseUnlimitedUnlimited

Rate limit headers are included in every response:

X-RateLimit-Limit: 600
X-RateLimit-Remaining: 594
X-RateLimit-Reset: 1709251200

When rate limited, the SDK receives a 429 response. Implement exponential backoff in your retry logic.


Configuration Options

TypeScript

const hx = new Hippocortex({
  apiKey: 'hx_live_...',       // Required: API key
  baseUrl: 'https://...',      // Optional: API base URL (default: https://api.hippocortex.dev/v1)
  timeoutMs: 30000,            // Optional: Request timeout in ms (default: 30000)
});

Python

hx = Hippocortex(
    api_key="hx_live_...",           # Required: API key
    base_url="https://...",          # Optional: API base URL
    timeout=30.0,                    # Optional: Timeout in seconds (default: 30.0)
)

Next Steps