Skip to content

API proxy token usage reports 0 input and cache tokens for an Anthropic-compatible Z.AI endpoint #75271

Closed

Description

@dsfaccini

This issue was posted by Claude Code using claude-opus-5-5 on behalf of David.

The AWF api-proxy's token usage table reports Input and Cache Read as 0 for every request to Z.AI's Anthropic-compatible endpoint. The Claude Code CLI's own result for the same session reports the real counts. Output tokens match.

Versions: gh-aw v0.86.2 (compiler and github/gh-aw-actions/setup), ghcr.io/github/gh-aw-firewall/api-proxy:0.27.44, Claude Code 2.1.227 in the threat-detection job.

Setup: threat detection uses engine: claude with ANTHROPIC_BASE_URL: https://api.z.ai/api/anthropic and model glm-5.3-flash. The AWF config routes it through apiProxy with targets.anthropic.host: api.z.ai.

Evidence: run https://github.com/pydantic/pydantic-ai/actions/runs/42064093118, job detection (127393142350).

Claude Code's result line (2026-11-05T16:58:10Z):

"modelUsage":{"glm-5.3-flash":{"inputTokens":38719,"outputTokens":4058,"cacheReadInputTokens":112640,"cacheCreationInputTokens":0}}

The api-proxy table parsed from /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/token-usage.jsonl in the same job (2026-11-05T16:58:14Z):

# | Alias | Input | Output | Cache Read | Cache Write | Duration
1 | glm53 | 0 | 135   | 0 | 0 | 3.0s
2 | glm53 | 0 | 63    | 0 | 0 | 5.7s
3 | glm53 | 0 | 1,087 | 0 | 0 | 24.6s
4 | glm53 | 0 | 234   | 0 | 0 | 7.9s
5 | glm53 | 0 | 1,659 | 0 | 0 | 34.4s
6 | glm53 | 0 | 880   | 0 | 0 | 21.2s
Total |   | 0 | 4,058 | 0 | 0 | 1m37s

Output totals agree (4,058). Input is 0 against 38,719, and cache read is 0 against 112,640.

Expected: the table and token-usage.jsonl carry the input and cache-read tokens the provider returned.

Impact: token summaries and anything built on token-usage.jsonl undercount Z.AI runs. This run's summary shows 4,058 of 155,417 tokens.

Activity

  1. locked and limited conversation to collaborators on Nov 6, 2026
  2. unlocked this conversation on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions