Portkey adds caching, routing, and observability in front of models. Register ValGuard as a custom OpenAI-compatible host so policy runs on the completion Portkey forwards — not only Portkey's built-in guardrail plugins.
When you need this
A cached response bypasses validators entirely. Disable Portkey cache for models that must hit ValGuard every time, or accept that cache hits skip rule evaluation.
Setup
- In Portkey Model Catalog, add a custom provider pointing at
https://api.valguard.ai/v1. - Attach
Authorization: Bearer <VG_API_KEY>andX-VG-Agentas custom headers on that model. - Confirm how Portkey retries treat ValGuard block responses (often HTTP 403).
- Shadow mode before customer-facing enforce.
Code
from portkey_ai import Portkey
client = Portkey(api_key="pk_live_...")
resp = client.chat.completions.create(
model="@valguard/gpt-4o-mini",
messages=[{"role": "user", "content": "Hi"}],
)
Verify custom-host steps in your Portkey account — UI names change between releases.
Honest limits
- Portkey documents its own guardrails. They are not ValGuard rule packs unless you duplicate policy in both places.
- Cache, retry, and virtual-key layers sit in front of ValGuard. Read failure modes in Trust.
- ValGuard does not manage Portkey API keys.
Related
- LiteLLM
- vs Guardrails AI (gateway guardrails section)
- Trust · Pricing