How to Use OpenViking: A Complete Setup Guide for AI Agent Context Management
Purpose
When I started building AI agents, context management was my biggest challenge. My agents could access immediate context, but they had no persistent memory. Every session started from scratch. They couldn’t reference documentation I’d previously added, and there was no way to search through accumulated knowledge.
OpenViking solves this problem. It’s a context management database that gives your agents persistent, searchable memory. In this post, I’ll show you how to set it up and use it in under 5 minutes.
What is OpenViking?
OpenViking is a context management system for AI agents. It lets you:
- Add resources (URLs, PDFs, code repositories) to a persistent knowledge base
- Search those resources semantically (by meaning, not just keywords)
- Access everything through a Unix-like CLI or Python SDK
The key innovation is the virtual filesystem paradigm. You interact with context the same way you interact with files: list, read, find, grep. If you know ls and find, you already know OpenViking.
Environment
Before starting, I made sure I had:
- Python 3.10 or higher
- Go 1.22+ (for AGFS components)
- C++ Compiler: GCC 9+ or Clang 11+
- An API key from OpenAI or another LLM provider
Step 1: Installation
I installed OpenViking with pip:
pip install openviking --upgrade --force-reinstallThis gives you three commands:
openviking- Main CLI (alias forov)ov- Short CLI aliasopenviking-server- The backend server
For the Rust CLI (optional but faster):
curl -fsSL https://raw.githubusercontent.com/volcengine/OpenViking/main/crates/ov_cli/install.sh | bashStep 2: Model Configuration
OpenViking needs two types of models:
- Embedding model - For semantic search
- VLM (Vision Language Model) - For understanding content
I created the configuration file at ~/.openviking/ov.conf:
{ "storage": { "workspace": "/home/your-name/openviking_workspace" }, "embedding": { "dense": { "api_base": "https://api.openai.com/v1", "api_key": "your-api-key", "provider": "openai", "dimension": 3072, "model": "text-embedding-3-large" } }, "vlm": { "api_base": "https://api.openai.com/v1", "api_key": "your-api-key", "provider": "openai", "model": "gpt-4o" }}Provider Options
OpenViking supports multiple providers:
| Provider | Best For | Models |
|---|---|---|
| OpenAI | Default choice | GPT-4o, text-embedding-3-large |
| Volcengine | Chinese market | Doubao models |
| LiteLLM | Multi-provider | Anthropic, DeepSeek, Gemini, Qwen, vLLM, Ollama |
For LiteLLM configuration:
{ "vlm": { "api_base": "http://localhost:4000", "api_key": "your-litellm-key", "provider": "litellm", "model": "anthropic/claude-3-opus-20240229" }}Step 3: Start the Server
I started the OpenViking server:
openviking-serverThe server runs in the foreground. I keep it running in a separate terminal or use tmux:
tmux new -s openvikingopenviking-server# Ctrl+B D to detachStep 4: CLI Quick Commands
With the server running, I tested the CLI.
Check Status
ov statusOutput:
Server: runningWorkspace: /home/cowrie/openviking_workspaceResources: 0Add a Resource
I added the OpenViking GitHub repository:
ov add-resource https://github.com/volcengine/OpenViking --waitThe --wait flag blocks until indexing completes. Without it, indexing happens in the background.
Output:
Adding resource: https://github.com/volcengine/OpenVikingCloning repository...Processing files...Creating embeddings...Resource added: volcengine/OpenVikingList Resources
ov ls viking://resources/Output:
viking://resources/volcengine/viking://resources/volcengine/OpenViking/View Directory Tree
ov tree viking://resources/volcengine -L 2Output:
viking://resources/volcengine/└── OpenViking/ ├── docs/ ├── src/ ├── README.md └── pyproject.tomlSemantic Search
This is the key feature. I searched for what OpenViking is:
ov find "what is openviking"Output:
Found 5 results:
1. viking://resources/volcengine/OpenViking/README.md Score: 0.89 Abstract: OpenViking is a context management database for AI agents...
2. viking://resources/volcengine/OpenViking/docs/intro.md Score: 0.85 Abstract: OpenViking provides persistent memory for AI agents...
3. viking://resources/volcengine/OpenViking/docs/quickstart.md Score: 0.82 Abstract: Get started with OpenViking in 5 minutes...Grep Within Resources
For exact string matching:
ov grep "openviking" --uri viking://resources/volcengine/OpenViking/docsOutput:
docs/intro.md:3:OpenViking is a context management databasedocs/quickstart.md:1:# OpenViking Quick Startdocs/quickstart.md:5:Install OpenViking with pip...Step 5: Python SDK Usage
For programmatic access, I used the Python SDK:
from openviking.client import OpenViking
# Initialize clientclient = OpenViking()
# Add a resourceclient.add_resource( "https://docs.example.com/api.pdf", reason="API documentation for reference")
# Semantic searchresults = client.find("authentication methods")
for ctx in results.resources: print(f"{ctx.uri}: {ctx.abstract}")
# Filesystem operationsfiles = client.ls("viking://resources/")print(f"Available resources: {files}")
# Read specific filecontent = client.read("viking://resources/docs/auth.md")print(content)Async Usage
import asynciofrom openviking.client import AsyncOpenViking
async def main(): client = AsyncOpenViking()
# Add multiple resources in parallel urls = [ "https://github.com/volcengine/OpenViking", "https://docs.python.org/3/", "https://fastapi.tiangolo.com/" ]
tasks = [client.add_resource(url) for url in urls] await asyncio.gather(*tasks)
# Search results = await client.find("how to create a fastapi endpoint") for ctx in results.resources: print(f"Found in: {ctx.uri}")
asyncio.run(main())Common Issues
Issue 1: Permission Denied on Workspace
When I started the server, I got:
Error: Cannot create workspace directory: /home/other/openviking_workspacePermission deniedFix: Ensure the workspace directory exists and is writable:
mkdir -p ~/openviking_workspacechmod 755 ~/openviking_workspaceIssue 2: API Key Not Found
When running semantic search:
Error: OPENAI_API_KEY not found in environmentFix: Set the API key in the config file or environment:
export OPENAI_API_KEY="sk-proj-xxxxx"Or add it to ~/.openviking/ov.conf.
Issue 3: Server Not Running
When I ran CLI commands:
Error: Cannot connect to OpenViking server at localhost:8080Fix: Start the server first:
openviking-server# Or check if it's already runningps aux | grep openvikingIssue 4: Embedding Dimension Mismatch
When adding resources:
Error: Embedding dimension mismatch: expected 3072, got 1536Fix: Update the dimension in your config to match the model:
{ "embedding": { "dense": { "model": "text-embedding-3-small", "dimension": 1536 } }}Best Practices
DO
Use meaningful resource names
# Good: Descriptive namingov add-resource https://github.com/volcengine/OpenViking --name "openviking-source"
# Bad: Default naming can be unclearov add-resource https://github.com/volcengine/OpenVikingOrganize with directories
# Create structure for different projectsov mkdir viking://resources/project-alpha/ov mkdir viking://resources/project-beta/Use specific search queries
# Good: Specific queryov find "how to configure embedding model in openviking"
# Less effective: Vague queryov find "config"DON’T
Don’t add duplicate resources
# Bad: Adding same URL twice wastes storage and computeov add-resource https://github.com/volcengine/OpenVikingov add-resource https://github.com/volcengine/OpenViking
# Good: Check firstov ls viking://resources/ | grep OpenVikingDon’t skip the —wait flag for testing
# Bad for scripts: Returns immediately, resource not readyov add-resource https://example.com/docs
# Good for scripts: Waits until indexing completesov add-resource https://example.com/docs --waitDon’t use small embedding dimensions for large corpuses
{ "embedding": { "dense": { "dimension": 256 // Too small for semantic search quality } }}Comparison with Alternatives
I tested OpenViking against other context management tools:
| Feature | OpenViking | ChromaDB | Pinecone | Local Files |
|---|---|---|---|---|
| Setup Time | 5 min | 15 min | 20 min | Instant |
| CLI Interface | Yes | No | No | Yes |
| Semantic Search | Yes | Yes | Yes | No |
| Virtual Filesystem | Yes | No | No | Yes |
| Self-Hosted | Yes | Yes | No | Yes |
| Cost | API only | Free | Paid | Free |
OpenViking wins on developer experience. The Unix-like CLI makes it intuitive for anyone who knows basic shell commands.
Summary
In this post, I showed how to set up and use OpenViking for AI agent context management. The key points are:
- Install with
pip install openviking - Configure embedding and VLM models in
~/.openviking/ov.conf - Start the server with
openviking-server - Use
ov add-resourceto add knowledge - Use
ov findfor semantic search
The entire setup takes about 5 minutes. The virtual filesystem paradigm makes context management feel natural: list, read, find, grep. If you’re building AI agents that need persistent memory, OpenViking provides a clean, developer-friendly solution.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments