Files
openclaw-skill/openclaw-knowhow-skill/output/openclaw-docs_data/pages/Token_use_costs_8183d7c88c.json
Selig 4c966a3ad2 Initial commit: OpenClaw Skill Collection
6 custom skills (assign-task, dispatch-webhook, daily-briefing,
task-capture, qmd-brain, tts-voice) with technical documentation.
Compatible with Claude Code, OpenClaw, Codex CLI, and OpenCode.
2026-03-13 10:58:30 +08:00

49 lines
4.9 KiB
JSON
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"title": "Token use & costs",
"content": "OpenClaw tracks **tokens**, not characters. Tokens are model-specific, but most\nOpenAI-style models average \\~4 characters per token for English text.\n\n## How the system prompt is built\n\nOpenClaw assembles its own system prompt on every run. It includes:\n\n* Tool list + short descriptions\n* Skills list (only metadata; instructions are loaded on demand with `read`)\n* Self-update instructions\n* Workspace + bootstrap files (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md` when new). Large files are truncated by `agents.defaults.bootstrapMaxChars` (default: 20000).\n* Time (UTC + user timezone)\n* Reply tags + heartbeat behavior\n* Runtime metadata (host/OS/model/thinking)\n\nSee the full breakdown in [System Prompt](/concepts/system-prompt).\n\n## What counts in the context window\n\nEverything the model receives counts toward the context limit:\n\n* System prompt (all sections listed above)\n* Conversation history (user + assistant messages)\n* Tool calls and tool results\n* Attachments/transcripts (images, audio, files)\n* Compaction summaries and pruning artifacts\n* Provider wrappers or safety headers (not visible, but still counted)\n\nFor a practical breakdown (per injected file, tools, skills, and system prompt size), use `/context list` or `/context detail`. See [Context](/concepts/context).\n\n## How to see current token usage\n\n* `/status` → **emojirich status card** with the session model, context usage,\n last response input/output tokens, and **estimated cost** (API key only).\n* `/usage off|tokens|full` → appends a **per-response usage footer** to every reply.\n * Persists per session (stored as `responseUsage`).\n * OAuth auth **hides cost** (tokens only).\n* `/usage cost` → shows a local cost summary from OpenClaw session logs.\n\n* **TUI/Web TUI:** `/status` + `/usage` are supported.\n* **CLI:** `openclaw status --usage` and `openclaw channels list` show\n provider quota windows (not per-response costs).\n\n## Cost estimation (when shown)\n\nCosts are estimated from your model pricing config:\n\nThese are **USD per 1M tokens** for `input`, `output`, `cacheRead`, and\n`cacheWrite`. If pricing is missing, OpenClaw shows tokens only. OAuth tokens\nnever show dollar cost.\n\n## Cache TTL and pruning impact\n\nProvider prompt caching only applies within the cache TTL window. OpenClaw can\noptionally run **cache-ttl pruning**: it prunes the session once the cache TTL\nhas expired, then resets the cache window so subsequent requests can re-use the\nfreshly cached context instead of re-caching the full history. This keeps cache\nwrite costs lower when a session goes idle past the TTL.\n\nConfigure it in [Gateway configuration](/gateway/configuration) and see the\nbehavior details in [Session pruning](/concepts/session-pruning).\n\nHeartbeat can keep the cache **warm** across idle gaps. If your model cache TTL\nis `1h`, setting the heartbeat interval just under that (e.g., `55m`) can avoid\nre-caching the full prompt, reducing cache write costs.\n\nFor Anthropic API pricing, cache reads are significantly cheaper than input\ntokens, while cache writes are billed at a higher multiplier. See Anthropics\nprompt caching pricing for the latest rates and TTL multipliers:\n[https://docs.anthropic.com/docs/build-with-claude/prompt-caching](https://docs.anthropic.com/docs/build-with-claude/prompt-caching)\n\n### Example: keep 1h cache warm with heartbeat\n\n## Tips for reducing token pressure\n\n* Use `/compact` to summarize long sessions.\n* Trim large tool outputs in your workflows.\n* Keep skill descriptions short (skill list is injected into the prompt).\n* Prefer smaller models for verbose, exploratory work.\n\nSee [Skills](/tools/skills) for the exact skill list overhead formula.",
"code_samples": [
{
"code": "models.providers.<provider>.models[].cost",
"language": "unknown"
}
],
"headings": [
{
"level": "h2",
"text": "How the system prompt is built",
"id": "how-the-system-prompt-is-built"
},
{
"level": "h2",
"text": "What counts in the context window",
"id": "what-counts-in-the-context-window"
},
{
"level": "h2",
"text": "How to see current token usage",
"id": "how-to-see-current-token-usage"
},
{
"level": "h2",
"text": "Cost estimation (when shown)",
"id": "cost-estimation-(when-shown)"
},
{
"level": "h2",
"text": "Cache TTL and pruning impact",
"id": "cache-ttl-and-pruning-impact"
},
{
"level": "h3",
"text": "Example: keep 1h cache warm with heartbeat",
"id": "example:-keep-1h-cache-warm-with-heartbeat"
},
{
"level": "h2",
"text": "Tips for reducing token pressure",
"id": "tips-for-reducing-token-pressure"
}
],
"url": "llms-txt#token-use-&-costs",
"links": []
}