When running kimi with stream-json (print) output, there is currently no way to obtain token usage from stdout. The PromptJsonWriter (src/cli/prompt-render.ts) only writes 5 JSON line types (system.version, session.resume_hint, turn.step.retrying, assistant, tool), and turn.step.completed events carrying usage are explicitly dropped in the print path. Verified on 0.37.2 — the word "usage" does not appear anywhere in the print/prompt-render code.
Usage data does exist internally: usage.record durable events are written to the session wire log (~/.kimi-code/sessions/<wd-slug>/<session_id>/agents/main/wire.jsonl) with full input/output/cache-read/cache-creation buckets. But consumers driving kimi headlessly (CI pipelines, orchestration platforms wrapping the CLI) must locate and tail this out-of-band file to get usage — fragile and racy while the session is still writing.
Request: emit a usage JSON line on stdout in stream-json mode, e.g. {"role":"meta","type":"turn.usage","usage":{"inputTokens":...,"outputTokens":...,"cacheReadTokens":...,"cacheCreationTokens":...}}, either per-turn or at session end. claude-code already does this (result event with usage), and it makes headless token accounting trivial.
Use case: we run kimi/opencode/codex/claude through a unified ledger and reconcile reported tokens per provider; kimi is the only one with no stdout usage outlet.
When running
kimiwith stream-json (print) output, there is currently no way to obtain token usage from stdout. ThePromptJsonWriter(src/cli/prompt-render.ts) only writes 5 JSON line types (system.version,session.resume_hint,turn.step.retrying,assistant,tool), andturn.step.completedevents carrying usage are explicitly dropped in the print path. Verified on 0.37.2 — the word "usage" does not appear anywhere in the print/prompt-render code.Usage data does exist internally:
usage.recorddurable events are written to the session wire log (~/.kimi-code/sessions/<wd-slug>/<session_id>/agents/main/wire.jsonl) with full input/output/cache-read/cache-creation buckets. But consumers driving kimi headlessly (CI pipelines, orchestration platforms wrapping the CLI) must locate and tail this out-of-band file to get usage — fragile and racy while the session is still writing.Request: emit a usage JSON line on stdout in stream-json mode, e.g.
{"role":"meta","type":"turn.usage","usage":{"inputTokens":...,"outputTokens":...,"cacheReadTokens":...,"cacheCreationTokens":...}}, either per-turn or at session end. claude-code already does this (resultevent withusage), and it makes headless token accounting trivial.Use case: we run kimi/opencode/codex/claude through a unified ledger and reconcile reported tokens per provider; kimi is the only one with no stdout usage outlet.