LLM Gateway

LLM Gateway & Cost Routing

Centralize company API keys, enforce per-user and department token/dollar budgets, prove cost savings in Shadow Mode, and apply 4-tier DLP and Threat Protection on every model request.

The /llm/<provider>/* Proxy

Instead of distributing raw vendor API keys to employee laptops, admins seal one pay-as-you-go API key per provider under Catalog & Models → Model providers using hardware-backed envelope encryption (write-only; never returned by any UI or API). AI tools and internal apps point their base URL at Control Proxy:

https://yourcompany.controlproxy.com/llm/<provider-slug>
Provider Type Default Slug & Client Base URL Notes
Anthropic (Claude) https://yourcompany.controlproxy.com/llm/anthropic Do not append /v1; Claude Code and Claude Desktop 3P append /v1/messages and /v1/models automatically.
OpenAI & OpenAI-Compatible https://yourcompany.controlproxy.com/llm/openai/v1 Include trailing /v1 for Codex CLI (wire_api = "responses"), Cursor, and OpenAI SDKs.
Google Gemini (OpenAI-style) https://yourcompany.controlproxy.com/llm/gemini/v1 Uses Gemini’s OpenAI-compatible endpoint under one sealed company API key.
DeepSeek & US-Hosted DeepSeek https://yourcompany.controlproxy.com/llm/deepseek-claude
(or OpenAI-style slug)
1-click preset for Claude Code and Claude Desktop 3P. Swap Base URL to US-hosted endpoints (such as Microsoft Azure AI Foundry, Together AI, or Fireworks AI) for strict US data residency. Control Proxy automatically synthesizes Claude model-picker aliases on GET /v1/models.

On every request, the LLM Gateway: (1) authenticates the caller via SSO JWT or mcpr_... key, (2) checks usage limits and per-key burst rate limits, (3) applies model routing rules if enabled, (4) runs DLP, Threat Protection, AI Judge, and Contextual PII & Policy Guardrails across prompts, standing instructions, tool definitions, tool results, and answers, and (5) swaps in the sealed vendor key, streams the response, and records usage in Activity → Model log.

Shadow Mode vs. Active Cost Routing

Most organizations send routine summarization, extraction, formatting, and simple Q&A prompts to expensive frontier models. Control Proxy lets you validate savings risk-free before moving a single request:

  • Shadow Mode (zero user impact): Evaluates live requests using your configured classifier and routing rules, logging the target model choice and exact projected dollar savings in Activity → Model log while still forwarding every request to the model originally requested.
  • Active Routing (cache-preserving conversation locks): When switched on, the gateway classifies the first real user prompt of a conversation (across categories such as code, writing, data, question, summary, translation, personal, other and difficulty simple / moderate / demanding). If a rule matches, the conversation is locked to the selected target model on turn 1 and kept there for all subsequent turns.
  • Why conversation locks matter: Switching models mid-conversation invalidates vendor prompt caches and breaks model-specific reasoning blocks—often costing more than a downgrade saves. Routing stays within the same provider protocol (e.g., Opus → Haiku, or GPT-5 → GPT-4o-mini) and never translates between incompatible wire formats.
  • Full transparency: Both Activity → Model log and SIEM model_request events record both model_asked_for and the actual model served, and users or tools can opt out via header when needed.

Per-User, Department & Org Caps + Burst Guardrails

Because API billing is pay-as-you-go, Control Proxy gives finance and IT hard spending guardrails under Activity → Usage limits and Security → Tool Guardrails:

  • Token & dollar caps (up to 40 rules): Configure caps in tokens (input + output + cached tokens) or US dollars across hour, day, week, or month windows.
  • User, department & org scopes: Apply caps per individual user (user scope, either for Everyone or targeted to a specific directory group/department) or as a shared company-wide ceiling (org scope).
  • Modes & flex buffers: Choose off, warn (logs and alerts once when crossed without blocking), or block (refuses requests until the window resets). Blocking rules support an optional soft-cap flex overage (0–100%) and self-service credit top-up requests for user/group caps.
  • Per-key LLM burst guardrail: Cap requests per minute per key (0–6,000 req/min; 0 = unlimited) under Security → Tool Guardrails. Exceeding the burst ceiling returns HTTP 429 with Retry-After to stop runaway agent loops before they burn budget.

Authentication: Personal Keys (mcpr_...) & SSO JWTs

Enterprise Fleet

Short-Lived OIDC / SSO JWTs

When corporate SSO is enabled for AI tools under Setup → Sign-in system, /llm/* accepts short-lived OIDC/SSO JWTs directly using the same user and group entitlements as the MCP Gateway. Unauthenticated calls return 401 with an RFC 9728 WWW-Authenticate discovery hint pointing to /.well-known/oauth-protected-resource/llm/<slug>. Pair with /usr/local/bin/cp-auth-token for zero-key MDM rollout.

Zero-MDM Quickstart

Personal Gateway Keys (mcpr_...)

Each user creates revocable personal gateway keys (prefixed mcpr_) on Your profile → Your gateway keys. Keys are shown once on creation, stored as cryptographic hashes, and accepted via either Authorization: Bearer <key> or x-api-key: <key>—making them compatible with Claude Code, Claude Desktop 3P, Codex CLI, Cursor, and VS Code BYOK with zero MDM.

Payload Capture & Privacy Defaults

By default, Control Proxy logs request metadata, model selection, token counts (input, output, cache_read, cache_write), estimated cost, and security rule labels/counts without exporting prompt or completion text to external SIEMs. Portal payload capture is configurable per model provider: when enabled, secret-looking values, payment cards, SSNs, and bank numbers are scrubbed before hardware-backed envelope encryption, and every payload inspection in Activity → Model log writes an entry to the tamper-evident Audit Log.