Skip to content

feat(customer-portal): reuse budget groups for organizations - #52411

Merged
tin-berri merged 1 commit into
mainfrom
litellm_customer_org_budget_tiers
Nov 18, 2026
Merged

tin-berri merged 1 commit into
mainfrom
litellm_customer_org_budget_tiers

Conversation

@tin-berri

@tin-berri tin-berri commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves

  • Customer organizations cannot reuse saved budget groups

How it solves it

  • Share the existing member group editor and save flow
  • Select a group or type dollars in one field

Intentional product change: typing a dollar amount replaces the selected group with a custom org budget. That org stops receiving changes to the group

User Flow

Before, the organization budget only accepts a dollar amount

  1. Open /customers and click Create organization
  2. Enter Demo tier organization and identifier demo-tier-org
  3. The monthly budget field has no saved-group selection

Before, custom dollars only

After, the same field accepts either a saved group or dollars

  1. Open /customers and click Create organization
  2. Enter Demo tier organization and identifier demo-tier-org
  3. Select Growth, or type $40 for a custom budget
  4. Create reusable groups in the sidebar Settings page at /customers/settings

After, select a saved group or type dollars

Changes

  • Reuse CustomerBudgetGroups, its editor, validation and save flow for both scopes
  • Reuse configure_templates and the existing budget writer for group changes
  • Assign ordinary budget rows through the existing organization budget_id
  • Store the reusable group ID list in existing config storage, with no schema changes
  • Preserve separate org spend, custom budgets, revision checks and cache invalidation

Final commit d746e428: all required CI checks pass, Greptile is 5/5, Bugbot and Veria found no issues, and Devin shows no findings needing attention. All review threads are resolved

Pre-Submission checklist

  • I have added meaningful tests
  • The focused tests covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is isolated to this feature
  • Automated reviews cover the latest commit and findings are addressed

Screenshots / Proof of Fix

The proof below uses the actual dashboard, Postgres, Redis and real model requests, with baseline 8ad167030460bb0574a6c958c928465edce8fead. The review fixes were verified at b9d2f646; the final wording-only update and recording were verified at d746e428. The two-worker proxy commands and environment setup are below

Before

  1. The create dialog only accepts dollars, as shown above
  2. GET /management/v1/customer_organization_budget_groups returns 404
  3. Creating an organization with budget_id returns 422

After

  1. The same create dialog selects a saved group, as shown above
  2. Settings saves named monthly and yearly groups through the shared editor
  3. The budget field saves a selected group or a custom $40 monthly budget
  4. The recording edits and saves monthly limits in both organization and member group editors
  5. Existing custom-budget edits retain their other windows and original scalar cap/reset period
org-tiers-final-shared-demo.mp4

Shared budget-group editor in Settings

Chat Completions

  1. POST /v1/chat/completions returns 200 with the shared group
  2. Changing the group cap to zero returns 422
  3. Switching that org to custom returns 200 while the other org remains capped

Responses

  1. POST /v1/responses returns 200 with the shared group
  2. Changing the group cap to zero returns 422
  3. Switching that org to custom returns 200 while the other org remains capped

Messages

  1. POST /v1/messages returns 200 with the shared group
  2. Changing the group cap to zero returns 422
  3. Switching that org to custom returns 200 while the other org remains capped

The recording shows the shared editing and switching flows. Returning to a saved group discards temporary custom edits. Returning to custom dollars preserves its private budget ID, reset period and yearly cap. Tests verify rejected saves and empty responses preserve drafts in both scopes. Clearing monthly dollars preserves other custom limits. Unchecking Set a budget and limits removes the whole custom budget. The custom-window edit was verified again through the dashboard with $150 historical spend, a $25 monthly window and a $1,000 yearly window. All three model endpoints returned 200 and the scalar cap stayed unset

The 22 live receipts also cover alias and member cache invalidation, concurrent budget edits rejecting stale revisions, generic budget updates, and preserving reusable rows after the last org is deleted. The API example below was executed successfully against the unchanged budget-enforcement implementation

Local verification passed 285 backend tests, 100 affected dashboard tests, production type checking, the production build, API-type synchronization and make check. The earlier enforcement proof covered 88 of 89 added executable lines and killed all five behavior mutations for ownership, deletion and stale revisions. This update changes response metadata and editor state only; the enforcement paths are unchanged

