This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Configuration & setup

Everything that controls how OpenKB talks to your LLM lives in two places: .openkb/config.yaml (model, language, tuning) and a .env file (your API key).


Install

pip install openkb

OpenKB pins a pre-release of its PageIndex dependency (pageindex==0.3.0.dev1), which some installers skip by default. If an install can't resolve pageindex, allow pre-releases:

uv tool install openkb --prerelease=allow # uv
pip install --pre openkb # pip

If openkb isn't found after a successful install, the console-script directory isn't on your PATH (e.g. pip --user installs to ~/.local/bin) — add it to PATH.


1. Initialize a knowledge base

mkdir my-kb &&cd my-kb
openkb init

init is interactive in a terminal and prompts for three things:

  • Model — in LiteLLM provider/model format. OpenAI models can drop the prefix (gpt-5.4); others need it (anthropic/claude-sonnet-4-6, gemini/gemini-3-flash-preview).
  • LLM API key — hidden input; if you provide one it's written to .env with 0600 permissions. Press Enter to skip and set it later.
  • Language — the output language for your wiki. Any language works; e.g. the six official UN languages: en (English), zh (Chinese), es (Spanish), fr (French), ar (Arabic), ru (Russian).

Skip the prompts entirely with flags — handy in scripts:

openkb init --model anthropic/claude-sonnet-4-6 --language en
openkb init -m gpt-5.4 -l zh

Non-interactive (pipes/CI): prompts are gated on a TTY. When stdin isn't a terminal, init uses the defaults instead of hanging, so printf 'gpt-5.4\n\nen\n' | openkb init works in a script.

init creates: raw/, wiki/{summaries,concepts,entities,sources/images}, wiki/AGENTS.md, wiki/index.md, wiki/log.md, and .openkb/config.yaml.


2. .openkb/config.yaml reference

The file init writes is small; everything else is optional. This is the shipped config.yaml.example, verbatim:

model: gpt-5.4 # LLM model (any LiteLLM-supported provider)language: en # Wiki output languagepageindex_threshold: 20# PDF pages threshold for PageIndex# Optional: override the entity-type vocabulary used for entity pages.# Omit this key to use the default 7 types# (person, organization, place, product, work, event, other).# entity_types:# - person# - organization# - dataset# - model# Optional: LLM / LiteLLM tuning. Keys are forwarded to LiteLLM; `timeout` and# `extra_headers` apply per request, the rest are set as litellm.<key>.# litellm:# timeout: 1200 # per-request timeout (s); raise for slow local backends (Ollama)# drop_params: true # let LiteLLM drop params a provider rejects (e.g. Ollama)# num_retries: 3# extra_headers: # extra HTTP headers some providers need (e.g. GitHub Copilot)# Editor-Version: vscode/1.95.0# Copilot-Integration-Id: vscode-chat
KeyDefaultWhat it does
modelgpt-5.4LLM used for all compile/query/chat work.
languageenLanguage the wiki is written in.
pageindex_threshold20PDFs with this many pages or more take the long-doc (PageIndex) path; shorter ones go through the short-doc path. See pageindex-cloud/.
entity_types7 defaultsCustom vocabulary for entity pages. other is always kept.
litellm:A pass-through block for LiteLLM. See below.

The litellm: block

OpenKB forwards this block to LiteLLM so you can tune anything LiteLLM supports — you set it, LiteLLM uses it. Two keys are special:

  • timeout and extra_headers are applied per request (they're needed on every call).
  • Every other key (drop_params, num_retries, ssl_verify, …) is set on the litellm module as a process-wide global.

Slow local runtimes (Ollama, LM Studio, llama.cpp)

Local inference can be slow — on a Mac running LM Studio, a single compile call can take minutes, and the default request timeout will abort it (this is the usual cause of failures with local runtimes). Raise timeout (in seconds). Add drop_params for backends that reject OpenAI-only params (e.g. Ollama):

model: ollama/llama3.1 # or your LM Studio / llama.cpp model idlanguage: enlitellm:
drop_params: truetimeout: 1200# raise further (e.g. 3600) for large local models

GitHub Copilot / ChatGPT-subscription providers

These need extra headers and use OAuth (no API key):

model: github_copilot/gpt-4olanguage: enlitellm:
extra_headers:
Editor-Version: vscode/1.95.0Copilot-Integration-Id: vscode-chat

OpenRouter response caching

When your model is an openrouter/* model, you can opt into OpenRouter's Response Caching: identical-payload requests come back in ~80–300 ms with zero token billing. That's a direct win on the compile-retry path (a failed add re-runs every summary/plan/concept call with the same prompts) and on repeated lint / dev iteration. Send the cache headers via extra_headers:

model: openrouter/anthropic/claude-sonnet-4.5language: enextra_headers: # top-level, or nested under `litellm:` — both workX-OpenRouter-Cache: "true"X-OpenRouter-Cache-TTL: "600"# optional, 1–86400s (OpenRouter default 300)

It's opt-in by design: responses are stored on OpenRouter, so leave it off for zero-data-retention / regulated content. Only openrouter/* models read these headers; other providers ignore them.


3. API keys & providers

Set one universal key and OpenKB routes it to the right provider based on your model. The shipped .env.example:

# OpenAI: LLM_API_KEY=sk-...# Anthropic: LLM_API_KEY=sk-ant-...# Gemini: LLM_API_KEY=AIza...
LLM_API_KEY=your-key-here
  • Provider auto-detection:model: anthropic/claude-sonnet-4-6 → your LLM_API_KEY is exported as ANTHROPIC_API_KEY automatically.
  • OAuth providers (chatgpt/*, github_copilot/*) need no key — OpenKB won't warn about a missing one.
  • PageIndex Cloud uses a separate PAGEINDEX_API_KEY (see pageindex-cloud/).

Where keys are read from (first match wins, existing env always respected):

  1. your shell environment
  2. <kb>/.env
  3. ~/.config/openkb/.env (a global key shared across all your KBs)

4. Where is "the KB"?

Most commands need to know which KB they act on. Resolution order:

  1. --kb-dir /path/to/kb (or OPENKB_DIR=/path/to/kb) — explicit override.
  2. Walk up from the current directory looking for a .openkb/ folder.
  3. The global default registered by openkb use <path> (stored in ~/.config/openkb/global.yaml).
# Run a query against a specific KB from anywhere
openkb --kb-dir ~/research-kb query "what changed in v2?"# Make one KB the default, then forget about paths
openkb use ~/research-kb
openkb status # now resolves ~/research-kb from any directory

Next: commands/ — the everyday ingest-and-query loop.