proxykey API KEY VAULT

API key injection: what it is and how it works

"Injection" is just substituting the real key into an outgoing request. The question isn't whether it happens — it always does, for anyone calling a third-party API. The question is where, and who does it.

2026-07-11 · proxykey

Injection isn't a technology, it's a moment

Every request to OpenAI, Stripe, or the Telegram Bot API has a moment when the real key lands in a header or URL of the outgoing HTTP request. That's injection. By default it happens in your application code — you literally write headers={"Authorization": f"Bearer {api_key}"}. The key then lives in the process's memory, in environment variables, sometimes in command-line arguments visible via ps aux to any user on the same machine.

The idea behind a credential proxy is to move that moment out of the application and onto a separate server whose sole job you trust: substituting the key. The application never sees the real value at all — it works with a revocable token, and injection happens on the proxy, at the last moment before the request goes out to the provider.

Where the substitution actually happens

ApproachWhere the real key livesWhat the consumer sees
In application code (the default)Process memory, .env, configThe full real key
An nginx/Lua ruleServer config or the container's environmentNothing — but the same key for everyone who reaches the server
A homegrown middlewareA database or secrets store you maintain yourselfDepends on the implementation — usually no per-consumer revocation or limits
Credential proxy (proxykey)Encrypted (AES-256-GCM), decrypted only in memory for one requestA revocable token (vlt_…), one per consumer

Formats you need to be able to inject into

Providers put the key in different places in the request, and a proxy that only knows how to inject into Authorization: Bearer won't cover half of real integrations:

proxykey supports all four formats at the provider-configuration level (bearer / header / query / path) — including special path parsing for Telegram, where the token is extracted straight from the URL instead of a header.

Why homegrown injection is usually worse than a purpose-built proxy

Technically you can build header substitution in nginx or a simple middleware in an evening. The gap shows up not at launch, but at the moment of an incident:

Homegrown injectionCredential proxy
A separate token per consumerUsually not — one key for everyoneYes, its own revocable token
Revoking one consumer's accessRequires changing config and reloading the serviceOne click, nothing else affected
Per-consumer request limitsUsually not implementedrpm/rpd on every token
A log of who called whenNeeds to be set up separatelyBuilt in
Key in git/config historyOften — server config gets versioned tooThe key never leaves encrypted storage

Homegrown injection solves exactly one problem — "the key isn't in client code." It doesn't solve the fact that the same key is still shared across every consumer, with no way to revoke just one of them.

FAQ

How is injection different from a credential proxy?

Injection is the substitution itself. A credential proxy is a service that does that substitution properly: it stores the key encrypted, hands consumers revocable tokens, and logs every substitution.

Can I do injection in an existing nginx setup?

Technically yes, via proxy_set_header with a secret from a protected store. But that's a static substitution of the same key for everyone who reaches the server — no separate token per consumer, no revocation without a config reload, no per-consumer limits or logs.

Does injection work with streaming?

Yes, as long as the proxy doesn't buffer the body. The substitution happens in headers or the path before the request leaves for the provider — a streaming response (SSE, chunks) passes through unchanged.

Try it on one key

Add a key, get a pass, and switch one service — it takes a minute. Free, no card required.

Get started →