Repository navigation
feat: litellm-master-key #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: yxtay/docker-stacks
Length of output: 847
🌐 Web query:
LiteLLM master_key setting documentation💡 Result:
The master_key in LiteLLM is the proxy's administrative credential [1][2][3]. It is used to authenticate admin API calls, serve as the password for the Admin UI, and manage virtual keys [4][2][5][3]. Configuration You can set the master key using either an environment variable or the configuration file [4][2]: 1. Environment Variable: Set the LITELLM_MASTER_KEY variable (must start with sk-) [4][5][3]. 2. Config File: Specify it under general_settings: master_key in your config.yaml [4][6]. If both are set, the value in the config file takes precedence [2]. Important Considerations - Security: The master key bypasses standard model-level checks and gives access to every model on the proxy [1]. It should be treated as a highly sensitive operator credential [1]. - Encryption: In some deployments, if a separate LITELLM_SALT_KEY is not configured, the master key is also used to encrypt sensitive data (such as API keys and credentials) at rest in the database [2]. If the master key is used for this purpose, rotating it requires a specific re-encryption process to prevent losing access to stored credentials [2]. - Best Practices: It is recommended to keep the key in a secure secret manager and follow the official master key rotation documentation when updating it [2][3].
Citations:
🏁 Script executed:
Repository: yxtay/docker-stacks
Length of output: 6002
🌐 Web query:
LiteLLM v1.94.0 environment variables LITELLM_MASTER_KEY configured💡 Result:
In LiteLLM, the
LITELLM_MASTER_KEYenvironment variable serves as the primary administrative key for the LiteLLM Proxy [1][2][3]. It grants full admin access, allowing you to perform operations such as creating, blocking, or unblocking virtual keys [1][3][4]. Key details regarding theLITELLM_MASTER_KEY: Configuration and Precedence - Environment Variable: You can set the master key directly via the environment variableLITELLM_MASTER_KEY(e.g.,export LITELLM_MASTER_KEY="sk-...") [2][3]. - Configuration File: You can also specify the master key in yourconfig.yamlfile under thegeneral_settingssection usingmaster_key: <key>ormaster_key: os.environ/LITELLM_MASTER_KEY[1][3]. - Precedence: If both are configured, the value defined ingeneral_settings.master_keyin theconfig.yamlfile generally takes precedence over the environment variable [5]. Operational Usage - Authentication: The master key is used to authenticate requests to administrative endpoints, such as the key management APIs (/key/generate,/key/block,/key/unblock) [1][4]. It is passed in the Authorization header as a Bearer token:Authorization: Bearer LITELLM_MASTER_KEY[1]. - Admin UI: The master key acts as the password for the Admin UI when accessing the proxy [6]. - Security Best Practices: It is highly recommended to use a strong, unique key starting withsk-[1][3]. Always avoid hardcoding the key in configuration files; use environment variables or secret management systems (e.g., AWS Secret Manager) instead [3][7]. - Versioning Note: LiteLLM v1.94.0 includes updates to proxy behavior, including fixes related to master key routing and startup initialization, ensuring that the master key configuration is preserved correctly during the proxy's lifecycle [8][9].Citations:
Do not commit the default LiteLLM master key.
agent/compose.yamlloads.envinto the LiteLLM service, andLITELLM_MASTER_KEYis the admin/proxy credential. Copying this example unchanged can deploy the shared placeholdersk-litellm-master-key; leave it empty or a non-credential placeholder and require generated per-deployment values.🤖 Prompt for AI Agents