Budget selection review fixes and real dashboard recording

The review findings reproduced on 8f0ce2a9. Clearing an unsaved group choice removed a private budget, and a catalog 503 disabled custom dollar entry

On b9d2f646, the same dashboard flow keeps the private budget ID, $1,000 yearly cap, 7d reset, and rate limits when clearing the amount. With only the catalog GET returning 503, the real dashboard creates a $40 organization and edits an existing custom budget to $60 and 300 TPM. A shared organization stays assigned to its group when saving its display name during that failure

Before, custom dollars and limits are unavailable during a catalog failure

Before, custom budget input disabled

After, dollars and custom limits remain editable during the same failure

After, custom budget saved during catalog failure

org-tiers-review-fixes.mp4

The final tip d746e428 also corrects the shared label and custom-option hint so they do not describe a saved 7d or non-recurring budget as monthly. This final diff changes only wording and the matching test selectors. The earlier outage recording at b9d2f646 still proves the unchanged save behavior; all 100 focused UI tests and make check pass again

Before, the $75 seven-day budget is labelled monthly

Before, seven-day budget labelled monthly

After, the same budget has an accurate label and retains its seven-day reset

After, neutral customer budget label

Final-tip recording of editing dollars and clearing a temporary group while preserving custom limits

org-tiers-final-reviewed.mp4

To repeat the clearing case, open /customers/manage?org=qa-ui-simple&tab=settings with a custom budget, select Growth, click Clear, then Save changes. The yearly cap and rate limits remain. Unchecking Set a budget and limits remains the explicit full-removal action

To repeat the outage case, save the local forwarding script below as catalog_fault_proxy.py, run it, and restart the dashboard with NEXT_PUBLIC_USE_REWRITES=true LENS_DEV_PROXY_URL=http://127.0.0.1:4190. It forwards authenticated requests to the real proxy on 4188 and returns 503 only for the catalog GET while qa/catalog-unavailable exists

mkdir -p qa
touch qa/catalog-unavailable
python3 catalog_fault_proxy.py
# In the dashboard directory, with the same local authentication environment
NEXT_PUBLIC_USE_REWRITES=true LENS_DEV_PROXY_URL=http://127.0.0.1:4190 \
  ../../scripts/with_dashboard_node.sh npm run dev -- --port 3188 --hostname 127.0.0.1
import http.client
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path

FLAG = Path(__file__).parent / "qa/catalog-unavailable"
class Proxy(BaseHTTPRequestHandler):
    def do_request(self):
        payload = self.rfile.read(int(self.headers.get("Content-Length", 0)))
        if self.command == "GET" and self.path.split("?")[0] == "/management/v1/customer_organization_budget_groups" and FLAG.exists():
            body = b'{"detail":"Group catalog temporarily unavailable"}'
            self.send_response(503)
            self.send_header("Content-Type", "application/json")
            self.send_header("Content-Length", str(len(body)))
            self.end_headers()
            self.wfile.write(body)
            return
        upstream = http.client.HTTPConnection("127.0.0.1", 4188, timeout=90)
        headers = {k: v for k,v in self.headers.items() if k.lower() not in ("host", "connection", "transfer-encoding")}
        upstream.request(self.command, self.path, body=payload, headers=headers)
        response = upstream.getresponse()
        body = response.read()
        self.send_response(response.status)
        for k,v in response.getheaders():
            if k.lower() not in ("connection", "transfer-encoding", "content-length"):
                self.send_header(k,v)
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)
        upstream.close()
    do_GET = do_POST = do_PATCH = do_DELETE = do_OPTIONS = do_request
    def log_message(self, *args):
        pass
ThreadingHTTPServer(("127.0.0.1", 4190), Proxy).serve_forever()

Create an organization with $40, then edit a private budget's dollars and rate limits. Both save against the real proxy. For a shared organization, only unrelated fields remain editable until the catalog loads. Remove qa/catalog-unavailable to recover the catalog

The regressions fail on the prior code. The final focused run passes 100 UI and 285 backend tests, including both member and organization group editing

Exact local setup and executed API workflow

