Join our Newsletter — 33% off our NHI Course
Home› Guides› Model Aggregator and LLM Router Key Security: Protect…
Guide Agent Identity & Access

Model Aggregator and LLM Router Key Security: Protect the Keys That Unlock Every Model

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 8 November 2026 14 min read
On this page

A model aggregator or LLM router turns dozens of separate provider keys into one credential, so a single leaked aggregator key, admin key or stored provider key can spend money and leak data across every model you use. Hosted aggregators such as OpenRouter and self-hosted routers such as LiteLLM Proxy give applications and agents one API in front of many model providers. That convenience concentrates non-human identities: the router holds upstream provider keys, issues its own keys to callers, and has administrative keys that can mint more. This guide focuses on the key and access model of routers and aggregators: which credentials exist, how to scope and rotate them, how bring-your-own-key (BYOK) changes the risk, and what to log. It is written for platform engineers, AI platform owners and identity teams. For the wider gateway pattern (routing, caching, policy) see the AI Gateway and LLM Gateway Guide; this page goes deeper on credentials.

Key takeaways

  • Three credential tiers, three risk levels. Inference keys spend money, management or master keys mint and delete inference keys, and stored provider keys (BYOK) are live credentials at OpenAI, Anthropic, AWS or Google. Protect each tier separately.
  • Every key needs a spending cap and an owner. OpenRouter's own documentation recommends a credit limit on every key, because an unlimited key lets a leaked credential or a runaway agent drain the whole balance, including auto top-ups.
  • Admin keys must expire. OpenRouter management keys are account-level and unscoped across workspaces; LiteLLM's master key is the proxy admin key. Give them expiry, vault them and never ship them to applications.
  • Deleting a stored key is not revoking it. When an aggregator or hosted tool holding your provider keys is breached, you must rotate at the provider, as the OpenCode Console breach showed.
  • The router's own logs are a secret store. Request and response bodies can contain tokens and personal data; treat log stores with the same controls as the keys themselves.

How identity and access work in model aggregators and LLM routers

A router sits between callers (applications, agents, developers) and upstream model providers. Hosted aggregators run the router for you and bill you through prepaid credits; self-hosted routers run inside your boundary and you supply every upstream key. In both cases the router is an identity broker: it authenticates the caller with one credential and authenticates to the provider with another.

CredentialHosted aggregator example (OpenRouter)Self-hosted router example (LiteLLM Proxy)What an attacker gets
Inference keyAPI key sent as Authorization: Bearer to https://openrouter.ai/api/v1, with optional credit limitVirtual key from /key/generate with models, max_budget, durationModel access up to the key's limit, billed to you
Administrative keyManagement key: cannot call completions, but can create, update and delete API keys through /api/v1/keysMaster key (general_settings: master_key or LITELLM_MASTER_KEY, must start with sk-)Ability to mint unlimited new inference keys and remove your controls
Upstream provider keyBYOK keys stored per workspace, encrypted by the aggregatorProvider keys in config, environment variables or the proxy databaseDirect use at the provider, bypassing all router limits
Delegated user keyKey issued to an end user through the OAuth PKCE flow, spending that user's creditsKeys tied to user_id or team_idSpend on someone else's account
Cloud identity for upstreamBYOK AWS access keys or Vertex service account JSONWorkload identity or cloud credentials on the proxy hostCloud API access beyond model invocation if over-scoped

OpenRouter's authentication page makes the point directly: its keys are more powerful than model provider keys because they can carry per-app credit limits and are used in OAuth flows. The same is true of any router key that can reach many providers at once.

Choosing hosted or self-hosted

  • Hosted aggregator: no infrastructure, one bill, very wide model catalogue. The aggregator becomes a third party that processes your prompts and, with BYOK, holds your provider secrets. Assess it under supplier risk (NIST CSF 2.0 GV.SC-07, SP 800-53 SA-9).
  • Self-hosted router: keys and prompts stay inside your boundary, but patching, database security and admin-plane exposure are your job. See the LiteLLM Proxy Security Guide for proxy hardening.
  • Small teams: a hosted aggregator with per-key limits and no BYOK is often lower risk than running a proxy nobody patches.
  • Large or regulated organisations: self-hosted routing with workload identity to cloud model services, or a hosted aggregator on a plan that supports regional processing and enforced data policies, plus your own egress controls.

Admin roles and privileged access

The administrative tier is where one credential becomes many. Treat it as privileged access, not as an API key.

  • OpenRouter management keys: on organisation accounts only Organization Admins can create them, and they are account-level and unscoped, covering all workspaces. The expiry is set at creation and cannot be changed; after expiry requests fail with 401 Unauthorized and "API key expired". OpenRouter advises setting an expiration on every management key, because a leaked one can create, edit and delete API keys and one without expiry stays valid until deleted.
  • Organisation settings: OpenRouter exposes GET and PATCH /api/v1/organization/settings, including is_filtered_model_catalog_enabled (default false). Changes here affect everyone, so restrict who holds keys that can call it.
  • LiteLLM master key: the documentation calls it the Proxy Admin key. Generate it randomly, store it in a secrets manager, keep admin routes on a management network and never use it from application code.
  • Human admins: enforce SSO and MFA on the aggregator console, keep the admin group small, and review it quarterly (SP 800-53 AC-2, AC-6). See the Privileged Access Management Guide.
