{"slug": "keyless-llm-access-with-agentgateway", "title": "Keyless LLM access with Agentgateway", "summary": "Agentgateway published a guide showing three ways to authenticate LLM clients without provider API keys: passing the client's own provider key through the gateway, issuing gateway-issued \"virtual\" keys that are swapped for the real provider key on backend requests, and OAuth/JWT authentication via a `jwtAuth` policy pointing at an identity provider's issuer, audience and JWKS URL. The post notes that OAuth is nearly infeasible for most LLM clients because they cannot handle browser redirects, with exceptions for MCP, which has first-class OAuth support, and recent native OAuth support in Codex via a `gateway_oauth` table on custom model providers and in Claude Desktop's enterprise gateway settings.", "body_md": "API keys suck - they are hard to manage, easy to leak, and often tied to a single user or service account. Despite this, they are extremely prevalent in the AI space - so much so that AWS, which historically only offered SigV4 signing, even added API key support for Bedrock!\n\nIn this post, I want to explore how to authenticate to LLMs without relying on API keys at all using [a gateway](https://agentgateway.dev/).\n\n## Let the client bring its own key[#](#let-the-client-bring-its-own-key)\n\nThe simplest option is for the client to keep using the provider key it already has and send that key to the gateway. The gateway isn't really doing anything here (with authentication anyways), and generally I don't see people doing this so not much more to say here.\n\n## \"Virtual\" keys[#](#virtual-keys)\n\nThe usual first step is to introduce a \"virtual\" key. This is a key issued by the gateway itself rather than the underlying LLM provider.\n\nThe gateway authenticates the client using the virtual key, and then swaps it out for the actual provider key when making requests to the backend.\n\nEach developer gets their own key, you can attach a budget to it, and revoking one doesn't break everyone else.\n\nThe Agentgateway config looks like this ([docs](https://agentgateway.dev/docs/standalone/latest/documentation/configuration/security/authentication/apikey-authn/)):\n\n```\nllm:\n  policies:\n    apiKey:\n      mode: strict\n      keys:\n      - key: \"$GATEWAY_KEY\"\n        metadata:\n          name: alice\n  models:\n  - name: \"*\"\n    provider: openAI\n    params:\n      apiKey: \"$OPENAI_API_KEY\"\n```\n\nFor getting a client working, this is hard to beat.\nEvery client under the sun supports an API key (even if it insists on calling it `OPENAI_API_KEY` when it's really your gateway's key).\nBut we have all the issues that API keys bring around management and security.\n\n## Have users log in[#](#have-users-log-in)\n\nBefore AI decided to use API keys everywhere, there was this obscure standard called OAuth that handled user authentication and authorization. What if we just used that? Everyone already has an identity provider, so we could leverage it for authentication instead of managing API keys.\n\nOn the gateway side, this is easy: swap the `apiKey` policy for a `jwtAuth` one pointing at your issuer, audience, and JWKS URL ([docs](https://agentgateway.dev/docs/standalone/latest/documentation/configuration/security/jwt-authn/)):\n\n```\nllm:\n  policies:\n    jwtAuth:\n      mode: strict\n      issuer: https://login.example.com/\n      audiences: [llm-gateway]\n      jwks:\n        url: https://login.example.com/.well-known/jwks.json\n```\n\nNow every request carries a real user identity (`jwt.sub` or `jwt.email`), which you can use for logs, rate limits, and more.\nOffboarding is handled by the identity provider, like everything else.\n\nSounds great... except it doesn't work in almost any case.\nDoing the OAuth flow is great when we are a browser and can issue a redirect to a login page - most LLM clients can't handle that.\nSo if you *could* get the (ephemeral) token to the client this would work great, but that piece is missing, making this option nearly infeasible.\n\nMCP has first-class OAuth support and requires clients to handle the OAuth flow themselves, including opening a browser, following redirects, and refreshing tokens, so it doesn't have this issue.\n\n### Clients with built-in support[#](#clients-with-built-in-support)\n\nVery recently, some clients have added native OAuth support, which solves this problem.\n\n**Codex** has a `gateway_oauth` table on custom model providers.\nPoint the provider's `base_url` at the gateway, fill in the authorization URL, token URL, client ID, and scopes from your identity provider, and Codex will prompt you to sign in the next time you use it (and handle refreshes). See [Codex and Entra setup](https://agentgateway.dev/blog/2026-11-19-codex-cli-entra-id-sign-in-agentgateway/).\n\n**Claude Desktop** has something similar in its enterprise gateway settings, called *Interactive sign-in*.\nGive it the gateway URL and OIDC settings and it will log in through the browser (or an OS broker, on managed devices).\nAll the gateway ever sees is a bearer token on the inference request. See [Claude Desktop setup](https://agentgateway.dev/docs/standalone/latest/integrations/llm/clients/claude-desktop/).\n\nFor both of these, though, access is often through a (heavily subsidized) subscription rather than API usage. So the ideal would actually be a dual-auth flow: the client logs in twice, once to the company identity provider (for the gateway) and once to the subscription (for the provider), and sends both credentials.\n\nThe gateway still gets the user identity for logs and policy, but the actual usage is billed to the user's subscription. Codex explicitly supports this, while Claude does not.\n\n### Everything else: agentdesktop[#](#everything-else-agentdesktop)\n\nIf you have a bunch of developers using a bunch of different tools, waiting for each one to add OAuth support isn't great. agentdesktop handles the login and writes the client config for you.\n\nFor Claude Code, for example, it sets the gateway URL and an API key helper; the helper just asks the local agentdesktop daemon for a token.\nClaude Code thinks it has an API key, and the developer gets a browser login instead of a secret to paste into a config file ([docs](https://agentdesktop.dev/docs/getting-started/standalone/)).\n\n```\ndaemon:\n  user: true\nllmGateway:\n  url: https://llm.example.com\n  authentication:\n    type: oidc\n    issuer: https://login.example.com/\n    clientId: agentdesktop\n    redirectUri: http://127.0.0.1:51327/callback\nprograms:\n  claudeCode:\n    useLlmGateway: true\n```\n\nYou might wonder, why not just write an `apiKeyHelper` script yourself? The problem is `apiKeyHelper` is really designed for a quick non-interactive script that returns a result, which doesn't go well with an interactive browser login form.\nYou could try to make `apiKeyHelper` work with a browser login, but that would require building a custom helper to handle that - this is exactly what agentdesktop is.\n\n## Dropping the provider key[#](#dropping-the-provider-key)\n\nThat takes care of one side. But the gateway still has a long-lived provider key sitting in it, and this is arguably the more important key to remove. While we have removed key sprawl, we now have a single point with all of our provider keys!\n\nIf Agentgateway is running somewhere that already gives it an identity (often called \"workload identity\"), which most places do these days, we can use that instead. All that's left is getting the provider to trust that identity. Fortunately, all of the major providers now support this!\n\n### Vertex AI, Azure OpenAI, and Bedrock[#](#vertex-ai-azure-openai-and-bedrock)\n\nFor the big cloud providers, this is really just an IAM exercise.\nAgentgateway picks up credentials from the environment by default for all three, so there isn't even an `auth` block to write ([provider docs](https://agentgateway.dev/docs/standalone/latest/integrations/llm/providers/)):\n\n```\nllm:\n  models:\n  - name: \"vertex/*\"\n    provider: vertex\n    params:\n      vertexProject: my-project\n      vertexRegion: us-central1\n    transformation:\n      model: llmRequest.model.stripPrefix(\"vertex/\")\n  - name: \"azure/*\"\n    provider: azure\n    params:\n      azureResourceName: my-openai-resource\n      azureResourceType: openAI\n    transformation:\n      model: llmRequest.model.stripPrefix(\"azure/\")\n  - name: \"bedrock/*\"\n    provider: bedrock\n    params:\n      awsRegion: us-east-1\n    transformation:\n      model: llmRequest.model.stripPrefix(\"bedrock/\")\n```\n\n- **GCP.** On GKE, enable Workload Identity Federation and grant the workload access to Vertex AI (for example,`roles/aiplatform.user` ). Application Default Credentials picks up the workload's credentials via the metadata server.[GKE workload identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity)\n- **Azure.** On AKS, federate the Kubernetes service account with an Entra identity, give it the`Cognitive Services OpenAI User` role on the resource, and label the gateway pod`azure.workload.identity/use: \"true\"` so it gets the projected token and environment variables.[AKS workload identity](https://learn.microsoft.com/en-us/azure/aks/workload-identity-deploy-cluster)\n- **AWS.** On EKS, give the gateway pod an IAM role through IRSA. On ECS, use the task role. Give the role permission to invoke the models you're serving (including`bedrock:InvokeModelWithResponseStream` for streaming). Agentgateway discovers the temporary credentials and signs the Bedrock request.[Agentgateway on AWS](https://agentgateway.dev/docs/standalone/latest/integrations/cloud-providers/aws/)\n\n### Anthropic and OpenAI directly[#](#anthropic-and-openai-directly)\n\nUntil recently, talking to Anthropic or OpenAI directly meant an API key, full stop. Now both support workload identity federation: you hand them a JWT from an issuer they trust, and get a short-lived access token back.\n\nUnlike the cloud providers, this requires some configuration on the provider side to register the workload identity issuer and set up the trust relationship. Once that is done, however, the process is about the same.\n\nThe setup is: have your workload identity provider write a rotating JWT file for each API (Kubernetes itself is a good option here!), register the issuer with each provider, and scope the trust rule down to just the identity running Agentgateway.\n\n- **Anthropic** : audience`https://api.anthropic.com` , using the JWT bearer grant. You'll need your organization ID and the rule ID from[setting up federation in the Claude Console](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) .\n- **OpenAI** : audience`https://api.openai.com/v1` , using the token exchange grant. You'll need the identity provider ID and project service account ID from[setting up federation in the OpenAI API platform](https://developers.openai.com/api/docs/guides/workload-identity-federation) .\n\nOn Kubernetes, the JWT files can just be projected service account tokens. Each provider wants a different audience, so we project two tokens into the gateway pod:\n\n```\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: agentgateway\nspec:\n  template:\n    spec:\n      serviceAccountName: agentgateway\n      containers:\n      - name: agentgateway\n        volumeMounts:\n        - name: wif\n          mountPath: /var/run/secrets/wif\n          readOnly: true\n      volumes:\n      - name: wif\n        projected:\n          sources:\n          - serviceAccountToken:\n              path: anthropic\n              audience: https://api.anthropic.com\n              expirationSeconds: 3600\n          - serviceAccountToken:\n              path: openai\n              audience: https://api.openai.com/v1\n              expirationSeconds: 3600\n```\n\nThe kubelet rotates these automatically.\nThe issuer to register with each provider is your cluster's service account issuer (which needs a publicly reachable OIDC discovery endpoint; managed clusters like EKS, GKE, and AKS provide one), and the subject to trust is `system:serviceaccount:<namespace>:agentgateway`.\n\nOn the gateway, this uses [Enterprise Agentgateway's](https://www.solo.io/products/agentgateway) `fileAccess.cel` support: name each file, then reference it in the token exchange policy.\nAgentgateway watches the files for rotation, does the exchange, and uses the resulting access token for inference.\n\n```\nconfig:\n  fileAccess:\n    cel:\n      anthropicToken: /var/run/secrets/wif/anthropic\n      openaiToken: /var/run/secrets/wif/openai\n\nllm:\n  models:\n  - name: \"anthropic/*\"\n    provider: anthropic\n    transformation:\n      model: llmRequest.model.stripPrefix(\"anthropic/\")\n    auth:\n      oauthTokenExchange:\n        host: https://api.anthropic.com/v1/oauth/token\n        grantType: jwtBearer\n        subjectToken:\n          source:\n            expression: files.anthropicToken\n        additionalParams:\n          organization_id: '\"YOUR_ANTHROPIC_ORGANIZATION_ID\"'\n          federation_rule_id: '\"YOUR_ANTHROPIC_FEDERATION_RULE_ID\"'\n\n  - name: \"openai/*\"\n    provider: openAI\n    transformation:\n      model: llmRequest.model.stripPrefix(\"openai/\")\n    auth:\n      oauthTokenExchange:\n        host: https://auth.openai.com/oauth/token\n        grantType: tokenExchange\n        subjectToken:\n          tokenType: urn:ietf:params:oauth:token-type:jwt\n          source:\n            expression: files.openaiToken\n        additionalParams:\n          identity_provider_id: '\"YOUR_OPENAI_IDENTITY_PROVIDER_ID\"'\n          service_account_id: '\"YOUR_OPENAI_SERVICE_ACCOUNT_ID\"'\n```\n\nAnd that's it: no API keys on the laptops, and no API keys in the gateway.\n\n### I really need a provider API key[#](#i-really-need-a-provider-api-key)\n\nIf your provider only supports API keys, there are some interesting options around making that usage and storage more secure - check out [this post](https://agentgateway.dev/blog/2026-11-22-eliminating-plaintext-credential-injection/) from my colleague exploring this more.", "url": "https://wpnews.pro/news/keyless-llm-access-with-agentgateway", "canonical_source": "https://blog.howardjohn.info/posts/keyless-llm-gateway/", "published_at": "2026-12-02 00:00:00+00:00", "updated_at": "2026-12-02 23:43:43.613548+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools"], "entities": ["Agentgateway", "AWS", "Amazon Bedrock", "Codex", "Claude Desktop", "MCP"], "also_reported_by": [], "takeaway": "Replace provider API keys at the gateway with a `jwtAuth` policy (issuer, audiences, JWKS URL) so each request carries a real user identity via `jwt.sub` or `jwt.email` for logging and rate limits, or use gateway-issued virtual keys swapped for the provider key when clients can't run an OAuth flow.", "recommendation": {"advice": "Put an LLM gateway in front of provider keys and authenticate clients with JWT/OAuth or per-developer virtual keys, so revocation and budgets are scoped per user instead of shared API keys.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/keyless-llm-access-with-agentgateway", "markdown": "https://wpnews.pro/news/keyless-llm-access-with-agentgateway.md", "text": "https://wpnews.pro/news/keyless-llm-access-with-agentgateway.txt", "jsonld": "https://wpnews.pro/news/keyless-llm-access-with-agentgateway.jsonld"}}