Use an isolated Postgres instance on port 55817 and Redis on port 55818. Set DATABASE_URL, LITELLM_MASTER_KEY, UI_USERNAME, UI_PASSWORD, and LITELLM_DEV_API_KEY in the process environment. Set PROXY_BASE_URL and LITELLM_CORS_ORIGINS to http://org-tiers.localhost:3188. Run make bootstrap in each checkout

model_list:
  - model_name: org-tier-proof
    litellm_params:
      model: openai/openai/gpt-5.4-nano
      api_base: https://gateway.product-dev.internal.litellm.ai/v1
      api_key: os.environ/LITELLM_DEV_API_KEY
router_settings:
  redis_host: 127.0.0.1
  redis_port: 55818
  redis_db: 1
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  coordination_redis:
    host: 127.0.0.1
    port: 55818
    db: 1
litellm_settings:
  drop_params: true
python litellm/proxy/proxy_cli.py --config qa/final.yaml \
  --host 127.0.0.1 --port 4188 --num_workers 2 --detailed_debug \
  --reload --use_v2_migration_resolver
cd litellm/ui/litellm-dashboard
NEXT_PUBLIC_USE_REWRITES=true LENS_DEV_PROXY_URL=http://127.0.0.1:4188 \
  ../../scripts/with_dashboard_node.sh npm run dev -- --port 3188 --hostname 127.0.0.1

For baseline use API port 4187, UI port 3187, Redis database 0 and a separate database. Copy that populated database before starting the final proxy. The PR uses the unchanged baseline schema

Run this script with API=http://127.0.0.1:4188 and the private admin key in LITELLM_MASTER_KEY. It retains existing groups and removes its two test organizations and key afterward. The isolated instance needs room for two organizations under the free-tier limit

import json
import os

import httpx

api = os.environ.get("API", "http://127.0.0.1:4188")
headers = {"Authorization": "Bearer " + os.environ["LITELLM_MASTER_KEY"]}
groups_path = "/management/v1/customer_organization_budget_groups"
orgs_path = "/management/v1/customer_organizations"

with httpx.Client(base_url=api, headers=headers, timeout=60) as client:
    def request(method, path, body=None, status=200):
        response = client.request(method, path, json=body)
        assert response.status_code == status, (path, response.status_code, response.text)
        return response.json() if response.content else None

    def save(groups):
        current = request("GET", groups_path)
        return request("PATCH", groups_path, {
            "expected_revision": current["budget_groups_revision"],
            "default_budget_template": None,
            "default_budgets": groups,
        })

    existing = request("GET", groups_path)["default_budgets"]
    retained = [{"budget_id": group["budget_id"], "name": group["name"]} for group in existing]
    saved = save([*retained, {"name": "QA Calendar", "budget_limits": [
        {"budget_duration": "1mo", "max_budget": 100},
        {"budget_duration": "12mo", "max_budget": 1000},
    ]}])
    group_id = next(group["budget_id"] for group in saved["default_budgets"] if group["name"] == "QA Calendar")
    for org_id in ("qa-calendar-a", "qa-calendar-b"):
        organization = request("POST", orgs_path, {
            "customer_org_id": org_id, "alias": org_id, "budget_id": group_id,
        }, 201)
        assert organization["budget_id"] == group_id

    key = request("POST", "/key/generate", {"models": ["org-tier-proof"]})["key"]
    model_headers = {
        "Authorization": "Bearer " + key,
        "x-litellm-customer-org-alias": "qa-calendar-a",
        "anthropic-version": "2023-06-01",
    }
    routes = {
        "/v1/chat/completions": {"messages": [{"role": "user", "content": "Say OK."}], "max_completion_tokens": 32},
        "/v1/responses": {"input": "Say OK.", "max_output_tokens": 32},
        "/v1/messages": {"messages": [{"role": "user", "content": "Say OK."}], "max_tokens": 32},
    }

    def infer(expected):
        for route, payload in routes.items():
            response = client.post(route, headers=model_headers, json={"model": "org-tier-proof", **payload})
            assert response.status_code == expected, (route, response.status_code, response.text)
            print(json.dumps({"route": route, "status": response.status_code}), flush=True)

    infer(200)
    save([*retained, {"budget_id": group_id, "name": "QA Calendar", "budget_limits": [
        {"budget_duration": "1mo", "max_budget": 0},
        {"budget_duration": "12mo", "max_budget": 1000},
    ]}])
    infer(422)
    before = request("GET", orgs_path + "/qa-calendar-a")
    custom = request("PATCH", orgs_path + "/qa-calendar-a", {
        "budget": {"budget_limits": [{"budget_duration": "1mo", "max_budget": 175}]},
    })
    assert custom["budget_id"] != group_id
    assert custom["spend"] >= before["spend"]
    other = request("GET", orgs_path + "/qa-calendar-b")
    assert other["budget_id"] == group_id
    assert other["budget"]["budget_limits"][0]["max_budget"] == 0
    infer(200)
    for org_id in ("qa-calendar-a", "qa-calendar-b"):
        request("DELETE", orgs_path + "/" + org_id, status=204)
    save(retained)
    request("POST", "/key/delete", {"keys": [key]})
    print("Calendar group update and custom switching passed")

