diff --git a/docs/my-website/docs/proxy/virtual_keys.md b/docs/my-website/docs/proxy/virtual_keys.md index c8844a3c3..a21fb703f 100644 --- a/docs/my-website/docs/proxy/virtual_keys.md +++ b/docs/my-website/docs/proxy/virtual_keys.md @@ -3,6 +3,13 @@ Track Spend, Set budgets and create virtual keys for the proxy Grant other's temporary access to your proxy, with keys that expire after a set duration. + +:::info + +Complete API documentation in the Swagger docs on your proxy base url (e.g. `http://0.0.0.0:8000)` + +::: + ## Quick Start Requirements: @@ -59,6 +66,17 @@ Expected response: } ``` +## Keys that don't expire + +Just set duration to None. + +```bash +curl --location 'http://0.0.0.0:8000/key/generate' \ +--header 'Authorization: Bearer sk-1234' \ +--header 'Content-Type: application/json' \ +--data '{"models": ["azure-models"], "aliases": {"mistral-7b": "gpt-3.5-turbo"}, "duration": null}' +``` + ## Upgrade/Downgrade Models If a user is expected to use a given model (i.e. gpt3-5), and you want to: diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 56fff3df4..6c7af4ed3 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -149,7 +149,7 @@ class UserAPIKeyAuth(LiteLLMBase): # the expected response object for user api k class GenerateKeyResponse(LiteLLMBase): key: str - expires: datetime + expires: Optional[datetime] user_id: str class _DeleteKeyObject(LiteLLMBase): diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 980b518d0..94aa51921 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -189,6 +189,7 @@ class PrismaClient: else: # Token exists but is expired. raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="expired user key") + return response else: # Token does not exist. raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid user key")