integrations/langchain/README.md
langchain-openviking is the official OpenViking integration package for
LangChain and LangGraph applications. It keeps framework-specific adapters
separate from the OpenViking server and communicates with remote OpenViking
instances through the lightweight openviking-sdk package.
OpenViking Server requirement: examples here use the
viking://~home alias (for exampleviking://~/memories), which the server expands to the authenticated caller's own user space, so they require a server withviking://~support. The uid-lessviking://user/memoriesshorthand is rejected by newer servers; pass an explicitviking://user/<uid>/...URI when targeting another user.
For LangChain retrievers, tools, message history, and context wrappers:
pip install langchain-openviking
For the LangGraph store and middleware:
pip install "langchain-openviking[langgraph]"
from langchain_openviking import OpenVikingRetriever
from openviking_sdk import SyncHTTPClient
client = SyncHTTPClient(
url="http://127.0.0.1:1933",
api_key="your-user-api-key",
)
client.initialize()
retriever = OpenVikingRetriever(
client=client,
target_uri="viking://~/memories",
)
try:
documents = retriever.invoke("What deployment preferences should I remember?")
finally:
client.close()
The package also provides OpenVikingSessionRecorder,
OpenVikingContextMiddleware, OpenVikingStore,
OpenVikingChatMessageHistory, and create_openviking_tools.
client= or async_client= remains caller-owned.url= are managed by the adapter and can be closed with
close() or aclose() as documented by each adapter.The previous openviking.integrations.langchain import path remains available
from the full openviking distribution as a compatibility shim.
See the OpenViking documentation and the repository's
examples/langchain-langgraph directory for complete examples.