okfsmith logo okfsmith Docs EN Open okfsmith
On this page

Providers

Providers & API keys

Providers & API keys

okfsmith's LLM mode (ingest extraction, chat generative answers) works with any OpenAI-compatible endpoint. Out of the box, the default is local and free: Ollama. When you're ready for hosted models, pick one of the 15 presets and add an API key.

Quick setup: a hosted provider in 60 seconds

export OKFSMITH_PROVIDER=openrouter
export OKFSMITH_API_KEY=your-key-here
export OKFSMITH_MODEL=openai/gpt-4o-mini

okfsmith chat ./kb

That's it. Verify your key is detected (without ever seeing the key) with:

okfsmith doctor

The 15 provider presets

--provider accepts any of these. Each maps to the provider's OpenAI-compatible base URL:

PresetWhat it's for
ollamaLocal models via Ollama — the default, free, private
lmstudioLocal models via LM Studio
openaiOpenAI's API (GPT models)
groqGroq's fast inference API
mistralMistral AI's API
deepseekDeepSeek's API
openrouterOpenRouter — one key, hundreds of models
togetherTogether AI inference
fireworksFireworks AI inference
deepinfraDeepInfra inference
anyscaleAnyscale endpoints
perplexityPerplexity's API
xaixAI's API (Grok)
geminiGoogle's Gemini via its OpenAI-compatible endpoint
agentrouterAgent Router — gateway to many providers
# Same command, any provider — change only the preset
okfsmith ingest ./kb report.pdf --provider groq --model llama-3.3-70b-versatile

Environment variables

VariablePurpose
OKFSMITH_API_KEYAPI key for the hosted endpoint (preferred)
OKFSMITH_PROVIDERProvider preset name (e.g. openrouter)
OKFSMITH_API_BASECustom OpenAI-compatible base URL (see below)
OKFSMITH_MODELDefault model name (overridden by --model)
AGENTROUTER_API_KEYHonored when the provider resolves to agentrouter
OPENAI_API_KEYLegacy fallback for hosted OpenAI-compatible endpoints

Example: Agent Router

export OKFSMITH_PROVIDER=agentrouter
export AGENTROUTER_API_KEY=your-key-here
okfsmith chat ./kb --model anthropic/claude-sonnet-4

Flags

FlagWhat it does
--provider <name>Choose a preset (e.g. openrouter)
--model <id>Model id for extraction/chat answers
--api-base <url>Any other OpenAI-compatible endpoint — overrides --provider
--api-key <key>Pass a key directly ⚠️ warns: this lands in your shell history

Example: anything else via --api-base

Azure OpenAI, self-hosted vLLM or llama.cpp, any compat proxy — all work:

# keep the key in an env var — never as a flag (flags land in shell history)
export OKFSMITH_API_KEY=your-key-here
okfsmith ingest ./kb docs/ --api-base https://my-proxy.example.com/v1 \
  --model my-model

Precedence order

When several sources are set, okfsmith resolves them in this order:

  1. Flags — --provider, --model, --api-base, --api-key
  2. Environment variables — OKFSMITH_PROVIDER, OKFSMITH_MODEL, OKFSMITH_API_BASE, OKFSMITH_API_KEY
  3. Defaults — Ollama at http://localhost:11434/v1, model qwen3:8b

So a flag always wins over an env var, which wins over the built-in default.

Ollama: the local default

With no keys and no flags, okfsmith expects Ollama on your machine:

# 1. Install Ollama from https://ollama.com, then pull a model
ollama pull qwen3:8b

# 2. Use okfsmith as-is — no keys, no env vars
okfsmith ingest ./kb report.pdf

doctor reports the Ollama reachability, provider, base URL, and model it's using — handy when something feels off (cli.html#okfsmith-doctor).

Anthropic's native API

Anthropic's own API is not OpenAI-compatible, so there is no --provider anthropic. To use Claude models with okfsmith, go through a compatible proxy or gateway:

# Option 1: OpenRouter
export OKFSMITH_PROVIDER=openrouter
export OKFSMITH_API_KEY=your-key-here
okfsmith chat ./kb --model anthropic/claude-sonnet-4

# Option 2: Agent Router
export OKFSMITH_PROVIDER=agentrouter
export AGENTROUTER_API_KEY=your-key-here
Advanced: how keys are resolved and masked - `doctor` distinguishes the key's source: `via OKFSMITH_API_KEY`, `via AGENTROUTER_API_KEY`, or `via OPENAI_API_KEY`. The value is never echoed, logged, or included in JSON output. - The CLI's own `--help` for `--api-key` explicitly warns that the flag value lands in shell history — prefer the env var. - `OKFSMITH_API_BASE` (or its alias `OKFSMITH_BASE_URL`) accepts any OpenAI-compatible base URL; when set, it takes precedence over the preset's canonical URL (`--api-base` overrides both). - Combining `--model` with `--no-llm` is a parameter error — `--no-llm` mode does deterministic extraction and never calls a model. - LLM extraction is the default ingest path: running `ingest` *without* `--no-llm` calls the configured LLM, and if none is reachable it errors rather than silently falling back.

Next →

CLI reference →