mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
feat(v2 managed agents): add litellm_api_key masking helper
This commit is contained in:
parent
41c484ed97
commit
6a618c51d3
1 changed files with 19 additions and 0 deletions
19
litellm/managed_agents/masking.py
Normal file
19
litellm/managed_agents/masking.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
"""Masking helpers for managed agents.
|
||||
|
||||
The agent's `litellm_api_key` is stored encrypted-at-rest by the proxy and
|
||||
returned masked on every read — `sk-abc123def456` → `sk-a****`.
|
||||
"""
|
||||
|
||||
|
||||
def mask_litellm_api_key(key: str) -> str:
|
||||
"""Return a masked form of a LiteLLM API key.
|
||||
|
||||
Pattern: keep the first 4 characters of the key (including any
|
||||
`sk-`-style prefix), then append `****`. For very short keys, mask
|
||||
everything to avoid leaking too much.
|
||||
"""
|
||||
if not key:
|
||||
return ""
|
||||
if len(key) <= 4:
|
||||
return "****"
|
||||
return f"{key[:4]}****"
|
||||
Loading…
Add table
Reference in a new issue