Skip to content

Conversation

@uc4w6c
Copy link
Contributor

@uc4w6c uc4w6c commented Oct 12, 2025

Title

feat: apply guardrail to anthropic endpoint

Relevant issues

#13997

Related PR for calling Guardrails from Anthropic endpoints:
#14107

@krrishdholakia
I'm currently working on applying Guardrails to Anthropic endpoints, but it's taking longer than expected, so I'd like to get your advice.

In this PR, I'm implementing the following flow based on your previous feedback:
#14107 (comment)

anthropic request format
  -> convert -> chat completion request
  -> run guardrails
  -> convert -> anthropic request format
  -> API call
  -> anthropic response format
  -> convert -> chat completion response
  -> run guardrails
  -> convert -> anthropic response format

First, could you please confirm if this overall approach looks good?

Next, there’s currently a bug where the response becomes empty during streaming.
I’m having trouble figuring out why this happens, so any hints or advice would be greatly appreciated.

Once this implementation is completed, it will enable controlling Claude Code’s tool calls through LiteLLM by combining it with the tool permission guardrail.
I’m developing this feature because I want to make that possible in my organization — and I believe many other organizations want the same, which could also help increase LiteLLM adoption.

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

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

@vercel
Copy link

vercel bot commented Oct 12, 2025

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

A member of the Team first needs to authorize it.

@uc4w6c uc4w6c marked this pull request as draft October 12, 2025 00:04
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.

1 participant