Expected output is 200, 422, then 200 for each of the three model endpoints, followed by Calendar group update and custom switching passed

Type

New Feature

Final Attestation

  • Regression tests and live workflows cover shared groups, custom budgets, concurrent edits and deletion safety

Note

Medium Risk
Changes customer-org budget assignment, shared budget lifecycle, and cache invalidation on catalog updates—areas that affect spend enforcement—but extends existing group configuration rather than new schema or auth paths.

Overview
Adds a proxy-admin catalog of reusable organization budget groups (GET/PATCH customer_organization_budget_groups), stored as budget IDs in existing litellm_config, with the same revision-checked save flow as per-org member groups. Customer organizations can now assign budget_id to a catalog group or keep a private budget, with budget_is_shared on responses; switching to custom dollars forks off the shared row, and generic budget delete is blocked for catalog entries.

The dashboard gets a Customer Management Settings page and a unified budget combobox (saved group or typed amount) on create/edit org flows, reusing the shared group editor in a global mode without member-default controls. SearchSelect gains controlled input so custom amounts commit without losing a prior group selection.

Reviewed by Cursor Bugbot for commit d746e42. Bugbot is set up for automated code reviews on this repo. Configure here.

@tin-berri
tin-berri requested a review from a team November 18, 2026 01:37
@veria-ai

veria-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Reviews

veria-ai[bot]

This comment was marked as resolved.

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from 16aa160 to df28877 Compare November 18, 2026 01:55
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review organization tiers, override precedence, independent spend accounting, and the persisted calendar-cap regression on this commit.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review organization tiers, policy inheritance, independent spend counters, and the persisted override regression on this commit.

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with no new actionable issues found.

Summary

Customer organizations can reuse saved budget groups or keep custom dollar budgets. The shared budget field now uses wording that also fits seven-day and non-recurring budgets.

  • Proxy admins can save budget groups for use across organizations.
  • Organizations can use shared groups or private budgets.
  • Organization budget fields accept a group or dollar amount.

No new actionable issues found. The three earlier findings remain addressed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Settings[Customer Settings] --> Catalog[Reusable organization budget groups]
  Catalog --> Choice[Organization budget field]
  Dollars[Custom dollar amount] --> Choice
  Choice --> Shared[Assign shared budget ID]
  Choice --> Private[Create or update private budget]
  Catalog --> Checks[Revision and deletion checks]
Loading

Reviews (16) · Last reviewed commit: "feat(customer-portal): reuse budget grou..." · Reviewed by Greptile

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@codspeed

codspeed Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 45 untouched benchmarks


Comparing litellm_customer_org_budget_tiers (d746e42) with main (65d30c2)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (22ef726) during the generation of this report, so 65d30c2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.90110% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...llm/proxy/management_helpers/customer_hierarchy.py 98.24% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from df28877 to 10939c6 Compare November 18, 2026 02:18
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 10939c65, including guarded migration replay and updated transaction fixtures. Application behavior and the recorded demo are unchanged.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review 10939c65, including the migration guard and transactional budget fixtures. The application code is unchanged.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from 10939c6 to 5426729 Compare November 18, 2026 03:11
@tin-berri tin-berri changed the title feat(customer-portal): add organization budget tiers feat(customer-portal): reuse budget groups for organizations Nov 18, 2026
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 5426729, which rebuilds organization budgets around the existing group editor, configuration flow, and single budget reference.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run Please review 5426729, which reuses existing budget groups for organizations with a single group-or-custom budget reference.

