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
🔄 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:** [@U8F69](https://github.com/U8F69)
**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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/11150
Author: @U8F69
Created: 3/4/2025
Status: ❌ Closed
Base:
dev← Head:feat_usage📝 Commits (10+)
522c522feat(credit): add user credit model and credit calculator0013da8refactor(models): revert code lint770ae8frefactor(models): revert code lintd5ea32brefactor(middlewares): revert code linta2babbdrefactor(middlewares): revert code lint9db440crefactor(main): revert code lint15618f2refactor(migration): merge migrationsecf4cearefactor(migration): merge migrationsc967625refactor(credit): credit deduct should apply before filter63efe87refactor(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
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.