Skip to main content

Key Interception

Clevername automatically detects API keys in agent prompts, strips them before they reach the AI provider, and offers to store them securely in the BYOK key store. Available on every tier (Free, Pro, Team, Enterprise) and on by default — no setup required.

Key Concepts

What is key interception?

When you or an agent includes an API key in a prompt routed through Clevername's governance gateway, the key is detected before the request reaches the AI provider. The key is stripped from the prompt, and you are offered the option to store it in your BYOK key store (GCP Secret Manager in production, AES-256-GCM in local dev). This prevents accidental key leakage to third-party AI providers.

Available on every tier

Key interception, multi-key labels, agent-key bindings, and the 6-hour key health check are included on Free, Pro, Team, and Enterprise. Paid tiers do not unlock additional interception modes — they raise governed-agent and gateway-token caps and add features like the SOC console (Team+) and SIEM export (Enterprise).

Why does this matter?

  • API keys sent in prompts can end up in provider logs and training data
  • Keys shared in conversation context may be visible to other tools and agents
  • Manual copy-paste is error-prone — interception catches mistakes automatically
  • Stored keys are encrypted with AES-256-GCM and protected by CMEK

No setup needed

Key interception runs in detect_and_offer mode by default. When a key is detected it is stripped and held for up to one hour so the caller can confirm storage. The only per-agent setting is question D7 of the Agent Review questionnaire, which writes the mode into the agent's compiled guardrail profile; there is no separate org-level switch.

How Key Interception Works
1

A request containing an API key reaches the gateway

An agent (or a script using a gateway token) sends a request through Clevername's governed path — the MCP gateway or the chat-completions API — whose prompt includes something like sk-proj-abc123.... This could be intentional or accidental.

2

Clevername detects the key pattern

Before the request leaves Clevername, the scanner identifies the key by its prefix (see the provider list below). The key is stripped from the prompt so the AI provider never sees it.

3

The key is held, and the caller decides

In detect_and_offer mode (the default) the stripped key is placed on hold for 1 hour (up to 5 pending holds per user) and the response tells the caller a key was intercepted. The caller then:

  • calls keys__confirm_held with the hold id to store it in the BYOK key store, or
  • calls keys__cancel_held to discard it, or
  • does nothing — the hold expires and the key is never stored.

keys__list_held lists your pending holds. In auto_store mode the confirmation step is skipped.

4

Key is stored and available

Once stored, the key appears in your API Keys settings and is available for routing AI calls. Future requests to that provider use the stored key automatically — no need to paste it again.

Interception Modes

Key interception supports four modes. The mode is per agent: question D7 of the Agent Review questionnaire writes it into the agent's guardrail profile. Requests without a compiled profile use detect_and_offer.

detect_and_offerDetect & Offer (default)

Keys are detected and stripped. You are prompted to store them. Best for most teams — catches mistakes without forcing storage.

auto_storeAuto Store

Keys are detected, stripped, and stored automatically without prompting. Best for teams that always want keys captured.

strip_onlyStrip Only

Keys are detected and stripped from the prompt but not stored. The key is discarded. Best for compliance-heavy environments.

offOff

No interception. Keys in prompts are sent through to the AI provider as-is. Not recommended for production use.

Tip
To change an agent's mode, answer question D7 differently and resubmit the agent for review. The mode lives in the compiled guardrail profile, so it changes only when the profile is recompiled.

How to Configure It

The interception mode comes from one place:

Agent Review questionnaire (D7)

Question D7 in the security questionnaire asks: “How should Clevername handle API keys detected in prompts?” The answer sets key_interception_mode in the agent's compiled guardrail profile, and the gateway reads it from there on every request.

Default without a profile

Requests from agents that have not been through Agent Review, and requests carrying no agent identity, use detect_and_offer. There is no organization-wide mode setting and no admin lock.

Key Rotation

When you paste a new key for a provider where you already have a stored key, Clevername detects that it is a replacement. The flow depends on your interception mode:

  • 1.The new key is intercepted and identified as belonging to the same provider as an existing key.
  • 2.In detect_and_offer mode, the hold response asks whether to replace the existing key or store the new one alongside it (multi-key): confirm with keys__confirm_held and replace=true to rotate, or replace=false to add a labelled key.
  • 3.If you choose to replace, the old key version is permanently destroyed in Secret Manager and the new key takes its place. There is no undo.
Important
Key rotation is irreversible. Once the old key version is destroyed in Secret Manager, it cannot be recovered. Make sure you no longer need the old key before confirming.

Multi-Key Support

You can store multiple keys for the same provider — for example, separate OpenAI keys for different projects or cost centers. Each key gets a label so you can tell them apart.

ProviderLabelHintUsed By
OpenAIProductionsk-p…8x2fAgent A, Agent B
OpenAIDevelopmentsk-d…3k9mAgent C
AnthropicDefaultsk-a…7j1nAll agents

When an agent needs a key, Clevername selects the one bound to that agent. If no specific binding exists, the default key for that provider is used. See Agent Key Binding for details.

Supported Providers

Detection is prefix-based. Keys for providers Clevername can route to are stripped and offered for storage; everything else is stripped and reported but never stored.

Stripped and offered for storage

OpenAI (sk-proj-, sk-)
Anthropic (sk-ant-, sk-)
Google Gemini (AIza, AQ.)

A bare sk- prefix is ambiguous between OpenAI and Anthropic and is resolved by live validation before storage.

Stripped and reported only

GitHub
GitLab
AWS (AKIA)
DigitalOcean
Vercel
Cloudflare
Slack
SendGrid
npm
PyPI
Replicate
Hugging Face
Groq
Perplexity
OpenRouter
Fireworks
Together
Databricks
Shopify
Square
Stripe (webhook / restricted)
New Relic
Sentry
PostHog
Notion