Skip to content

feat(metering): pass the free-model allowance limit through to clients - #32

Merged
hcastc00 merged 1 commit into
mainfrom
feat/free-model-allowance
Nov 27, 2026
Merged

hcastc00 merged 1 commit into
mainfrom
feat/free-model-allowance

Conversation

@hcastc00

@hcastc00 hcastc00 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Metering is adding a monthly token allowance per account plan for free models (models priced at zero for every token). When a request doesn't fit, Metering answers the reservation with HTTP 429, type rate_limit_error, code free_model_allowance_exceeded, and a message that includes the reset time.

The Gateway passes Metering errors through only when it recognises the code; anything else becomes a 500. This adds the new code next to daily_token_limit_exceeded, so clients get the 429 and Metering's message.

  • pkg/domain: new ErrCodeFreeModelAllowance constant.
  • metering/client.go: maps it like the daily token limit, with no retry.
  • The test now covers both limit codes: passed through unchanged, not retried.

Companion: dappnode/dappnode-nexus#173

Deploy order

Deploy this before the Metering change, or refused free-model requests reach clients as 500s. It's safe on its own: Metering doesn't send the code yet.

Test plan

  • go test ./... and go vet ./... pass.

🤖 Generated with Claude Code

Metering now refuses free-model requests that exceed the account plan's
monthly free-model token allowance with HTTP 429 and the code
free_model_allowance_exceeded. Map it like the daily token limit, so
clients get the 429 and Metering's message (with the reset time) instead
of a 500.

Deploy before the Metering change in dappnode-nexus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hcastc00
hcastc00 merged commit b48cbae into main Nov 27, 2026
5 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