From 4508b4ede01965d2ab0e5c89c93009cda569c570 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 7 Mar 2024 08:14:46 -0800 Subject: [PATCH] docs(team_based_routing.md): add docs on team based routing --- .../docs/proxy/team_based_routing.md | 71 +++++++++++++++++++ docs/my-website/sidebars.js | 1 + 2 files changed, 72 insertions(+) create mode 100644 docs/my-website/docs/proxy/team_based_routing.md diff --git a/docs/my-website/docs/proxy/team_based_routing.md b/docs/my-website/docs/proxy/team_based_routing.md new file mode 100644 index 00000000000..4b057cdf382 --- /dev/null +++ b/docs/my-website/docs/proxy/team_based_routing.md @@ -0,0 +1,71 @@ +# 👥 Team-based Routing + +Route calls to different model groups based on the team-id + +## Config with model group + +Create a config.yaml with 2 model groups + connected postgres db + +```yaml +model_list: + - model_name: gpt-3.5-turbo-eu # 👈 Model Group 1 + litellm_params: + model: azure/chatgpt-v-2 + api_base: os.environ/AZURE_API_BASE_EU + api_key: os.environ/AZURE_API_KEY_EU + api_version: "2023-07-01-preview" + - model_name: gpt-3.5-turbo-worldwide # 👈 Model Group 2 + litellm_params: + model: azure/chatgpt-v-2 + api_base: os.environ/AZURE_API_BASE + api_key: os.environ/AZURE_API_KEY + api_version: "2023-07-01-preview" + +general_settings: + master_key: sk-1234 + database_url: "postgresql://..." # 👈 Connect proxy to DB +``` + +Start proxy + +```bash +litellm --config /path/to/config.yaml +``` + +## Create Team with Model Alias + +```bash +curl --location 'http://0.0.0.0:4000/team/new' \ +--header 'Authorization: Bearer sk-1234' \ # 👈 Master Key +--header 'Content-Type: application/json' \ +--data '{ + "team_alias": "my-new-team_4", + "model_aliases": {"gpt-3.5-turbo": "gpt-3.5-turbo-eu"} +}' + +# Returns team_id: my-team-id +``` + +## Create Team Key + +```bash +curl --location 'http://localhost:4000/key/generate' \ +--header 'Authorization: Bearer sk-1234' \ +--header 'Content-Type: application/json' \ +--data '{ + "team_id": "my-team-id", # 👈 YOUR TEAM ID +}' +``` + +## Call Model with alias + +```bash +curl --location 'http://0.0.0.0:4000/v1/chat/completions' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer sk-A1L0C3Px2LJl53sF_kTF9A' \ +--data '{ + "model": "gpt-3.5-turbo", # 👈 MODEL + "messages": [{"role": "system", "content": "You'\''re an expert at writing poems"}, {"role": "user", "content": "Write me a poem"}, {"role": "user", "content": "What'\''s your name?"}], + "user": "usha" +}' +``` \ No newline at end of file diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index d50e31c791b..7aaf2e114cf 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -39,6 +39,7 @@ const sidebars = { "proxy/user_keys", "proxy/virtual_keys", "proxy/users", + "proxy/team_based_routing", "proxy/ui", "proxy/budget_alerts", "proxy/model_management",