Skip to main content
hookie-ai is Hookie’s Python client for a project’s brain: its memories and decisions, knowledge search (memories, documents and the knowledge graph in one call), documents and the project context bundle. It ships adapters for LangChain, LangGraph and CrewAI, and it is MIT licensed. The package is on PyPI as hookie-ai.

Install

The client needs Python 3.9 or later. The [crewai] extra needs Python 3.10 or later, as CrewAI does. The distribution is hookie-ai; the import is hookie.

Your API key

Every call uses your own Hookie credential: an admin API key (hk_…) from Settings → API keys in the console, or a connected agent’s OAuth token. Hookie never supplies a key for you. The key acts as the member who created it, capped at its role and, optionally, one project. See API keys.
The client sends the key only as an Authorization: Bearer header to your Hookie origin (HTTPS, or http://localhost for development). It never logs the key, never puts it in an error, and leaves it out of repr(client).

Projects by id or slug

Hookie’s project routes take a project’s id. You can pass an id or a slug. The client looks a slug up once with GET /admin/api/projects; a project-scoped key, which may not list projects, uses the one project GET /admin/api/me names. With no project named, calls go to default, the slug of your workspace’s Default project. hk.project_id() returns the id the client resolved.

The client

AsyncHookie has the same methods, awaited, and supports async for over iter. Responses are the API’s JSON, unchanged, typed as TypedDicts in hookie.models. See Project context and Personal AI memory for what each field means. memories.extract sends a session to automatic memory capture: Hookie proposes up to 5 memories and decisions from it, redacts credentials before its model reads the text, and does not store the transcript.

Retries and idempotency

  • Every POST that writes carries an Idempotency-Key, so a retried save runs once. request() sends none on the routes that refuse one (api-keys and invites).
  • Reads (GETs and the search POSTs) are retried on 5xx and burst 429s, twice by default. A quota 429 is not retried, and neither is a 429 whose Retry-After is longer than 10 seconds.
  • When a retried write meets Hookie’s 409 “still in progress” (the first attempt timed out but is still running), the client waits for the first attempt’s answer, up to timeout. Past that, the HookieConflictError has reason == "idempotency_in_progress": ask again with the same idempotency_key, never a new one.

Errors

Every failure is a HookieError with status, reason, retry_after and body:

LangChain

Install hookie-ai[langchain].
  • Retriever: top_k is 1 to 20 in every mode. The memories mode matches the query word by word and ranks memories that match more words first.
  • Chat history: HookieChatMessageHistory keeps the messages in your process. Hookie keeps memories, not transcripts: capture() (and clear(), unless capture_on_clear=False) sends the conversation to automatic memory capture. System messages and tool output are left out of what is sent. recall(query) matches the query word by word.
  • Tools: create_hookie_tools(async_client=...) needs no sync client and no HOOKIE_API_KEY unless a tool is then called synchronously.

LangGraph

Install hookie-ai[langgraph].
  • Context node: keeps its message at the front of the history and replaces it rather than repeating it. The messages key must use add_messages, as MessagesState does, so a model or prompt that adds its own system message never gets two apart.
  • Capture node: sends only what the person and the agent said, not the context, other system messages or tool output.
Hookie memories are curated notes rather than a key-value store, so there is no BaseStore. Keep the graph’s own state in a LangGraph checkpointer.

CrewAI

Install hookie-ai[crewai] (Python 3.10 or later).
The tools are HookieKnowledgeSearchTool, HookieProjectContextTool and HookieSaveMemoryTool, which saves a memory or a decision.

Read-only agents

Pass allow_writes=False to any of the tool factories (create_hookie_tools, create_hookie_tool_node, hookie_crewai_tools) to leave out the tools that save. For a read-only key, create one with the viewer role in Settings → API keys.

Content is data, not instructions

Memories, documents and graph nodes are written by people and agents. The framework tools’ text and the context node’s message start with a note saying so. Keep that note when you build your own prompts from search results.