cursor[bot]

This comment was marked as resolved.

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from 5426729 to d81c54e Compare November 18, 2026 03:24
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review d81c54e7. The revision helper was renamed for the recursion checker, and reset fixtures now support group lookups.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run Please review d81c54e7, including the revision helper rename and the reset fixture update. Product behavior is unchanged.

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from d81c54e to 7e5cbcc Compare November 18, 2026 03:29
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 7e5cbcce. The only additional change aligns the shared editor’s delete button, verified in both organization and member views.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run Please review 7e5cbcce. The delete button now uses the final grid column, verified in both editor scopes.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from 7e5cbcc to f455e81 Compare November 18, 2026 03:55
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review f455e81. Customer budget now accepts a saved group or dollar amount directly in both create and edit flows.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run Please review f455e81, including direct dollar entry, selecting numeric group names, blur persistence, and existing organization budget edits.

cursor[bot]

This comment was marked as resolved.

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 8f0ce2a9. Group reselection restores saved fields, while returning to custom dollars preserves private budget ownership and other limits.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review 8f0ce2a9. Both group and custom round trips now have regression coverage and live dashboard verification, alongside shared editing.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 18, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from 8f0ce2a to b9d2f64 Compare November 18, 2026 07:12
@greptile-apps
greptile-apps Bot dismissed their stale review November 18, 2026 07:12

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review b9d2f646. Both reported budget selection failures now have regression coverage and verified dashboard flows

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review b9d2f646. Both budget selection issues are fixed, with saved ownership handling and live verification of clearing and catalog failures

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 18, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@tin-berri

Copy link
Copy Markdown
Contributor Author

/devin review

Please review b9d2f646. Catalog failures now preserve custom editing and protect saved group assignments, with live verification

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Starting Devin Review.

Devin Review

@tin-berri
tin-berri force-pushed the litellm_customer_org_budget_tiers branch from b9d2f64 to d746e42 Compare November 18, 2026 07:34
@greptile-apps
greptile-apps Bot dismissed their stale review November 18, 2026 07:34

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@tin-berri

Copy link
Copy Markdown
Contributor Author

/devin review

Please review d746e42. The shared budget label and custom-option hint now avoid claiming monthly resets for existing custom budgets

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Starting Devin Review.

Devin Review

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review d746e42. The final change corrects the shared budget label for non-monthly budgets, with matching regression selectors and recorded dashboard verification

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review d746e42. The final change corrects the shared budget label for non-monthly budgets. The two original selection fixes retain their passing regression and live-dashboard proof

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d746e42. Configure here.

@tin-berri
tin-berri merged commit ee13362 into main Nov 18, 2026
158 of 160 checks passed
@tin-berri
tin-berri deleted the litellm_customer_org_budget_tiers branch November 18, 2026 08:01
tin-berri pushed a commit that referenced this pull request Nov 18, 2026
Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.
ishaan-j-berri added a commit that referenced this pull request Nov 18, 2026
* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* fix(customer-portal): enforce app caps and charge each window once

Enforce an authenticated app budget when optional customer and app headers are omitted. Normalize overlapping scalar and explicit budget windows to a single charge with the stricter cap and explicit reset time.

Cover all app primitives through native HTTP auth and use realistic empty gateway configuration in existing test doubles.

* fix(customer-portal): reuse budget controls and admission

Use shared customer budget controls for app forms and resolve member budgets at one owner. Remove unused app lifecycle and listing routes.

Parse request identity once, check each global and app scope once, and keep app counters alive through the existing database flush window.
devin-ai-integration Bot added a commit that referenced this pull request Nov 18, 2026
…ers (#52485)

* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* feat(proxy): let each app decide whether it may create unknown customers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: sort imports

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): lock the app customer switch while its save is pending

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): refuse an unknown organization alias sent with a known member

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): refuse an unknown customer before reporting its organization's budget

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(ui): move the no-app customer switch into its own component

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* fix(customer-portal): enforce app caps and charge each window once

Enforce an authenticated app budget when optional customer and app headers are omitted. Normalize overlapping scalar and explicit budget windows to a single charge with the stricter cap and explicit reset time.

Cover all app primitives through native HTTP auth and use realistic empty gateway configuration in existing test doubles.

* fix(customer-portal): reuse budget controls and admission

