Skip to content

fix(quota-poller): switch Kilo balance to tRPC batch endpoint#215

Merged
typelicious merged 1 commit intomainfrom
fix/kilo-trpc-fetcher
Apr 18, 2026
Merged

fix(quota-poller): switch Kilo balance to tRPC batch endpoint#215
typelicious merged 1 commit intomainfrom
fix/kilo-trpc-fetcher

Conversation

@typelicious
Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the 4-URL REST probe list with a single tRPC batch GET to `https://app.kilo.ai/api/trpc/...\`
  • Parses `creditBlocks[].amount_mUsd` for total and `totalBalance_mUsd` for remaining; converts mUSD → USD
  • Implementation modeled on CodexBar's open-source Swift fetcher (same endpoint, same schema)

Why

The REST URLs shipped in v2.2.0 all return 404/308 — Kilo never published a stable REST balance API. The real endpoint is a tRPC batch that CodexBar discovered and documented in its open-source Swift code.

Test plan

  • Live: real account reports `total=40.00 used=11.45` (matches user's actual balance)
  • Parse handles both list and dict tRPC response shapes
  • Handles optional `{json: ...}` envelope
  • CI green across 3.10 / 3.11 / 3.12 / 3.13

🤖 Generated with Claude Code

The initial probe-list approach (4 REST URLs on kilocode.ai/kilo.ai)
all returned 404 or 308 because Kilo's balance lives behind a tRPC
batch call, not REST. Replaced with a single GET to

  https://app.kilo.ai/api/trpc/user.getCreditBlocks,kiloPass.getState,
    user.getAutoTopUpPaymentMethod?batch=1&input={urlencoded JSON}

Implementation cribbed from CodexBar's open-source Swift fetcher
(https://github.com/steipete/CodexBar) — same endpoint, same schema.
Amounts arrive in mUSD; we sum amount_mUsd across creditBlocks for
total, use totalBalance_mUsd for remaining, and divide by 1_000_000.

Verified live: a real Kilo account now reports total=\$40.00
used=\$11.45 in the operator dashboard.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@typelicious typelicious enabled auto-merge (squash) April 18, 2026 13:04
@typelicious typelicious merged commit ca773ad into main Apr 18, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant