The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Litellm dev 07 05 2025 p4 (#12350)
Krish Dholakiadbe37b542dbb
diff --git a/docs/my-website/docs/proxy/service_accounts.md b/docs/my-website/docs/proxy/service_accounts.mdindex 5825af4cb8d..49fe0173b07 100644--- a/docs/my-website/docs/proxy/service_accounts.md+++ b/docs/my-website/docs/proxy/service_accounts.md@@ -6,8 +6,27 @@ import Image from '@theme/IdealImage';Use this if you want to create Virtual Keys that are not owned by a specific user but instead created for production projects+Why use a service account key?+ - Prevent key from being deleted when user is deleted.+ - Apply team limits, not team member limits to key.+## Usage+Use the `/key/service-account/generate` endpoint to generate a service account key.+++```bash+curl -L -X POST 'http://localhost:4000/key/service-account/generate' \+-H 'Authorization: Bearer sk-1234' \+-H 'Content-Type: application/json' \+-d '{+ "team_id": "my-unique-team"+}'+```++## Example - require `user` param for all service account requests++### 1. Set settings for Service AccountsSet `service_account_settings` if you want to create settings that only apply to service account keysdiff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex 1e1401bf72f..aa2f3b7a3a8 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -196,6 +196,7 @@ class KeyManagementRoutes(str, enum.Enum):KEY_UPDATE = "/key/update"KEY_DELETE = "/key/delete"KEY_REGENERATE = "/key/regenerate"+ KEY_GENERATE_SERVICE_ACCOUNT = "/key/service-account/generate"KEY_REGENERATE_WITH_PATH_PARAM = "/key/{key_id}/regenerate"KEY_BLOCK = "/key/block"KEY_UNBLOCK = "/key/unblock"@@ -380,6 +381,7 @@ class LiteLLMRoutes(enum.Enum):KeyManagementRoutes.KEY_DELETE,KeyManagementRoutes.KEY_INFO,KeyManagementRoutes.KEY_REGENERATE,+ KeyManagementRoutes.KEY_GENERATE_SERVICE_ACCOUNT,KeyManagementRoutes.KEY_REGENERATE_WITH_PATH_PARAM,KeyManagementRoutes.KEY_LIST,KeyManagementRoutes.KEY_BLOCK,@@ -1057,11 +1059,11 @@ class DeleteCustomerRequest(LiteLLMPydanticObjectBase):class MemberBase(LiteLLMPydanticObjectBase):user_id: Optional[str] = Field(default=None,- description="The unique ID of the user to add. Either user_id or user_email must be provided"+ description="The unique ID of the user to add. Either user_id or user_email must be provided",)user_email: Optional[str] = Field(default=None,- description="The email address of the user to add. Either user_id or user_email must be provided"+ description="The email address of the user to add. Either user_id or user_email must be provided",)@model_validator(mode="before")@@ -2555,7 +2557,7 @@ class MemberUpdateResponse(LiteLLMPydanticObjectBase):class TeamMemberAddRequest(MemberAddRequest):"""Request body for adding members to a team.-+Example:```json{@@ -2568,10 +2570,11 @@ class TeamMemberAddRequest(MemberAddRequest):}```"""+team_id: str = Field(description="The ID of the team to add the member to")max_budget_in_team: Optional[float] = Field(default=None,- description="Maximum budget allocated to this user within the team. If not set, user has unlimited budget within team limits"+ description="Maximum budget allocated to this user within the team. If not set, user has unlimited budget within team limits",)diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.pyindex 9215060dfed..13f0d1753d0 100644--- a/litellm/proxy/management_endpoints/key_management_endpoints.py+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py@@ -330,6 +330,196 @@ def common_key_access_checks(router = APIRouter()+async def _common_key_generation_helper( # noqa: PLR0915+ data: GenerateKeyRequest,+ user_api_key_dict: UserAPIKeyAuth,+ litellm_changed_by: Optional[str],+ team_table: Optional[LiteLLM_TeamTableCachedObj],+) -> GenerateKeyResponse:+ from litellm.proxy.proxy_server import (+ litellm_proxy_admin_name,+ llm_router,+ premium_user,+ prisma_client,+ )++ common_key_access_checks(+ user_api_key_dict=user_api_key_dict,+ data=data,+ llm_router=llm_router,+ premium_user=premium_user,+ )++ # check if user set default key/generate params on config.yaml+ if litellm.default_key_generate_params is not None:+ for elem in data:+ key, value = elem+ if value is None and key in [+ "max_budget",+ "user_id",+ "team_id",+ "max_parallel_requests",+ "tpm_limit",+ "rpm_limit",+ "budget_duration",+ ]:+ setattr(data, key, litellm.default_key_generate_params.get(key, None))+ elif key == "models" and value == []:+ setattr(data, key, litellm.default_key_generate_params.get(key, []))+ elif key == "metadata" and value == {}:+ setattr(data, key, litellm.default_key_generate_params.get(key, {}))++ # check if user set default key/generate params on config.yaml+ if litellm.upperbound_key_generate_params is not None:+ for elem in data:+ key, value = elem+ upperbound_value = getattr(+ litellm.upperbound_key_generate_params, key, None+ )+ if upperbound_value is not None:+ if value is None:+ # Use the upperbound value if user didn't provide a value+ setattr(data, key, upperbound_value)+ else:+ # Compare with upperbound for numeric fields+ if key in [+ "max_budget",+ "max_parallel_requests",+ "tpm_limit",+ "rpm_limit",+ ]:+ if value > upperbound_value:+ raise HTTPException(+ status_code=400,+ detail={+ "error": f"{key} is over max limit set in config - user_value={value}; max_value={upperbound_value}"+ },+ )+ # Compare durations+ elif key in ["budget_duration", "duration"]:+ upperbound_duration = duration_in_seconds(+ duration=upperbound_value+ )+ user_duration = duration_in_seconds(duration=value)+ if user_duration > upperbound_duration:+ raise HTTPException(+ status_code=400,+ detail={+ "error": f"{key} is over max limit set in config - user_value={value}; max_value={upperbound_value}"+ },+ )++ # APPLY ENTERPRISE KEY MANAGEMENT PARAMS+ try:+ from litellm_enterprise.proxy.management_endpoints.key_management_endpoints import (+ apply_enterprise_key_management_params,+ )++ data = apply_enterprise_key_management_params(data, team_table)+ except Exception as e:+ verbose_proxy_logger.info(+ "litellm.proxy.proxy_server.generate_key_fn(): Enterprise key management params not applied - {}".format(+ str(e)+ )+ )++ # TODO: @ishaan-jaff: Migrate all budget tracking to use LiteLLM_BudgetTable+ _budget_id = data.budget_id+ if prisma_client is not None and data.soft_budget is not None:+ # create the Budget Row for the LiteLLM Verification Token+ budget_row = LiteLLM_BudgetTable(+ soft_budget=data.soft_budget,+ model_max_budget=data.model_max_budget or {},+ )+ new_budget = prisma_client.jsonify_object(budget_row.json(exclude_none=True))++ _budget = await prisma_client.db.litellm_budgettable.create(+ data={+ **new_budget, # type: ignore+ "created_by": user_api_key_dict.user_id or litellm_proxy_admin_name,+ "updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,+ }+ )+ _budget_id = getattr(_budget, "budget_id", None)++ # ADD METADATA FIELDS+ # Set Management Endpoint Metadata Fields+ for field in LiteLLM_ManagementEndpoint_MetadataFields_Premium:+ if getattr(data, field, None) is not None:+ _set_object_metadata_field(+ object_data=data,+ field_name=field,+ value=getattr(data, field),+ )++ data_json = data.model_dump(exclude_unset=True, exclude_none=True) # type: ignore++ # if we get max_budget passed to /key/generate, then use it as key_max_budget. Since generate_key_helper_fn is used to make new users+ if "max_budget" in data_json:+ data_json["key_max_budget"] = data_json.pop("max_budget", None)+ if _budget_id is not None:+ data_json["budget_id"] = _budget_id++ if "budget_duration" in data_json:+ data_json["key_budget_duration"] = data_json.pop("budget_duration", None)++ if user_api_key_dict.user_id is not None:+ data_json["created_by"] = user_api_key_dict.user_id+ data_json["updated_by"] = user_api_key_dict.user_id++ # Set tags on the new key+ if "tags" in data_json:+ from litellm.proxy.proxy_server import premium_user++ if premium_user is not True and data_json["tags"] is not None:+ raise ValueError(+ f"Only premium users can add tags to keys. {CommonProxyErrors.not_premium_user.value}"+ )++ _metadata = data_json.get("metadata")+ if not _metadata:+ data_json["metadata"] = {"tags": data_json["tags"]}+ else:+ data_json["metadata"]["tags"] = data_json["tags"]++ data_json.pop("tags")++ data_json = await _set_object_permission(+ data_json=data_json,+ prisma_client=prisma_client,+ )++ await _enforce_unique_key_alias(+ key_alias=data_json.get("key_alias", None),+ prisma_client=prisma_client,+ )++ response = await generate_key_helper_fn(+ request_type="key", **data_json, table_name="key"+ )++ response["soft_budget"] = (+ data.soft_budget+ ) # include the user-input soft budget in the response++ response = GenerateKeyResponse(**response)++ response.token = (+ response.token_id+ ) # remap token to use the hash, and leave the key in the `key` field [TODO]: clean up generate_key_helper_fn to do this++ asyncio.create_task(+ KeyManagementEventHooks.async_key_generated_hook(+ data=data,+ response=response,+ user_api_key_dict=user_api_key_dict,+ litellm_changed_by=litellm_changed_by,+ )+ )++ return response++@router.post("/key/generate",tags=["key management"],@@ -337,7 +527,7 @@ router = APIRouter()response_model=GenerateKeyResponse,)@management_endpoint_wrapper-async def generate_key_fn( # noqa: PLR0915+async def generate_key_fn(data: GenerateKeyRequest,user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),litellm_changed_by: Optional[str] = Header(@@ -400,9 +590,6 @@ async def generate_key_fn( # noqa: PLR0915"""try:from litellm.proxy.proxy_server import (- litellm_proxy_admin_name,- llm_router,- premium_user,prisma_client,user_api_key_cache,user_custom_key_generate,@@ -444,192 +631,141 @@ async def generate_key_fn( # noqa: PLR0915route=KeyManagementRoutes.KEY_GENERATE,)- common_key_access_checks(- user_api_key_dict=user_api_key_dict,+ return await _common_key_generation_helper(data=data,- llm_router=llm_router,- premium_user=premium_user,+ user_api_key_dict=user_api_key_dict,+ litellm_changed_by=litellm_changed_by,+ team_table=team_table,)-- # check if user set default key/generate params on config.yaml- if litellm.default_key_generate_params is not None:- for elem in data:- key, value = elem- if value is None and key in [- "max_budget",- "user_id",- "team_id",- "max_parallel_requests",- "tpm_limit",- "rpm_limit",- "budget_duration",- ]:- setattr(- data, key, litellm.default_key_generate_params.get(key, None)- )- elif key == "models" and value == []:- setattr(data, key, litellm.default_key_generate_params.get(key, []))- elif key == "metadata" and value == {}:- setattr(data, key, litellm.default_key_generate_params.get(key, {}))-- # check if user set default key/generate params on config.yaml- if litellm.upperbound_key_generate_params is not None:- for elem in data:- key, value = elem- upperbound_value = getattr(- litellm.upperbound_key_generate_params, key, None- )- if upperbound_value is not None:- if value is None:- # Use the upperbound value if user didn't provide a value- setattr(data, key, upperbound_value)- else:- # Compare with upperbound for numeric fields- if key in [- "max_budget",- "max_parallel_requests",- "tpm_limit",- "rpm_limit",- ]:- if value > upperbound_value:- raise HTTPException(- status_code=400,- detail={- "error": f"{key} is over max limit set in config - user_value={value}; max_value={upperbound_value}"- },- )- # Compare durations- elif key in ["budget_duration", "duration"]:- upperbound_duration = duration_in_seconds(- duration=upperbound_value- )- user_duration = duration_in_seconds(duration=value)- if user_duration > upperbound_duration:- raise HTTPException(- status_code=400,- detail={- "error": f"{key} is over max limit set in config - user_value={value}; max_value={upperbound_value}"- },- )-- # APPLY ENTERPRISE KEY MANAGEMENT PARAMS- try:- from litellm_enterprise.proxy.management_endpoints.key_management_endpoints import (- apply_enterprise_key_management_params,- )-- data = apply_enterprise_key_management_params(data, team_table)- except Exception as e:- verbose_proxy_logger.info(- "litellm.proxy.proxy_server.generate_key_fn(): Enterprise key management params not applied - {}".format(- str(e)- )- )-- # TODO: @ishaan-jaff: Migrate all budget tracking to use LiteLLM_BudgetTable- _budget_id = data.budget_id- if prisma_client is not None and data.soft_budget is not None:- # create the Budget Row for the LiteLLM Verification Token- budget_row = LiteLLM_BudgetTable(- soft_budget=data.soft_budget,- model_max_budget=data.model_max_budget or {},- )- new_budget = prisma_client.jsonify_object(- budget_row.json(exclude_none=True)- )-- _budget = await prisma_client.db.litellm_budgettable.create(- data={- **new_budget, # type: ignore- "created_by": user_api_key_dict.user_id or litellm_proxy_admin_name,- "updated_by": user_api_key_dict.user_id or litellm_proxy_admin_name,- }+ except Exception as e:+ verbose_proxy_logger.exception(+ "litellm.proxy.proxy_server.generate_key_fn(): Exception occured - {}".format(+ str(e))- _budget_id = getattr(_budget, "budget_id", None)-- # ADD METADATA FIELDS- # Set Management Endpoint Metadata Fields- for field in LiteLLM_ManagementEndpoint_MetadataFields_Premium:- if getattr(data, field, None) is not None:- _set_object_metadata_field(- object_data=data,- field_name=field,- value=getattr(data, field),- )-- data_json = data.model_dump(exclude_unset=True, exclude_none=True) # type: ignore-- # if we get max_budget passed to /key/generate, then use it as key_max_budget. Since generate_key_helper_fn is used to make new users- if "max_budget" in data_json:- data_json["key_max_budget"] = data_json.pop("max_budget", None)- if _budget_id is not None:- data_json["budget_id"] = _budget_id+ )+ raise handle_exception_on_proxy(e)- if "budget_duration" in data_json:- data_json["key_budget_duration"] = data_json.pop("budget_duration", None)- if user_api_key_dict.user_id is not None:- data_json["created_by"] = user_api_key_dict.user_id- data_json["updated_by"] = user_api_key_dict.user_id+ "/key/service-account/generate",+ tags=["key management"],+ dependencies=[Depends(user_api_key_auth)],+)+@management_endpoint_wrapper+async def generate_service_account_key_fn(+ data: GenerateKeyRequest,+ user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),+ litellm_changed_by: Optional[str] = Header(+ None,+ description="The litellm-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability",+ ),+):+ """+ Generate a Service Account API key based on the provided data. This key does not belong to any user. It belongs to the team.- # Set tags on the new key- if "tags" in data_json:- from litellm.proxy.proxy_server import premium_user+ Why use a service account key?+ - Prevent key from being deleted when user is deleted.+ - Apply team limits, not team member limits to key.- if premium_user is not True and data_json["tags"] is not None:- raise ValueError(- f"Only premium users can add tags to keys. {CommonProxyErrors.not_premium_user.value}"- )+ Docs: https://docs.litellm.ai/docs/proxy/virtual_keys- _metadata = data_json.get("metadata")- if not _metadata:- data_json["metadata"] = {"tags": data_json["tags"]}- else:- data_json["metadata"]["tags"] = data_json["tags"]+ Parameters:+ - duration: Optional[str] - Specify the length of time the token is valid for. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d").+ - key_alias: Optional[str] - User defined key alias+ - key: Optional[str] - User defined key value. If not set, a 16-digit unique sk-key is created for you.+ - team_id: Optional[str] - The team id of the key+ - user_id: Optional[str] - [NON-FUNCTIONAL] THIS WILL BE IGNORED. The user id of the key+ - budget_id: Optional[str] - The budget id associated with the key. Created by calling `/budget/new`.+ - models: Optional[list] - Model_name's a user is allowed to call. (if empty, key is allowed to call all models)+ - aliases: Optional[dict] - Any alias mappings, on top of anything in the config.yaml model list. - https://docs.litellm.ai/docs/proxy/virtual_keys#managing-auth---upgradedowngrade-models+ - config: Optional[dict] - any key-specific configs, overrides config in config.yaml+ - spend: Optional[int] - Amount spent by key. Default is 0. Will be updated by proxy whenever key is used. https://docs.litellm.ai/docs/proxy/virtual_keys#managing-auth---tracking-spend+ - send_invite_email: Optional[bool] - Whether to send an invite email to the user_id, with the generate key+ - max_budget: Optional[float] - Specify max budget for a given key.+ - budget_duration: Optional[str] - Budget is reset at the end of specified duration. If not set, budget is never reset. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d").+ - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel requests. Raises 429 error, if user's parallel requests > x.+ - metadata: Optional[dict] - Metadata for key, store information for key. Example metadata = {"team": "core-infra", "app": "app2", "email": "[email protected]" }+ - guardrails: Optional[List[str]] - List of active guardrails for the key+ - permissions: Optional[dict] - key-specific permissions. Currently just used for turning off pii masking (if connected). Example - {"pii": false}+ - model_max_budget: Optional[Dict[str, BudgetConfig]] - Model-specific budgets {"gpt-4": {"budget_limit": 0.0005, "time_period": "30d"}}}. IF null or {} then no model specific budget.+ - model_rpm_limit: Optional[dict] - key-specific model rpm limit. Example - {"text-davinci-002": 1000, "gpt-3.5-turbo": 1000}. IF null or {} then no model specific rpm limit.+ - model_tpm_limit: Optional[dict] - key-specific model tpm limit. Example - {"text-davinci-002": 1000, "gpt-3.5-turbo": 1000}. IF null or {} then no model specific tpm limit.+ - allowed_cache_controls: Optional[list] - List of allowed cache control values. Example - ["no-cache", "no-store"]. See all values - https://docs.litellm.ai/docs/proxy/caching#turn-on--off-caching-per-request+ - blocked: Optional[bool] - Whether the key is blocked.+ - rpm_limit: Optional[int] - Specify rpm limit for a given key (Requests per minute)+ - tpm_limit: Optional[int] - Specify tpm limit for a given key (Tokens per minute)+ - soft_budget: Optional[float] - Specify soft budget for a given key. Will trigger a slack alert when this soft budget is reached.+ - tags: Optional[List[str]] - Tags for [tracking spend](https://litellm.vercel.app/docs/proxy/enterprise#tracking-spend-for-custom-tags) and/or doing [tag-based routing](https://litellm.vercel.app/docs/proxy/tag_routing).+ - enforced_params: Optional[List[str]] - List of enforced params for the key (Enterprise only). [Docs](https://docs.litellm.ai/docs/proxy/enterprise#enforce-required-params-for-llm-requests)+ - allowed_routes: Optional[list] - List of allowed routes for the key. Store the actual route or store a wildcard pattern for a set of routes. Example - ["/chat/completions", "/embeddings", "/keys/*"]+ - object_permission: Optional[LiteLLM_ObjectPermissionBase] - key-specific object permission. Example - {"vector_stores": ["vector_store_1", "vector_store_2"]}. IF null or {} then no object permission.+ Examples:- data_json.pop("tags")+ 1. Allow users to turn on/off pii masking- data_json = await _set_object_permission(- data_json=data_json,- prisma_client=prisma_client,- )+ ```bash+ curl --location 'http://0.0.0.0:4000/key/generate' \+ --header 'Authorization: Bearer sk-1234' \+ --header 'Content-Type: application/json' \+ --data '{+ "permissions": {"allow_pii_controls": true}+ }'+ ```- await _enforce_unique_key_alias(- key_alias=data_json.get("key_alias", None),- prisma_client=prisma_client,- )+ Returns:+ - key: (str) The generated api key+ - expires: (datetime) Datetime object for when key expires.+ - user_id: (str) Unique user id - used for tracking spend across multiple keys for same user id.- response = await generate_key_helper_fn(- request_type="key", **data_json, table_name="key"- )+ """+ from litellm.proxy.proxy_server import (+ prisma_client,+ user_api_key_cache,+ user_custom_key_generate,+ )- response["soft_budget"] = (- data.soft_budget- ) # include the user-input soft budget in the response+ verbose_proxy_logger.debug("entered /key/generate")- response = GenerateKeyResponse(**response)+ if user_custom_key_generate is not None:+ if asyncio.iscoroutinefunction(user_custom_key_generate):+ result = await user_custom_key_generate(data) # type: ignore+ else:+ raise ValueError("user_custom_key_generate must be a coroutine")+ decision = result.get("decision", True)+ message = result.get("message", "Authentication Failed - Custom Auth Rule")+ if not decision:+ raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=message)+ team_table: Optional[LiteLLM_TeamTableCachedObj] = None+ if data.team_id is not None:+ try:+ team_table = await get_team_object(+ team_id=data.team_id,+ prisma_client=prisma_client,+ user_api_key_cache=user_api_key_cache,+ parent_otel_span=user_api_key_dict.parent_otel_span,+ check_db_only=True,+ )+ except Exception as e:+ verbose_proxy_logger.debug(+ f"Error getting team object in `/key/generate`: {e}"+ )+ team_table = None- response.token = (- response.token_id- ) # remap token to use the hash, and leave the key in the `key` field [TODO]: clean up generate_key_helper_fn to do this+ key_generation_check(+ team_table=team_table,+ user_api_key_dict=user_api_key_dict,+ data=data,+ route=KeyManagementRoutes.KEY_GENERATE_SERVICE_ACCOUNT,+ )- asyncio.create_task(- KeyManagementEventHooks.async_key_generated_hook(- data=data,- response=response,- user_api_key_dict=user_api_key_dict,- litellm_changed_by=litellm_changed_by,- )- )+ data.user_id = None # do not allow user_id to be set for service account keys- return response- except Exception as e:- verbose_proxy_logger.exception(- "litellm.proxy.proxy_server.generate_key_fn(): Exception occured - {}".format(- str(e)- )- )- raise handle_exception_on_proxy(e)+ return await _common_key_generation_helper(+ data=data,+ user_api_key_dict=user_api_key_dict,+ litellm_changed_by=litellm_changed_by,+ team_table=team_table,+ )def prepare_metadata_fields(diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsxindex 9165de6515c..06bba670977 100644--- a/ui/litellm-dashboard/src/components/create_key_button.tsx+++ b/ui/litellm-dashboard/src/components/create_key_button.tsx@@ -32,6 +32,7 @@ import {proxyBaseUrl,getPossibleUserRoles,userFilterUICall,+ keyCreateServiceAccountCall,} from "./networking";import VectorStoreSelector from "./vector_store_management/VectorStoreSelector";import PremiumVectorStoreSelector from "./common_components/PremiumVectorStoreSelector";@@ -308,8 +309,12 @@ const CreateKey: React.FC<CreateKeyProps> = ({// Remove the original field as it's now part of object_permissiondelete formValues.allowed_mcp_server_ids;}-- const response = await keyCreateCall(accessToken, userID, formValues);+ let response;+ if (keyOwner === "service_account") {+ response = await keyCreateServiceAccountCall(accessToken, formValues);+ } else {+ response = await keyCreateCall(accessToken, userID, formValues);+ }console.log("key create Response:", response);diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsxindex e42a4331562..1db7865057e 100644--- a/ui/litellm-dashboard/src/components/networking.tsx+++ b/ui/litellm-dashboard/src/components/networking.tsx@@ -522,10 +522,70 @@ export const alertingSettingsCall = async (accessToken: String) => {}};+export const keyCreateServiceAccountCall = async (+ accessToken: string,+ formValues: Record<string, any>, // Assuming formValues is an object+) => {+ try {+ console.log("Form Values in keyCreateServiceAccountCall:", formValues); // Log the form values before making the API call++ // check if formValues.description is not undefined, make it a string and add it to formValues.metadata+ if (formValues.description) {+ // add to formValues.metadata+ if (!formValues.metadata) {+ formValues.metadata = {};+ }+ // value needs to be in "", valid JSON+ formValues.metadata.description = formValues.description;+ // remove descrption from formValues+ delete formValues.description;+ formValues.metadata = JSON.stringify(formValues.metadata);+ }+ // if formValues.metadata is not undefined, make it a valid dict+ if (formValues.metadata) {+ console.log("formValues.metadata:", formValues.metadata);+ // if there's an exception JSON.parse, show it in the message+ try {+ formValues.metadata = JSON.parse(formValues.metadata);+ } catch (error) {+ throw new Error("Failed to parse metadata: " + error);+ }+ }++ console.log("Form Values after check:", formValues);+ const url = proxyBaseUrl ? `${proxyBaseUrl}/key/service-account/generate` : `/key/service-account/generate`;+ const response = await fetch(url, {+ method: "POST",+ headers: {+ [globalLitellmHeaderName]: `Bearer ${accessToken}`,+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ ...formValues, // Include formValues in the request body+ }),+ });++ if (!response.ok) {+ const errorData = await response.text();+ handleError(errorData);+ console.error("Error response from the server:", errorData);+ throw new Error(errorData);+ }++ const data = await response.json();+ console.log("API Response:", data);+ return data;+ // Handle success - you might want to update some state or UI based on the created key+ } catch (error) {+ console.error("Failed to create key:", error);+ throw error;+ }+};+export const keyCreateCall = async (accessToken: string,userID: string,- formValues: Record<string, any> // Assuming formValues is an object+ formValues: Record<string, any>, // Assuming formValues is an object) => {try {console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API calldiff --git a/ui/litellm-dashboard/src/components/team/permission_definitions.tsx b/ui/litellm-dashboard/src/components/team/permission_definitions.tsxindex 625f61997e8..7f7f85793b4 100644--- a/ui/litellm-dashboard/src/components/team/permission_definitions.tsx+++ b/ui/litellm-dashboard/src/components/team/permission_definitions.tsx@@ -10,6 +10,7 @@ export interface PermissionInfo {*/export const PERMISSION_DESCRIPTIONS: Record<string, string> = {'/key/generate': 'Member can generate a virtual key for this team',+ '/key/service-account/generate': 'Member can generate a service account key (not belonging to any user) for this team','/key/update': 'Member can update a virtual key belonging to this team','/key/delete': 'Member can delete a virtual key belonging to this team','/key/info': 'Member can get info about a virtual key belonging to this team',