Use shared customer budget controls for app forms and resolve member budgets at one owner. Remove unused app lifecycle and listing routes.

Parse request identity once, check each global and app scope once, and keep app counters alive through the existing database flush window.

* fix(customer-portal): preserve app attribution for deferred costs

Persist the original trusted customer and app billing context on managed jobs. Restore it in batch and background cost polling with the original request time, preserving admission windows and existing claim behavior.

Recognize the India Bedrock model prefix in dashboard model setup.

* fix(ci): make migration repeatable and await scoped callbacks

Set the required migration lock timeout and add the billing-context column only if it is absent.

Use per-request completion test callbacks and await the MCP panel failure notification. Keep response, pricing, and complete callback-sequence assertions.

* fix(ui): align Bedrock profile parsing with main

Use the upstream country-prefix handling to clear the model-setup merge conflict.

* refactor(proxy): resolve a customer under its registration rules in one helper

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: ishaan-j-berri <ishaan.j@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration Bot added a commit that referenced this pull request Nov 18, 2026
…52492)

* feat(proxy): add per-team chargeback cost margins

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* fix(proxy): secure team pricing and surcharge budget reservations

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* chore(ui): regenerate team pricing endpoint descriptions

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* fix(proxy): preserve team pricing when archiving deleted teams

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* feat(proxy): replace the per-team margin with a surcharge on customer requests

A cost_margin_config entry keyed customer adds a percentage to requests made for a customer organization. The surcharge is part of spend, so customer budgets count it, and each request records it in cost_breakdown and in a customer_margin_spend column on the daily spend tables so cost before the surcharge stays exact

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* chore: regenerate the lazy openapi snapshot

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: keep the accumulation suppression on its line

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: read the recorded surcharge through a typed model

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): import the surcharge breakdown on the customer usage page

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): type the surcharge field where daily metrics are built

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): show a small surcharge to four decimals

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): reload margins after a refused save and drop the fixed amount for customer requests

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style(ui): format the surcharge breakdown

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: carry the surcharge column in daily activity fixtures

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* feat(proxy): let each app decide whether it may create unknown customers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: sort imports

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): lock the app customer switch while its save is pending

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge requests charged to a customer through the key's binding

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: forward the surcharge through the grouped daily activity fixture

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge billed failure rows charged to a customer

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: keep the callback tests' existing formatting

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): refuse an unknown organization alias sent with a known member

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(proxy): let an app set its own surcharge on customer requests

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): refuse an unknown customer before reporting its organization's budget

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge a customer-bound key at settlement and record no fields for a zero surcharge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: a zero surcharge is covered by its own case

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(ui): move the no-app customer switch into its own component

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): read a key's customer binding from the trusted metadata bucket of any route

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(proxy): apply an app's surcharge to keys bound to a customer

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* fix(customer-portal): enforce app caps and charge each window once

Enforce an authenticated app budget when optional customer and app headers are omitted. Normalize overlapping scalar and explicit budget windows to a single charge with the stricter cap and explicit reset time.

Cover all app primitives through native HTTP auth and use realistic empty gateway configuration in existing test doubles.

* test(proxy): let the customer usage fake answer app lookups for customer-bound keys

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): type the payload metadata read for customer attribution

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge billed failures on customer-bound keys and record the surcharge without a snapshot

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge billed failures whose customer binding sits beside litellm_params

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): drive a billed Responses failure on a customer-bound key through the failure callback

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): drive a billed Responses failure through the failure callback at each app surcharge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(customer-portal): reuse budget controls and admission

Use shared customer budget controls for app forms and resolve member budgets at one owner. Remove unused app lifecycle and listing routes.

Parse request identity once, check each global and app scope once, and keep app counters alive through the existing database flush window.

* fix(customer-portal): preserve app attribution for deferred costs

Persist the original trusted customer and app billing context on managed jobs. Restore it in batch and background cost polling with the original request time, preserving admission windows and existing claim behavior.

Recognize the India Bedrock model prefix in dashboard model setup.

* fix(ci): make migration repeatable and await scoped callbacks

Set the required migration lock timeout and add the billing-context column only if it is absent.

Use per-request completion test callbacks and await the MCP panel failure notification. Keep response, pricing, and complete callback-sequence assertions.

