Skip to content

fix: restore om-usage HTTP endpoint - #5859

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.43from
Witroch4:witalo/restore-om-usage-http-endpoint-upstream
Jul 2, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.43from
Witroch4:witalo/restore-om-usage-http-endpoint-upstream

Conversation

@Witroch4

@Witroch4 Witroch4 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Restores GET /api/usage/om-usage as a terminal-friendly HTTP endpoint for the existing @@om-usage self-service command.
  • Reuses the same API key authentication and allowUsageCommand permission gate used by the in-chat command.
  • Supports provider and connection selection via query/header inputs, while preserving the existing personal USD quota output when API-key USD quota is enabled.

Root cause

The app already had the local @@om-usage command, but the HTTP route was missing. Requests to /api/usage/om-usage?provider=claude were falling through to the dynamic /api/usage/[connectionId] route, so om-usage was treated as a connection id and returned Connection not found.

Behavior

A valid OmniRoute API key with allowUsageCommand enabled can now call:

curl "http://<host>/api/usage/om-usage?provider=claude" \
  -H "Authorization: Bearer <api-key>"

The response is text/plain and returns the same usage/quota text as the local command, without calling an upstream provider.

Validation

  • DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx/esm --test tests/unit/internal-usage-command.test.ts → 10/10 passing
  • npx eslint src/lib/usage/internalUsageCommand.ts src/app/api/usage/om-usage/route.ts tests/unit/internal-usage-command.test.ts → passing
  • Production smoke test on Witalo's fork deployment returned HTTP 200 for /api/usage/om-usage?provider=claude after deploy.

Restore GET /api/usage/om-usage as a terminal-friendly equivalent of @@om-usage. The route authenticates normal API keys, respects allowUsageCommand, and supports provider/connection selection while preserving the existing usage text format.\n\nTests:\n- DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx/esm --test tests/unit/internal-usage-command.test.ts\n- npx eslint src/lib/usage/internalUsageCommand.ts src/app/api/usage/om-usage/route.ts tests/unit/internal-usage-command.test.ts\n- npm run typecheck:core\n- npm run build\n- Docker build omniroute:restore-om-usage-http-20260701181714\n- Production curl /api/usage/om-usage?provider=claude returned HTTP 200\n\nNote: pre-commit docs-sync currently fails on existing docs/i18n CHANGELOG body size drift unrelated to this change, so this commit bypasses the hook.
@Witroch4
Witroch4 requested a review from diegosouzapw as a code owner July 1, 2026 21:32
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.43 July 1, 2026 23:43
…rors

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
@diegosouzapw
diegosouzapw merged commit cfb2db8 into cheaper-inference:release/v3.8.43 Jul 2, 2026
3 checks passed
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @Witroch4! Solid diagnosis on the dynamic-route shadowing. We completed the authz registration (/api/usage/om-usage as an exact public prefix), wrapped the handler with sanitized error responses, and added end-to-end classify tests — all under your authorship. Merged into release/v3.8.43. For #5863, please rebase the percentage delta on top of this. 🙌

tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
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.

2 participants