API reference
The daemon (default 127.0.0.1:8787) is OpenAI-compatible, so any OpenAI client, opencode, OpenClaw, Hermes, Codex, or your own, can point at it. Requests are also tool-calling capable: tool calls stream through verbatim (delta.tool_calls), finish with finish_reason: "tool_calls", and role: "tool" result messages round-trip unchanged.
Completions
POST /v1/completions
POST /v1/chat/completions
Standard OpenAI request/response shapes, with streaming (SSE) support. max_tokens is clamped to the effective context advertised by the daemon, so clients never hit "not enough tokens" 400s on small boxes.
Cache admin
POST /cache/lookup # look up a prompt against the cached index
DELETE /cache/{id} # evict a single cached prompt
GET /cache/stats # hit rate, bytes, entries
Health
GET /healthz
Auth
Set TOKI_AUTH_TOKEN to gate the API. Clients send it as a standard Authorization: Bearer <token> header. The web UI itself is always open (no login); the web server authenticates every proxied daemon call with its own configured credential.
Client wiring
Any OpenAI-compatible client works. Example, opencode:
{
"provider": {
"tokirecur": {
"name": "Toki Recur (KV-cache, local)",
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "http://127.0.0.1:8787/v1",
"apiKey": "demo-token"
},
"models": {
"qwen3.5-9b": {
"name": "Qwen3.5 9B (Toki Recur)",
"contextWindow": 24000,
"limit": { "context": 24000, "output": 8192 }
}
}
}
},
"small_model": "tokirecur/qwen3.5-9b"
}
The model id is a label; the actual weights are whatever llama-server has loaded. contextWindow should stay under TOKI_MAX_CONTEXT_TOKENS.
Codex (Responses API)
Codex CLI (v0.146+) speaks the Responses API. Point it at the daemon with wire_api = "responses"; the daemon serves /v1/responses and translates between the two protocols transparently (including tool calls, reasoning summaries, and cache metrics).
[model_providers.tokirecur]
name = "Toki Recur"
base_url = "http://127.0.0.1:8787/v1"
wire_api = "responses"
env_key = "TOKI_AUTH_TOKEN"
[model_providers.tokirecur.env]
TOKI_AUTH_TOKEN = "demo-token"
Next: Benchmark, workloads, scoring, and measured results.