Skip to main content
Portkey and LangWatch both sit between your app and the upstream LLM providers, and both speak the OpenAI-compatible dialect. The feature surface overlaps heavily but the data-model and governance primitives differ in ways that shape your migration. This cookbook is the concrete end-to-end playbook for teams already on Portkey.
Terminology crosswalk. Portkey and LangWatch use overlapping names for different concepts (e.g. “virtual key” means different things). The table below is the single source of truth, refer back to it whenever a section feels ambiguous.

Concept mapping at a glance

Code migration: the minimum change

If your current Portkey setup looks like:
Your LangWatch equivalent:
Two things moved:
  1. No Portkey SDK. LangWatch speaks the OpenAI protocol natively, use any official OpenAI client (Node, Python, Go, Java). Same story for Anthropic: new Anthropic({ baseURL: "https://gateway.langwatch.ai" }) with your VK as the apiKey.
  2. virtualKey header → apiKey bearer. Portkey carries the VK in a custom header; LangWatch just uses the standard bearer so you don’t need provider-specific plumbing.

Config migration: Portkey Config JSON → LangWatch VK + ModelProviders

A typical Portkey config:
Maps to: Step 1, configure ModelProviders in LangWatch Settings Go to Settings → Model Providers and add entries for OpenAI + Anthropic with your provider-issued API keys. These are the LangWatch equivalent of Portkey’s “Virtual Keys to actual providers” layer, and they’re reusable across gateway AND prompt playground AND evaluators. Step 2, fill the ModelProvider Advanced (Gateway) tab Open each ModelProvider you created in Step 1 and switch to the Advanced (Gateway) tab: Step 3, create a Virtual Key with the routing policy From AI Gateway → Routing Policies → New routing policy create a policy whose modelProviderIds[] is [<openai-id>, <anthropic-id>]. Then from AI Gateway → Virtual Keys → New virtual key:
  • Name: whatever you called the Portkey config (e.g. prod-chat)
  • Routing policy: the one you just created (or leave unset to use the org default, which orders by fallbackPriorityGlobal then createdAt)
  • Cache policy: respect (default, honours Anthropic cache_control passthrough)
  • Optional: attach an existing LangWatch evaluator with executionMode=AS_GUARDRAIL as a pre or post hook if you had Portkey guardrails.
The X-LangWatch-Cache: force, X-LangWatch-Cache: disable header overrides the VK default per-request. Use force on idempotent eval harnesses to dedupe cost; use disable to bust caches during debugging (equivalent to Portkey’s x-portkey-cache-force-refresh: true). Step 4, attach a budget From AI Gateway → Budgets → New budget:
  • Scope: project (or organization for fleet-wide) + target the new project
  • Window: month
  • Limit: your Portkey spend cap
  • on_breach: block (hard-cap, returns 402) or warn (soft-cap, adds X-LangWatch-Budget-Warning header)
LangWatch budgets stack hierarchically, your org budget PLUS the project budget PLUS any per-VK budget all apply to the same request. This is a deliberate step-up from Portkey’s key-scoped budgets and is one of the key enterprise-grade features.

Rollout pattern: gradual migration without a big-bang

We recommend the following sequence over 2-4 weeks:
  1. Week 1, shadow traffic. Mint a LangWatch VK with config.shadow_mode: true (v1.1; for v1 just log both upstream responses). Route 1-5% of production traffic through LangWatch alongside Portkey. Compare latency, error rate, and response equality.
  2. Week 2, canary by tenant. Route low-risk tenants (internal users, dev environments) fully through LangWatch. Portkey still carries the majority.
  3. Week 3, flip customer traffic. Route 50% of customer traffic through LangWatch, with a feature flag that can instantly revert.
  4. Week 4, decommission Portkey. Once metrics show parity, null out the Portkey integration. Keep the Portkey org active for 30 days in case of rollback; delete after.
Run /gateway/usage spend + /settings/audit-log (filter Target = virtual_key, budget, etc.) mutation history in parallel to your existing Portkey analytics during the rollout, the LangWatch audit log will show you every VK, budget, provider mutation alongside platform actions, which is especially useful in the cutover period when your ops team is still adjusting governance.

Feature-parity gaps (be explicit)

Some Portkey features don’t have LangWatch v1 equivalents. If any of these are load-bearing for you, weigh them carefully:
  • Loadbalance strategy (sibling-key rotation for rate-limit absorption), LangWatch v1 routes to one credential per provider slot. Sibling-key loadbalancing is on the v1.1 roadmap. Workaround: if you genuinely need it, keep Portkey for those routes, run LangWatch in parallel for governance.
  • Semantic cache: LangWatch v1 ships respect, force, disable modes for explicit Anthropic cache_control + a rule engine; semantic similarity lookups are v1.1.
  • Prompt management embedded in the gateway: LangWatch has a dedicated Prompt Management product surface that’s more powerful than Portkey’s embedded library, but it’s a separate area rather than a subfolder of the gateway.
  • Guardrails catalog: Portkey ships a pre-built library of guardrails; LangWatch reuses the evaluator catalog you already have (and any custom evaluator you’ve built). For most enterprise teams this is a net win (you own the logic); for quick-start it’s a cold start.

What to watch during + after migration

  • Per-tenant spend: compare your Portkey invoice amount to sum(GatewayBudgetLedger.amountUsd) on the same time window. First-week variance ≤ 3% is normal (different rounding, model-version timings); > 5% warrants investigation.
  • p99 latency: LangWatch’s gateway hot path is ~700 ns of gateway-local overhead; upstream provider latency dominates. Compare p99 with + without the gateway (shadow mode is the cleanest A/B). Any regression > 10 ms is worth a ticket.
  • 401 rate: during the VK rollout window, any client still hitting Portkey’s endpoint will 404 post-decommission. Set an alert on gateway_http_requests_total{status="401"} rate spikes to catch stragglers before customer escalations.
  • Audit log volume: your team will mutate more governance-configuration post-migration (budgets, guardrails, rotation policies). Expect 10-50× more audit rows than Portkey’s minimal audit surface, plan retention accordingly.

See also