docs(ui.md): add docs on self serve ui flow

This commit is contained in:
Krrish Dholakia 2024-01-01 18:25:41 +05:30
parent 9cb5a2bec0
commit 95f850fecc
5 changed files with 63 additions and 6 deletions

View file

@ -1,3 +1,5 @@
import Image from '@theme/IdealImage';
# [BETA] Self-serve UI # [BETA] Self-serve UI
Allow your users to create their own keys through a UI Allow your users to create their own keys through a UI
@ -8,4 +10,54 @@ This is in beta, so things may change. If you have feedback, [let us know](https
::: :::
## Quick Start
Requirements:
- Need to a [Resend](https://resend.com/) account for sending emails
[**See code**](https://github.com/BerriAI/litellm/blob/61cd800b9ffbb02c286481d2056b65c7fb5447bf/litellm/proxy/proxy_server.py#L1782)
### Step 1. Save Resend keys
```env
export RESEND_API_KEY="my-resend-api-key"
export RESEND_API_EMAIL="my-resend-sending-email" # e.g. krrish@berri.ai
```
### Step 2. Enable user auth
In your config.yaml,
```yaml
general_settings:
# other changes
allow_user_auth: true
```
This will enable:
* Users to create keys via `/key/generate` (by default, only admin can create keys)
* The `/user/auth` endpoint to send user's emails with their login credentials (key + user id)
### Step 3. Connect to UI
You can use our hosted UI (https://dashboard.litellm.ai/) or [self-host your own](https://github.com/BerriAI/litellm/tree/main/ui).
If you self-host, you need to save the UI url in your proxy environment as `LITELLM_HOSTED_UI`.
Connect your proxy to your UI, by entering:
1. The hosted proxy URL
2. Accepted email subdomains
3. [OPTIONAL] Allowed admin emails
<Image img={require('../../img/admin_dashboard.png')} />
## What users will see?
### Auth
<Image img={require('../../img/user_auth_screen.png')} />
### Create Keys
<Image img={require('../../img/user_create_key_screen.png')} />

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View file

@ -76,12 +76,17 @@ def auth_page(page_param: str):
else: else:
post_endpoint = f"{decoded_params['proxy_url']}/user/auth" post_endpoint = f"{decoded_params['proxy_url']}/user/auth"
try: if (
assert email.split("@")[1] in decoded_params["accepted_email_subdomain"] decoded_params["accepted_email_subdomain"] == "*"
except: ): # if user wants to allow all emails
raise Exception( pass
f"Only emails from {decoded_params['accepted_email_subdomain']} are allowed" else:
) try:
assert email.split("@")[1] in decoded_params["accepted_email_subdomain"]
except:
raise Exception(
f"Only emails from {decoded_params['accepted_email_subdomain']} are allowed"
)
response = requests.post( response = requests.post(
post_endpoint, json={"user_email": email, "page": page_param} post_endpoint, json={"user_email": email, "page": page_param}
) )