fix(nvidia-safety): correct NeMo Guardrails API endpoint #4202
+9
−45
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.


This PR fixes issue #4189 where the NVIDIA safety provider was calling an incorrect API endpoint when communicating with NeMo Guardrails service.
Problem
The NVIDIA safety provider implementation was calling
/v1/guardrail/checks, which does not exist in the NeMo Guardrails API. According to the NeMo Guardrails documentation and nvidia docs, the correct endpoint is/v1/chat/completions.This caused:
Solution
1. Fixed Endpoint (nvidia.py:144)
Before:
After:
2. Simplified Request Format (nvidia.py:140-143)
Before:
After:
The simplified format matches the NeMo Guardrails API specification and removes unnecessary inference parameters that were meant for LLM completion, not safety checks.
Testing
Test Results
Manual Verification
The reproduction script demonstrates the fix:
Validation Against NeMo Guardrails API
This fix aligns with the official NeMo Guardrails API specification:
Endpoint:
POST /v1/chat/completionsRequest Format:
{ "config_id": "demo-config", "messages": [ { "role": "user", "content": "Hello!" } ] }Response Format:
{ "role": "assistant", "content": "Response text", "status": "allowed|blocked", "rails_status": { "reason": "...", "triggered_rails": [...] } }Breaking Changes
None. This is a bug fix that makes the implementation work as originally intended.
References
src/llama_stack/providers/remote/safety/nvidia/nvidia.py