From 0d41e2972bcd28bf7a2bd34ffadd219e24d6de07 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 16 Aug 2024 13:55:28 -0700 Subject: [PATCH] docs on oauth 2.0 --- docs/my-website/docs/proxy/oauth2.md | 57 ++++++++++++++++++++++++++++ docs/my-website/sidebars.js | 1 + 2 files changed, 58 insertions(+) create mode 100644 docs/my-website/docs/proxy/oauth2.md diff --git a/docs/my-website/docs/proxy/oauth2.md b/docs/my-website/docs/proxy/oauth2.md new file mode 100644 index 000000000..668004349 --- /dev/null +++ b/docs/my-website/docs/proxy/oauth2.md @@ -0,0 +1,57 @@ +# Oauth 2.0 Authentication + +Use this if you want to use an Oauth2.0 token to make `/chat`, `/embeddings` requests to the LiteLLM Proxy + +## Usage + +1. Set env vars: + +```bash +export OAUTH_TOKEN_INFO_ENDPOINT="https://your-provider.com/token/info" +export OAUTH_USER_ID_FIELD_NAME="sub" +export OAUTH_USER_ROLE_FIELD_NAME="role" +export OAUTH_USER_TEAM_ID_FIELD_NAME="team_id" +``` + +- `OAUTH_TOKEN_INFO_ENDPOINT`: URL to validate OAuth tokens +- `OAUTH_USER_ID_FIELD_NAME`: Field in token info response containing user ID +- `OAUTH_USER_ROLE_FIELD_NAME`: Field in token info for user's role +- `OAUTH_USER_TEAM_ID_FIELD_NAME`: Field in token info for user's team ID + +2. Enable on litellm config.yaml + +Set this on your config.yaml + +```yaml +model_list: + - model_name: gpt-4 + litellm_params: + model: openai/fake + api_key: fake-key + api_base: https://exampleopenaiendpoint-production.up.railway.app/ + +general_settings: + master_key: sk-1234 + enable_oauth2_auth: true +``` + +3. Use token in requests to LiteLLM + +```shell +curl --location 'http://0.0.0.0:4000/chat/completions' \ + --header 'Content-Type: application/json' \ + --data '{ + "model": "gpt-3.5-turbo", + "messages": [ + { + "role": "user", + "content": "what llm are you" + } + ] +}' +``` + +## Debugging + +Start the LiteLLM Proxy with [`--detailed_debug` mode and you should see more verbose logs](cli.md#detailed_debug) + diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index ac9586d76..bfa8953d4 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -66,6 +66,7 @@ const sidebars = { "proxy/customers", "proxy/billing", "proxy/token_auth", + "proxy/oauth2", "proxy/alerting", "proxy/ui", "proxy/prometheus",