[PR #6904] [management, proxy] Meter custom provider model costs #27454

Open
opened 2026-08-05 07:08:44 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6904
Author: @CoderSufiyan
Created: 7/26/2026
Status: 🔄 Open

Base: mainHead: fix/issue-6888-custom-provider-pricing


📝 Commits (3)

  • 4de1e03 [management, proxy] Meter custom provider model costs
  • 4684d7a [proxy] Match cost meter precision
  • 3ac5150 [proxy] Use switch for custom cache pricing

📊 Changes

5 files changed (+233 additions, -12 deletions)

View changed files

📝 management/internals/modules/agentnetwork/synthesizer.go (+62 -3)
📝 management/internals/modules/agentnetwork/synthesizer_test.go (+5 -1)
📝 proxy/internal/middleware/builtin/cost_meter/factory.go (+16 -1)
📝 proxy/internal/middleware/builtin/cost_meter/middleware.go (+54 -5)
📝 proxy/internal/middleware/builtin/cost_meter/middleware_test.go (+96 -2)

📄 Description

Summary

  • propagate valid configured provider model prices into synthesized cost-meter middleware config
  • meter prices by the router-resolved provider ID and model, with static pricing as the fallback
  • preserve provider cache-token semantics using configured input prices

Closes #6888

Testing

  • go test ./management/internals/modules/agentnetwork ./proxy/internal/middleware/builtin/cost_meter -count=1
  • go test ./proxy/... -count=1

Checklist

  • Documentation is not needed

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Added provider- and model-specific pricing overrides for cost calculations.
    • Exact pricing can be applied when provider and model details are available.
    • Generated pricing configuration now includes valid pricing for reachable, enabled providers and configured models.
  • Bug Fixes
    • Invalid, placeholder, or zero-value overrides no longer replace built-in pricing.
    • Cache-related costs now use the appropriate configured input rates when applicable.
  • Tests
    • Expanded coverage for pricing overrides, cache fallback behavior, and zero-price fallback.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6904 **Author:** [@CoderSufiyan](https://github.com/CoderSufiyan) **Created:** 7/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-6888-custom-provider-pricing` --- ### 📝 Commits (3) - [`4de1e03`](https://github.com/netbirdio/netbird/commit/4de1e03fb0f0190f4f11e79d3e10272bb61c4cb3) [management, proxy] Meter custom provider model costs - [`4684d7a`](https://github.com/netbirdio/netbird/commit/4684d7a30c70227b8fc49d5a08991fad6940a6c8) [proxy] Match cost meter precision - [`3ac5150`](https://github.com/netbirdio/netbird/commit/3ac515033700f7d366d8f1bfabce9159f5cd4d53) [proxy] Use switch for custom cache pricing ### 📊 Changes **5 files changed** (+233 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `management/internals/modules/agentnetwork/synthesizer.go` (+62 -3) 📝 `management/internals/modules/agentnetwork/synthesizer_test.go` (+5 -1) 📝 `proxy/internal/middleware/builtin/cost_meter/factory.go` (+16 -1) 📝 `proxy/internal/middleware/builtin/cost_meter/middleware.go` (+54 -5) 📝 `proxy/internal/middleware/builtin/cost_meter/middleware_test.go` (+96 -2) </details> ### 📄 Description ## Summary - propagate valid configured provider model prices into synthesized cost-meter middleware config - meter prices by the router-resolved provider ID and model, with static pricing as the fallback - preserve provider cache-token semantics using configured input prices Closes #6888 ## Testing - `go test ./management/internals/modules/agentnetwork ./proxy/internal/middleware/builtin/cost_meter -count=1` - `go test ./proxy/... -count=1` ## Checklist - [x] Documentation is **not needed** <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/netbirdio/codesmith/netbird/pr/6904"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1787652786&installation_model_id=427504&pr_number=6904&repository=netbirdio%2Fnetbird&return_to=https%3A%2F%2Fgithub.com%2Fnetbirdio%2Fnetbird%2Fpull%2F6904&signature=b71e0492609813cea64ea43d33e17148c64387cd174d6a5beb2b6022966c242c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added provider- and model-specific pricing overrides for cost calculations. * Exact pricing can be applied when provider and model details are available. * Generated pricing configuration now includes valid pricing for reachable, enabled providers and configured models. * **Bug Fixes** * Invalid, placeholder, or zero-value overrides no longer replace built-in pricing. * Cache-related costs now use the appropriate configured input rates when applicable. * **Tests** * Expanded coverage for pricing overrides, cache fallback behavior, and zero-price fallback. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:08:44 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#27454