Description: Briefly describe the changes in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Description
Support creation of API keys for authentication purposes, allowing users to utilize them with our API of LiteLLM OpenAI Proxy Service
Example Usage
fromopenaiimportOpenAIfromrichimportprintBASE_URL="http://localhost:18080/litellm/api/v1"TOKEN="sk-89ca1254569345f5b00d3d9b80b2d174"MODEL="bedrock-claude-3-haiku"oai=OpenAI(api_key=TOKEN,base_url=BASE_URL,)resp=oai.chat.completions.create(stream=True,messages=[{"role":"user","content":"What is the meaning of life?"}],model=MODEL,)formessageinresp:content=message.choices[0].delta.contentifnotcontent:continueprint(content,end="")print()
Changelog Entry
Added
create API Key in frontend
auth by api key
Fixed
[List any fixes or corrections]
Changed
[List any changes or updates]
Removed
[List any removed features or files]
🔄 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/1306
**Author:** [@vaayne](https://github.com/vaayne)
**Created:** 3/26/2024
**Status:** ✅ Merged
**Merged:** 4/2/2024
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `feature/support_auth_by_api_key`
---
### 📝 Commits (10+)
- [`81e9280`](https://github.com/open-webui/open-webui/commit/81e928030f1524444f3c32b23916a76ed58a59d7) backend support api key
- [`b4b56f9`](https://github.com/open-webui/open-webui/commit/b4b56f9c85af2b5e8b756ed2b8b9ef40166a3c5d) frontend support api key
- [`a0935de`](https://github.com/open-webui/open-webui/commit/a0935dec60eb635e7f8b3bf796aab9047cd6ee88) Merge branch 'dev' into feature/support_auth_by_api_key
- [`56369fe`](https://github.com/open-webui/open-webui/commit/56369fea3a0cfe54a2a01d3c4bdbb2568510a159) Merge branch 'dev' into feature/support_auth_by_api_key
- [`b11af9e`](https://github.com/open-webui/open-webui/commit/b11af9ea0e85d8c7a03c6b0b6512b9f5cf14cd57) fix
- [`38c34b4`](https://github.com/open-webui/open-webui/commit/38c34b444428b43a7c6dc0a02339a5adcc942c0a) fix: import
- [`ba0523c`](https://github.com/open-webui/open-webui/commit/ba0523cd69649936c7e09cb8a8771703dc992343) refac: api_key field moved to user
- [`da8646c`](https://github.com/open-webui/open-webui/commit/da8646cae90cba48d714364a25784aa6890f4875) refac
- [`e49e04c`](https://github.com/open-webui/open-webui/commit/e49e04c56aa0d854c4df142e89289258dfbe7f2e) chore: formatting
- [`7c5f6d7`](https://github.com/open-webui/open-webui/commit/7c5f6d71b3607e0529fd1359ac0346bdf5784a72) refac
### 📊 Changes
**9 files changed** (+469 additions, -71 deletions)
<details>
<summary>View changed files</summary>
➕ `backend/apps/web/internal/migrations/003_add_auth_api_key.py` (+48 -0)
📝 `backend/apps/web/models/auths.py` (+16 -0)
📝 `backend/apps/web/models/users.py` (+25 -0)
📝 `backend/apps/web/routers/auths.py` (+43 -7)
📝 `backend/constants.py` (+2 -1)
📝 `backend/utils/utils.py` (+22 -0)
📝 `src/lib/apis/auths/index.ts` (+75 -0)
📝 `src/lib/components/chat/Settings/Account.svelte` (+223 -63)
➕ `src/lib/components/icons/Plus.svelte` (+15 -0)
</details>
### 📄 Description
## Pull Request Checklist
- [x] **Description:** Briefly describe the changes in this pull request.
- [ ] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [ ] **Documentation:** Have you updated relevant documentation?
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
---
## Description
Support creation of API keys for authentication purposes, allowing users to utilize them with our API of [LiteLLM OpenAI Proxy Service](https://litellm.vercel.app/docs/proxy/quick_start)
<img width="713" alt="image" src="https://github.com/open-webui/open-webui/assets/10231735/cd647e4a-fe5e-4ffb-9620-5a384b7711fd">
### Example Usage
```python
from openai import OpenAI
from rich import print
BASE_URL = "http://localhost:18080/litellm/api/v1"
TOKEN = "sk-89ca1254569345f5b00d3d9b80b2d174"
MODEL = "bedrock-claude-3-haiku"
oai = OpenAI(
api_key=TOKEN,
base_url=BASE_URL,
)
resp = oai.chat.completions.create(
stream=True,
messages=[{"role": "user", "content": "What is the meaning of life?"}],
model=MODEL,
)
for message in resp:
content = message.choices[0].delta.content
if not content:
continue
print(content, end="")
print()
```
---
### Changelog Entry
### Added
- create API Key in frontend
- auth by api key
### Fixed
- [List any fixes or corrections]
### Changed
- [List any changes or updates]
### Removed
- [List any removed features or files]
---
<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/1306
Author: @vaayne
Created: 3/26/2024
Status: ✅ Merged
Merged: 4/2/2024
Merged by: @tjbck
Base:
dev← Head:feature/support_auth_by_api_key📝 Commits (10+)
81e9280backend support api keyb4b56f9frontend support api keya0935deMerge branch 'dev' into feature/support_auth_by_api_key56369feMerge branch 'dev' into feature/support_auth_by_api_keyb11af9efix38c34b4fix: importba0523crefac: api_key field moved to userda8646creface49e04cchore: formatting7c5f6d7refac📊 Changes
9 files changed (+469 additions, -71 deletions)
View changed files
➕
backend/apps/web/internal/migrations/003_add_auth_api_key.py(+48 -0)📝
backend/apps/web/models/auths.py(+16 -0)📝
backend/apps/web/models/users.py(+25 -0)📝
backend/apps/web/routers/auths.py(+43 -7)📝
backend/constants.py(+2 -1)📝
backend/utils/utils.py(+22 -0)📝
src/lib/apis/auths/index.ts(+75 -0)📝
src/lib/components/chat/Settings/Account.svelte(+223 -63)➕
src/lib/components/icons/Plus.svelte(+15 -0)📄 Description
Pull Request Checklist
Description
Support creation of API keys for authentication purposes, allowing users to utilize them with our API of LiteLLM OpenAI Proxy Service
Example Usage
Changelog Entry
Added
Fixed
Changed
Removed
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.