ValGuard + Portkey: custom provider for guarded models

Register ValGuard as a custom OpenAI-compatible host in Portkey. Disable cache on paths that must hit validators every time.

Last verified:

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

  1. In Portkey Model Catalog, add a custom provider pointing at https://api.valguard.ai/v1.
  2. Attach Authorization: Bearer <VG_API_KEY> and X-VG-Agent as custom headers on that model.
  3. Confirm how Portkey retries treat ValGuard block responses (often HTTP 403).
  4. 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

Next step

Quickstart.