Repository navigation
feat(metering): pass the free-model allowance limit through to clients - #32
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, codefree_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: newErrCodeFreeModelAllowanceconstant.metering/client.go: maps it like the daily token limit, with no retry.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 ./...andgo vet ./...pass.🤖 Generated with Claude Code