[PR #11150] [CLOSED] feat(credit): add user credit model and credit calculator #45716

Closed
opened 2026-04-29 20:12:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/11150
Author: @OrenZhang
Created: 3/4/2025
Status: Closed

Base: devHead: feat_usage


📝 Commits (10+)

  • 522c522 feat(credit): add user credit model and credit calculator
  • 0013da8 refactor(models): revert code lint
  • 770ae8f refactor(models): revert code lint
  • d5ea32b refactor(middlewares): revert code lint
  • a2babbd refactor(middlewares): revert code lint
  • 9db440c refactor(main): revert code lint
  • 15618f2 refactor(migration): merge migrations
  • ecf4cea refactor(migration): merge migrations
  • c967625 refactor(credit): credit deduct should apply before filter
  • 63efe87 refactor(credit): change description

📊 Changes

67 files changed (+1075 additions, -65 deletions)

View changed files

📝 backend/open_webui/config.py (+26 -1)
📝 backend/open_webui/main.py (+13 -1)
backend/open_webui/migrations/versions/a959f8a63245_add_credits.py (+58 -0)
backend/open_webui/models/credits.py (+166 -0)
📝 backend/open_webui/models/models.py (+15 -4)
📝 backend/open_webui/models/users.py (+7 -1)
📝 backend/open_webui/routers/openai.py (+26 -2)
📝 backend/open_webui/routers/tasks.py (+24 -0)
📝 backend/open_webui/routers/users.py (+80 -3)
📝 backend/open_webui/utils/auth.py (+86 -37)
backend/open_webui/utils/usage.py (+216 -0)
📝 src/lib/apis/users/index.ts (+3 -1)
📝 src/lib/components/admin/Users/UserList.svelte (+26 -0)
📝 src/lib/components/admin/Users/UserList/EditUserModal.svelte (+16 -1)
📝 src/lib/components/workspace/Models/ModelEditor.svelte (+39 -0)
📝 src/lib/i18n/locales/ar-BH/translation.json (+5 -0)
📝 src/lib/i18n/locales/ar/translation.json (+5 -0)
📝 src/lib/i18n/locales/bg-BG/translation.json (+5 -0)
📝 src/lib/i18n/locales/bn-BD/translation.json (+5 -0)
📝 src/lib/i18n/locales/bo-TB/translation.json (+5 -0)

...and 47 more files

📄 Description

close #6692

Added

  • Add a user points/credits model that automatically initializes credits when pulling models or making ChatCompletion requests, and starts billing after the response is generated.

Additional Information

I've tested this feature with both the API and WebUI, and it's functioning properly.

Please provide me with some suggestions on whether this implementation is feasible or acceptable, so I can adjust my development direction accordingly.

Screenshots

image

🔄 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/open-webui/open-webui/pull/11150 **Author:** [@OrenZhang](https://github.com/OrenZhang) **Created:** 3/4/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat_usage` --- ### 📝 Commits (10+) - [`522c522`](https://github.com/open-webui/open-webui/commit/522c522443a05c6298ae6d51b4a685d9329b5bd7) feat(credit): add user credit model and credit calculator - [`0013da8`](https://github.com/open-webui/open-webui/commit/0013da8d97e5fcda7b711fd0b5de9b7b6ce7a5f2) refactor(models): revert code lint - [`770ae8f`](https://github.com/open-webui/open-webui/commit/770ae8f90152b0f3fa078e19ddd91d53387fe1da) refactor(models): revert code lint - [`d5ea32b`](https://github.com/open-webui/open-webui/commit/d5ea32ba6ef48f7e2512881a7996d4d5d7b33e88) refactor(middlewares): revert code lint - [`a2babbd`](https://github.com/open-webui/open-webui/commit/a2babbded729ea7a629de4692e01add6c679f19d) refactor(middlewares): revert code lint - [`9db440c`](https://github.com/open-webui/open-webui/commit/9db440cf439ffb64d70ca0c45c8bf5735d597c18) refactor(main): revert code lint - [`15618f2`](https://github.com/open-webui/open-webui/commit/15618f250978d7e0a3dda49418589f17d24a4bb8) refactor(migration): merge migrations - [`ecf4cea`](https://github.com/open-webui/open-webui/commit/ecf4ceab21a66dee0e1489d3941bda0016ad895a) refactor(migration): merge migrations - [`c967625`](https://github.com/open-webui/open-webui/commit/c967625d8199131cc499fe8441589ce46dca2510) refactor(credit): credit deduct should apply before filter - [`63efe87`](https://github.com/open-webui/open-webui/commit/63efe87a3baaa9939e46e4222c0edbb2aa5c3c9f) refactor(credit): change description ### 📊 Changes **67 files changed** (+1075 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/config.py` (+26 -1) 📝 `backend/open_webui/main.py` (+13 -1) ➕ `backend/open_webui/migrations/versions/a959f8a63245_add_credits.py` (+58 -0) ➕ `backend/open_webui/models/credits.py` (+166 -0) 📝 `backend/open_webui/models/models.py` (+15 -4) 📝 `backend/open_webui/models/users.py` (+7 -1) 📝 `backend/open_webui/routers/openai.py` (+26 -2) 📝 `backend/open_webui/routers/tasks.py` (+24 -0) 📝 `backend/open_webui/routers/users.py` (+80 -3) 📝 `backend/open_webui/utils/auth.py` (+86 -37) ➕ `backend/open_webui/utils/usage.py` (+216 -0) 📝 `src/lib/apis/users/index.ts` (+3 -1) 📝 `src/lib/components/admin/Users/UserList.svelte` (+26 -0) 📝 `src/lib/components/admin/Users/UserList/EditUserModal.svelte` (+16 -1) 📝 `src/lib/components/workspace/Models/ModelEditor.svelte` (+39 -0) 📝 `src/lib/i18n/locales/ar-BH/translation.json` (+5 -0) 📝 `src/lib/i18n/locales/ar/translation.json` (+5 -0) 📝 `src/lib/i18n/locales/bg-BG/translation.json` (+5 -0) 📝 `src/lib/i18n/locales/bn-BD/translation.json` (+5 -0) 📝 `src/lib/i18n/locales/bo-TB/translation.json` (+5 -0) _...and 47 more files_ </details> ### 📄 Description close #6692 ### Added - Add a user points/credits model that automatically initializes credits when pulling models or making ChatCompletion requests, and starts billing after the response is generated. --- ### Additional Information I've tested this feature with both the API and WebUI, and it's functioning properly. Please provide me with some suggestions on whether this implementation is feasible or acceptable, so I can adjust my development direction accordingly. ### Screenshots <img width="1073" alt="image" src="https://github.com/user-attachments/assets/7821ee70-e6bb-4ed9-8ff0-456b880d99d8" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 20:12:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#45716