Admin actionWho should be able to do itControl
Create or delete inference keysPlatform automation, two named adminsExpiring management key in a vault, change logged
Add or change BYOK provider keysPlatform team onlyDual control, provider key created specifically for the router
Change guardrails, budgets, data policiesOrg adminsChange ticket, alert on modification
Raise a key's credit limitBudget ownerApproval record, temporary increase where supported

Integrations, API tokens and service accounts

Inference keys: one per caller

  • Issue a key per application, environment and agent: shared keys make attribution, limits and revocation impossible. OpenRouter lists creating a unique key per customer instance in a SaaS application as a core use of the management API.
  • Cap every key: set a credit limit at creation. OpenRouter supports a limit with limit_reset (for example daily, reset at midnight UTC), after which requests are rejected until reset. Keys created during onboarding get a $100 limit and expire after 180 days, a sensible default to copy.
  • Restrict models and providers: in OpenRouter, guardrails provide a model allowlist and provider allowlist assigned to members or keys; in LiteLLM the key's models field does the same. An agent that only needs one model should not be able to call the most expensive one.
  • Expire and rotate: LiteLLM keys accept duration, and POST /key/{key}/regenerate with a grace_period (documented as an Enterprise feature) allows overlap during rotation; omitting the grace period revokes the old key immediately. Scheduled rotation uses LITELLM_KEY_ROTATION_ENABLED. See the AI Agent Credential Lifecycle and Rotation Guide.
  • Keep keys server-side: OpenRouter warns that a no-limit key should stay out of client-side code. Browser and mobile apps should call your backend, which holds the key.

BYOK: storing your provider keys in the aggregator

BYOK lets the aggregator call providers with your own provider credentials. OpenRouter says provider keys are encrypted and used for all requests routed through that provider, charges a 5% fee on BYOK usage, and lets you filter each key by model, by OpenRouter API key hash (allowed_api_key_hashes) or by workspace member (allowed_user_ids).

  • Create a dedicated provider key for the aggregator: never paste a key that other systems use. Then a breach at the aggregator can be contained by revoking one key at the provider.
  • Least privilege for cloud credentials: for Amazon Bedrock, OpenRouter documents the required actions as bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream and recommends dedicated IAM users with limited permissions. For Google Vertex it requires aiplatform.endpoints.predict (plus batch permissions only if you use Batch). Prefer a Bedrock API key tied to one region over long-lived access keys where it meets your needs.
  • Decide on fallback: by default, if all BYOK keys fail or are rate limited, OpenRouter falls back to its shared endpoints. Set "Never use shared capacity" (is_required: true) or is_byok_only: true if your data agreements require your own provider account.
  • Count BYOK spend in budgets: BYOK spend does not count toward guardrail or workspace budgets by default. Enable include_byok_in_budgets (and include_byok_in_limit on keys) or your caps will not cover it.
  • Do not rely on self-attestation: OpenRouter states that zero data retention and data region declarations by providers are self-attested and not verified by OpenRouter. Treat them as contractual claims to check, not technical guarantees.

Delegated user keys (OAuth PKCE)

Applications that let users bring their own aggregator account can use OpenRouter's PKCE flow: redirect to https://openrouter.ai/auth with callback_url, code_challenge and code_challenge_method, then exchange the code at /api/v1/auth/keys. Codes expire after 10 minutes and are single use. Always use S256 (the documentation also permits plain and even no challenge), always send and check state, and store the returned key encrypted and bound to the user who authorised it. See the OAuth 2.1, GNAP and FAPI Guide.

Logging and detection

Router compromise shows up first as money and unusual models. Detection should use both the router's own records and the providers' billing and audit data, because a stolen BYOK key is used directly at the provider and never touches the router.

SignalSourceWhat it can indicate
Spend per key above its normal daily rangeOpenRouter key fields usage_daily, usage_weekly; LiteLLM key spendLeaked key, runaway agent loop, resale of access (ATT&CK T1496.004 Cloud Service Hijacking)
Keys created, edited or deleted outside change windowsManagement API activity, console auditAdmin or management key compromise
New models or providers used by an existing keyActivity logs per key hashMisuse, or guardrails removed
BYOK provider key used from unknown IPs or regionsProvider audit (AWS CloudTrail for Bedrock, Google Cloud audit logs, provider usage dashboards)Provider key stolen from the router or aggregator
Key found in code, tickets or logsSecret scanning, provider leak notificationsExposure (ATT&CK T1552.001 Credentials In Files)
Guardrail or budget changesGuardrail API and consoleDefence weakening ahead of abuse
  • Leak notifications: OpenRouter is a GitHub secret scanning partner and emails the owner when a key is confirmed compromised. Route those emails to a monitored security mailbox, not an individual. See the LLMjacking Response Playbook.
  • Protect the logs: in the LiteLLM supply chain attack of October 2026, LiteLLM said developer GitHub CLI OAuth tokens had been captured in logged response bodies on an internet-exposed internal deployment, and the attacker used them to ship a poisoned release that stole LLM provider keys stored in LiteLLM Proxy. Limit body logging, redact tokens and restrict access to log stores.