* fix(ui): align Bedrock profile parsing with main

Use the upstream country-prefix handling to clear the model-setup merge conflict.

* refactor(proxy): resolve a customer under its registration rules in one helper

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
Co-authored-by: ishaan-j-berri <ishaan.j@berri.ai>
devin-ai-integration Bot added a commit that referenced this pull request Nov 18, 2026
…2496)

* feat(proxy): add per-team chargeback cost margins

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* fix(proxy): secure team pricing and surcharge budget reservations

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* chore(ui): regenerate team pricing endpoint descriptions

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* fix(proxy): preserve team pricing when archiving deleted teams

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>

* feat(proxy): replace the per-team margin with a surcharge on customer requests

A cost_margin_config entry keyed customer adds a percentage to requests made for a customer organization. The surcharge is part of spend, so customer budgets count it, and each request records it in cost_breakdown and in a customer_margin_spend column on the daily spend tables so cost before the surcharge stays exact

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* chore: regenerate the lazy openapi snapshot

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: keep the accumulation suppression on its line

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: read the recorded surcharge through a typed model

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): import the surcharge breakdown on the customer usage page

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): type the surcharge field where daily metrics are built

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): show a small surcharge to four decimals

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): reload margins after a refused save and drop the fixed amount for customer requests

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style(ui): format the surcharge breakdown

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: carry the surcharge column in daily activity fixtures

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* feat(proxy): let each app decide whether it may create unknown customers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: sort imports

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): lock the app customer switch while its save is pending

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge requests charged to a customer through the key's binding

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: forward the surcharge through the grouped daily activity fixture

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge billed failure rows charged to a customer

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style: keep the callback tests' existing formatting

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): refuse an unknown organization alias sent with a known member

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(proxy): let an app set its own surcharge on customer requests

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(ui): list every application in the customer portal sidebar page

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): refuse an unknown customer before reporting its organization's budget

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge a customer-bound key at settlement and record no fields for a zero surcharge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: a zero surcharge is covered by its own case

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: open the application from the list in the surcharge range test

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(ui): move the no-app customer switch into its own component

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): read a key's customer binding from the trusted metadata bucket of any route

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(proxy): apply an app's surcharge to keys bound to a customer

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* feat(customer-portal): set budgets per customer and gateway app

Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups.

Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.

* fix(customer-portal): show app usage and resolve CI regressions

Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections.

Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.

* fix(customer-portal): enforce app caps and charge each window once

Enforce an authenticated app budget when optional customer and app headers are omitted. Normalize overlapping scalar and explicit budget windows to a single charge with the stricter cap and explicit reset time.

Cover all app primitives through native HTTP auth and use realistic empty gateway configuration in existing test doubles.

* test(proxy): let the customer usage fake answer app lookups for customer-bound keys

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): show window budgets, paginate applications and keep deep links on the application

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): type the payload metadata read for customer attribution

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): keep linked applications from loading forever and ignore invalid page sizes

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): keep the applications page number in the URL one-based

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge billed failures on customer-bound keys and record the surcharge without a snapshot

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): surcharge billed failures whose customer binding sits beside litellm_params

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): drive a billed Responses failure on a customer-bound key through the failure callback

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): drive a billed Responses failure through the failure callback at each app surcharge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(customer-portal): reuse budget controls and admission

Use shared customer budget controls for app forms and resolve member budgets at one owner. Remove unused app lifecycle and listing routes.

Parse request identity once, check each global and app scope once, and keep app counters alive through the existing database flush window.

* fix(customer-portal): preserve app attribution for deferred costs

Persist the original trusted customer and app billing context on managed jobs. Restore it in batch and background cost polling with the original request time, preserving admission windows and existing claim behavior.

Recognize the India Bedrock model prefix in dashboard model setup.

* fix(ci): make migration repeatable and await scoped callbacks

Set the required migration lock timeout and add the billing-context column only if it is absent.

Use per-request completion test callbacks and await the MCP panel failure notification. Keep response, pricing, and complete callback-sequence assertions.

* fix(ui): align Bedrock profile parsing with main

Use the upstream country-prefix handling to clear the model-setup merge conflict.

* refactor(proxy): resolve a customer under its registration rules in one helper

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
Co-authored-by: ishaan-j-berri <ishaan.j@berri.ai>
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