Skip to content

Pass CLIProxyAPI usage and tok/s into OpenCode session telemetry #5

Description

@RaviTharuma

Feature

Map gateway-reported cost, token usage, and tokens-per-second into the host harness so a run shows real $ and tok/s, not catalog guesses.

Why

OmniRoute already emits (non-stream) X-OmniRoute-Response-Cost, X-OmniRoute-Tokens-In/Out, X-OmniRoute-Latency-Ms, X-OmniRoute-Model, X-OmniRoute-Provider, X-OmniRoute-Decision. CLIProxyAPI often has upstream usage and, on some builds, internal TPS — but plugins typically register models and stop there.

Harness cost UIs (OpenCode session cost, Pi usage, OMP status) therefore:

  • price the requested model from models.dev / /api/pricing even after a combo/credential failover
  • omit tok/s, or compute it client-side from deltas (wrong on buffered streams and tool pauses)

Live generation speed cannot come from models.dev. It has to ride on the completion.

Requested behavior

  1. On each completion (stream final chunk included), read gateway usage/cost/tok/s headers or usage fields and write them into the host’s usage/cost/speed slots.
  2. If the gateway updates the routed model mid-request (combo / credential failover), update the host’s displayed model id for that turn.
  3. Prefer gateway numbers over catalog cost × token estimates when both exist.
  4. If the gateway has no tok/s yet, do not invent one from tokens / latency_ms (that includes TTFT). Show until the gateway field exists.
  5. Keep catalog sync (models.dev / /v1/models / /api/pricing) for picker metadata; this issue is per-request telemetry.

Related gateway asks (please link rather than re-implement scraping):

  • OmniRoute: tok/s + streaming cost headers
  • CLIProxyAPI: tok/s / usage on the inference response

Acceptance

  • One streamed turn shows host cost + tok/s that match the gateway response.
  • After failover, the turn is attributed to the model that answered.
  • No extra HTTP calls to dashboards or log APIs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions