Keyless LLM access with Agentgateway 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. 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 In this post, I want to explore how to authenticate to LLMs without relying on API keys at all using a gateway https://agentgateway.dev/ . Let the client bring its own key let-the-client-bring-its-own-key The 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. "Virtual" keys virtual-keys The usual first step is to introduce a "virtual" key. This is a key issued by the gateway itself rather than the underlying LLM provider. The gateway authenticates the client using the virtual key, and then swaps it out for the actual provider key when making requests to the backend. Each developer gets their own key, you can attach a budget to it, and revoking one doesn't break everyone else. The Agentgateway config looks like this docs https://agentgateway.dev/docs/standalone/latest/documentation/configuration/security/authentication/apikey-authn/ : llm: policies: apiKey: mode: strict keys: - key: "$GATEWAY KEY" metadata: name: alice models: - name: " " provider: openAI params: apiKey: "$OPENAI API KEY" For getting a client working, this is hard to beat. Every 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 . But we have all the issues that API keys bring around management and security. Have users log in have-users-log-in Before 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. On 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/ : llm: policies: jwtAuth: mode: strict issuer: https://login.example.com/ audiences: llm-gateway jwks: url: https://login.example.com/.well-known/jwks.json Now every request carries a real user identity jwt.sub or jwt.email , which you can use for logs, rate limits, and more. Offboarding is handled by the identity provider, like everything else. Sounds great... except it doesn't work in almost any case. Doing 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. So if you could get the ephemeral token to the client this would work great, but that piece is missing, making this option nearly infeasible. MCP 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. Clients with built-in support clients-with-built-in-support Very recently, some clients have added native OAuth support, which solves this problem. Codex has a gateway oauth table on custom model providers. Point 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/ . Claude Desktop has something similar in its enterprise gateway settings, called Interactive sign-in . Give it the gateway URL and OIDC settings and it will log in through the browser or an OS broker, on managed devices . All 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/ . For 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. The 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. Everything else: agentdesktop everything-else-agentdesktop If 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. For 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. Claude 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/ . daemon: user: true llmGateway: url: https://llm.example.com authentication: type: oidc issuer: https://login.example.com/ clientId: agentdesktop redirectUri: http://127.0.0.1:51327/callback programs: claudeCode: useLlmGateway: true You 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. You 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. Dropping the provider key dropping-the-provider-key That 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 If 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 Vertex AI, Azure OpenAI, and Bedrock vertex-ai-azure-openai-and-bedrock For the big cloud providers, this is really just an IAM exercise. Agentgateway 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/ : llm: models: - name: "vertex/ " provider: vertex params: vertexProject: my-project vertexRegion: us-central1 transformation: model: llmRequest.model.stripPrefix "vertex/" - name: "azure/ " provider: azure params: azureResourceName: my-openai-resource azureResourceType: openAI transformation: model: llmRequest.model.stripPrefix "azure/" - name: "bedrock/ " provider: bedrock params: awsRegion: us-east-1 transformation: model: llmRequest.model.stripPrefix "bedrock/" - 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 - 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 - 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/ Anthropic and OpenAI directly anthropic-and-openai-directly Until 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. Unlike 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. The 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. - 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 . - 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 . On 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: apiVersion: apps/v1 kind: Deployment metadata: name: agentgateway spec: template: spec: serviceAccountName: agentgateway containers: - name: agentgateway volumeMounts: - name: wif mountPath: /var/run/secrets/wif readOnly: true volumes: - name: wif projected: sources: - serviceAccountToken: path: anthropic audience: https://api.anthropic.com expirationSeconds: 3600 - serviceAccountToken: path: openai audience: https://api.openai.com/v1 expirationSeconds: 3600 The kubelet rotates these automatically. The 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: