mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
Sample code to prevent logging API key
Sample code in documentation to prevent logging API key. Ideally should be implemented in the codebase if not already
This commit is contained in:
parent
c5340b8709
commit
b8d7cafb8d
1 changed files with 13 additions and 1 deletions
|
|
@ -41,6 +41,18 @@ def send_slack_alert(
|
|||
# get it from https://api.slack.com/messaging/webhooks
|
||||
slack_webhook_url = os.environ['SLACK_WEBHOOK_URL'] # "https://hooks.slack.com/services/<>/<>/<>"
|
||||
|
||||
# Remove api_key from kwargs under litellm_params
|
||||
if kwargs.get('litellm_params'):
|
||||
kwargs['litellm_params'].pop('api_key', None)
|
||||
if kwargs['litellm_params'].get('metadata'):
|
||||
kwargs['litellm_params']['metadata'].pop('deployment', None)
|
||||
# Remove deployment under metadata
|
||||
if kwargs.get('metadata'):
|
||||
kwargs['metadata'].pop('deployment', None)
|
||||
# Prevent api_key from being logged
|
||||
if kwargs.get('api_key'):
|
||||
kwargs.pop('api_key', None)
|
||||
|
||||
# Define the text payload, send data available in litellm custom_callbacks
|
||||
text_payload = f"""LiteLLM Logging: kwargs: {str(kwargs)}\n\n, response: {str(completion_response)}\n\n, start time{str(start_time)} end time: {str(end_time)}
|
||||
"""
|
||||
|
|
@ -90,4 +102,4 @@ response = litellm.completion(
|
|||
- [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version)
|
||||
- [Community Discord 💭](https://discord.gg/wuPM9dRgDw)
|
||||
- Our numbers 📞 +1 (770) 8783-106 / +1 (412) 618-6238
|
||||
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
|
||||
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue