Providers and configuration

OpenRouter, Anthropic, Gemini, local LM Studio, budgets, and the environment variables that control them.

Guardian routes to a provider you choose. The default is OpenRouter; direct Anthropic, Gemini, and local OpenAI-compatible runtimes are also supported.

Providers

ProviderWhen to useSetup
OpenRouterOne key, many models, cheapest-model routingOPENROUTER_API_KEY
Anthropic directLower latency for Claude modelsANTHROPIC_API_KEY
Google GeminiGemini modelsGEMINI_API_KEY
LM StudioLocal models on port 1234guardian --lm-studio
OllamaLocal models on port 11434GUARDIAN_OLLAMA_BASE_URL
llama.cppLocal server on port 8080GUARDIAN_LLAMA_CPP_BASE_URL
Any OpenAI-compatiblevLLM, TGI, a gatewayguardian --base-url ... --api-key ...

Environment variables

VariableDefaultPurpose
OPENROUTER_API_KEY—OpenRouter routing
ANTHROPIC_API_KEY—Direct Anthropic routing
GEMINI_API_KEY—Gemini routing
GUARDIAN_LOCAL_API_KEY—Key for a custom local gateway
GUARDIAN_LOCAL_BASE_URLhttp://127.0.0.1:8080/v1Custom local endpoint
OLLAMA_API_KEY—Optional Ollama gateway key
GUARDIAN_OLLAMA_BASE_URLhttp://127.0.0.1:11434/v1Ollama endpoint
LLAMA_CPP_API_KEY—Optional llama.cpp key
GUARDIAN_LLAMA_CPP_BASE_URLhttp://127.0.0.1:8080/v1llama.cpp endpoint
LMSTUDIO_API_KEY—Optional LM Studio key
GUARDIAN_LMSTUDIO_BASE_URLhttp://127.0.0.1:1234/v1LM Studio endpoint
GUARDIAN_PORT3000Server port
DAILY_BUDGET_USD50Daily cap
MONTHLY_BUDGET_USD500Monthly cap
MAX_REQUEST_COST_USD1.0Per-request cap
MEMOS_NAMESPACE—Enables MemOS memory injection
MEMOS_STORAGE_PATH~/.memos/memos.dbMemOS database path

Budgets

Budgets are hard caps, not warnings. A request that would exceed a cap fails before it is sent.

guardian start -p 3000 --daily-budget 50 --monthly-budget 500

Check the current state:

curl -s http://localhost:3000/api/v1/budget

Precedence

  1. CLI flags (--model, --base-url, --api-key).
  2. Environment variables.
  3. Built-in defaults.

That means a one-off --base-url does not permanently change your config.

Local models

# LM Studio
guardian --lm-studio

# Any OpenAI-compatible server
guardian --base-url http://127.0.0.1:8000/v1 --api-key local

Local providers do not need an API key unless your gateway enforces one. Folding and budgets work the same way; only the model call changes.

Safety

  • Privacy shield redacts PII and blocks prompt-injection patterns before the request leaves the process.
  • Tool gating keeps tools the current turn cannot use out of the prompt.
  • Budget enforcement prevents runaway spend.
  • No implicit network calls beyond the provider you configured.

Local does not mean private

If you route to a hosted provider, the prompt leaves your machine. Folding reduces what is sent, but it does not make a hosted call local.