Metrics:

  • Percentage of inference keys with a credit limit and an expiry (target 100%).
  • Percentage of management or master keys with expiry under 90 days.
  • Number of keys with no traffic in 30 days (should trend to zero after clean-up).
  • Mean time from leak notification to provider-side revocation.
  • Share of AI traffic that goes through the sanctioned router rather than direct provider calls.

Hardening baseline

  1. Inventory: list every router or aggregator account, workspace, management key, inference key and BYOK provider key, with an owner for each (CSF 2.0 PR.AA-01).
  2. Constrain admin keys: expire and vault management or master keys, restrict who can create them, alert on use.
  3. Cap and scope inference keys: limit, reset interval, model and provider allowlists, expiry. Pilot on one team before enforcing everywhere so limits do not break production; keep a documented process for raising limits rather than removing them.
  4. Isolate BYOK keys: dedicated provider keys or IAM principals for the router, least-privilege actions, budgets counted, shared-capacity fallback set to your data policy.
  5. Apply data policy: in OpenRouter, use the training opt-out and data policy filtering at settings/privacy, guardrail ZDR enforcement (for example enforce_zdr_openai) and, where your plan supports it, regional hostnames eu.openrouter.ai or us.openrouter.ai or allowed_data_regions.
  6. Close the bypass: block direct calls to provider endpoints from workloads that should use the router, so personal keys cannot sidestep limits.
  7. Prepare revocation: write down how to disable a key (OpenRouter PATCH /api/v1/keys/{hash} with disabled; LiteLLM POST /key/block) and how to rotate each BYOK key at its provider. Rolling back a bad limit is a matter of raising it; rolling back a leaked key is impossible, so rehearse rotation.

Framework mapping

RiskControlFramework reference
Unlimited spend from stolen or looping keysPer-key credit limits and reset intervalsOWASP LLM10:2025 Unbounded Consumption; SP 800-53 AC-6
Long-lived admin and inference keysExpiry, rotation, vaultingSP 800-53 IA-5; CSF 2.0 PR.AA-01
Provider keys stored by a third partyDedicated keys, supplier assessmentSP 800-53 SA-9, SC-28; CSF 2.0 GV.SC-07
Over-broad model and provider accessAllowlists per key or memberCSF 2.0 PR.AA-05
Misuse not noticedSpend and admin activity monitoringSP 800-53 AU-2, AU-6; CSF 2.0 DE.CM-09
Prompts and tokens leaking via logs or providersData policies, log redactionOWASP LLM02:2025 Sensitive Information Disclosure
Poisoned router package stealing keysPinned versions, artifact verificationATT&CK T1195.002 Compromise Software Supply Chain

Common misconfigurations

  • One shared key for everything: a single aggregator key in every service means one leak stops all AI traffic when you revoke it, so teams delay revocation. Per-caller keys make revocation cheap.
  • No limit on the key, auto top-up on the account: the combination OpenRouter itself warns about. A leaked key then spends until someone reads the invoice. See the Denial-of-Wallet and AI Agent Cost Runaway Guide.
  • Re-using production provider keys for BYOK: when the hosted service is breached, revoking the key breaks unrelated systems. In the OpenCode Console breach, stored OpenAI, Anthropic and Google keys were exposed and users reported unauthorised charges on their own provider accounts.
  • Admin keys without expiry: a management or master key from an old automation, still valid and sitting in a CI variable.
  • Budgets that silently exclude BYOK: caps look healthy while BYOK spend is uncapped because include_byok_in_budgets was never enabled.
  • Router logs with full bodies and no access control: prompts, personal data and tokens captured where many people can read them.

Practitioner checklist

  • Inventory every aggregator account, workspace and router instance with a named owner.
  • Expire, vault and alert on all management and master keys; limit who can create them.
  • Issue one inference key per application, environment and agent, each with a credit limit, reset interval and expiry.
  • Restrict models and providers per key or member using allowlists.
  • Use dedicated, least-privilege provider keys or IAM principals for BYOK, and count BYOK in budgets.
  • Set data policies: training opt-out, ZDR enforcement and regional processing where required, and confirm provider claims contractually.
  • Monitor per-key spend, new models, admin changes and provider-side use of BYOK keys.
  • Route leak notifications to a monitored mailbox and rehearse provider-side rotation.
  • Redact tokens from router logs and restrict log access.
  • Block direct provider egress for workloads that must use the router. See the API Key Management Guide.

Standards and references

Related NHI Mgmt Group resources: AI Gateway and LLM Gateway Guide · LiteLLM Proxy Security Guide · LLMjacking Guide · Secrets Management Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 8 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.