Skip to content

Conversation

@agrattan0820
Copy link

@agrattan0820 agrattan0820 commented Nov 18, 2025

Enhance custom guardrail functionality with dynamic HTTP headers

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
image

Type

🆕 New Feature
✅ Test

Changes

  • Added support for passing custom HTTP headers to the guardrail API via the get_guardrail_custom_headers method.
  • Updated GraySwan guardrail to utilize custom headers in API requests.
  • Improved documentation for custom guardrail usage, including examples for dynamic header configuration.
  • Refactored payload preparation to prioritize custom headers over dynamic body parameters and configuration values.
  • Added comprehensive tests for custom header extraction and payload preparation logic.

- Added support for passing custom HTTP headers to the guardrail API via the `get_guardrail_custom_headers` method.
- Updated GraySwan guardrail to utilize custom headers in API requests.
- Improved documentation for custom guardrail usage, including examples for dynamic header configuration.
- Refactored payload preparation to prioritize custom headers over dynamic body parameters and configuration values.
- Added comprehensive tests for custom header extraction and payload preparation logic.
@vercel
Copy link

vercel bot commented Nov 18, 2025

@agrattan0820 is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

…guardrail payload handling

- Enhanced the S3 cache test to verify that all expected keys are present during concurrent operations.
- Updated the GraySwan guardrail tests to ensure custom headers are ignored for configuration parameters, prioritizing dynamic body values instead.
- Removed outdated tests related to custom header merging that are no longer applicable.
@krrishdholakia
Copy link
Contributor

@agrattan0820 looks like your testing is failing

Screenshot 2025-11-18 at 7 55 01 PM

…paration

- Refactored test functions for better readability and consistency by applying uniform formatting.
- Updated the GraySwan guardrail's payload preparation to include an optional `custom_headers` parameter.
- Improved assertions in tests to ensure accurate verification of expected behavior regarding custom headers and dynamic body values.
@agrattan0820
Copy link
Author

@agrattan0820 looks like your testing is failing

Screenshot 2025-11-18 at 7 55 01 PM

Yep yep, pushing up the working commit!

- Removed unnecessary line breaks and streamlined conditional expressions for better clarity.
- Consolidated multiple lines into single lines where appropriate to enhance code conciseness.
- Ensured consistent formatting across various sections of the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants