Proxy and API

Point any Anthropic or OpenAI client at Guardian, and use the HTTP endpoints directly.

Guardian exposes the same HTTP surface it uses internally. Point an existing client at it, or call the endpoints directly.

Start the server

guardian start
guardian start -p 3000 --daily-budget 50 --monthly-budget 500
guardian start --lm-studio            # local runtime, no API key
guardian start --no-reasoning         # disable chain-of-thought

Default port: 3000.

Endpoints

EndpointMethodPurpose
/v1/chat/completionsPOSTOpenAI-compatible proxy
/v1/messagesPOSTAnthropic Messages-compatible proxy
/api/v1/stats/summaryGETAggregated stats
/api/v1/stats/savingsGETSavings analytics
/api/v1/stats/compressionGETCompression metrics
/api/v1/logsGETPaginated request logs
/api/v1/providersGETModel catalog
/api/v1/budgetGETBudget status
/api/v1/foldPOSTStandalone folding
/healthGETHealth check

OpenAI client

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:3000/v1",
  apiKey: "guardian-local-key",
});

const response = await client.chat.completions.create({
  model: "auto", // Guardian picks the cheapest capable model
  messages: [{ role: "user", content: "Explain semantic folding" }],
});

Anthropic client

export ANTHROPIC_BASE_URL="http://localhost:3000"

POST /v1/messages supports content blocks, multi-turn tool_use history, and the named SSE lifecycle. Set ANTHROPIC_API_KEY to route anthropic/* models directly to api.anthropic.com instead of through OpenRouter.

Standalone folding

curl -s http://localhost:3000/api/v1/fold \
  -H 'content-type: application/json' \
  -d '{"text":"a very long context","maxTokens":200}'

Budgets

Guardian enforces three caps:

VariableDefaultScope
MAX_REQUEST_COST_USD1.0One request
DAILY_BUDGET_USD50Per day
MONTHLY_BUDGET_USD500Per month

When a cap is hit, the request fails with a budget error rather than silently spending. Check remaining headroom with GET /api/v1/budget or /budget in the TUI.

Health and metrics

curl -s http://localhost:3000/health
curl -s http://localhost:3000/api/v1/stats/summary
curl -s http://localhost:3000/api/v1/stats/compression

The dashboard (guardian dash) reads the same endpoints.

Memory pack injection

Set MEMOS_NAMESPACE on the server and Guardian injects a MemOS pack ahead of the conversation. You can override it per request with memory_pack in the body. Errors are soft: a failed pack does not fail the request.