Three credential decisions, not one

Use three independent decisions in the architecture: access to the gateway, selection of a provider credential, and authorization at an MCP server. For an authenticated AI Gateway, the credential location depends on the endpoint family: REST uses the usual Authorization header, while provider-native gateway endpoints use cf-aig-authorization.

BYOK changes how the gateway obtains a provider key, not whether an authenticated gateway accepts the request. When no provider authorization value is supplied, the gateway can use a stored provider key. When a provider authorization value is supplied, the documented behavior is to pass that value onward instead.

This separation is a proposed architecture model, not a provider-prescribed implementation. It avoids treating a gateway token, a provider key, and an MCP user token as substitutes for one another.

Four-case decision table

The owner and action columns below are deliberately application-owned policy choices. The credential-selection and gateway-result columns summarize the supplied documentation.

Credential-routing decisions for a gateway using BYOK
CaseClient-supplied credentialStored-key selectionForwarded provider credentialGateway-auth outcomeInference to rejectCredential ownerBounded application-owned action
No provider authorization header; default BYOK aliasGateway credential only, when gateway authentication is enabledThe configured default stored key is selected.No client provider value is forwarded.With authenticated gateway enabled, the required gateway credential must be present.Do not equate selecting a stored provider key with authenticating to the gateway.Proposed: platform team owns the stored provider key; service owns its gateway credential.Remove provider-key injection from this request path and retain the gateway credential.
No provider authorization header; explicit BYOK aliasGateway credential, plus an alias-selection header when a non-default key is intendedThe alias header chooses the configured stored key for that alias.No client provider value is forwarded.Gateway authentication remains a separate request requirement when enabled.Do not assume that an alias header replaces the gateway credential.Proposed: platform team governs aliases; service requests an approved alias.Review each non-default alias against an application-owned environment or tenant rule.
Provider authorization header present while BYOK is configuredGateway credential and a provider authorization valueDo not expect stored-key substitution for this request.The supplied provider authorization value is sent to the provider.Gateway authentication is evaluated independently of the provider value.Do not assume a BYOK rotation replaces a client-supplied provider credential.Proposed: the calling service owns the supplied provider credential until that header is removed.Inventory the header and remove it before relying on BYOK selection.
Authenticated gateway enabled; gateway token absentNo gateway credentialDo not rely on a stored-key selection outcome.Not a useful basis for application policy.The documented result is a failed request because authorization is missing.Do not treat a stored provider key or alias as gateway access credentials.Proposed: the service owns supplying its gateway credential.Restore the correct gateway credential for the endpoint family, then reassess provider-key routing.

Hypothetical rotation failure walkthrough

Consider an imagined service that replaces a stored provider key but still emits an obsolete provider authorization header. Under the documented forwarding rule, that client value would be sent to the provider rather than being replaced by the stored key. This is a conditional reasoning path, not an observed incident or a claimed integration result.

  1. The team would withdraw the assumption that stored-key rotation automatically governs every request.
  2. It would remove the conflicting provider header from the BYOK path while preserving the distinct credential used to reach an authenticated gateway.
  3. It would review whether the request should use the default stored key or a named alias.
  4. It would capture the actual provider response separately before deciding on application remediation.

The supplied excerpts support header forwarding and stored-key selection behavior; they do not establish the response returned by a provider for a particular obsolete key.

Keep MCP authorization server-side

For remotely hosted HTTP MCP servers, the supplied guidance describes an OAuth authorization-code flow with PKCE and says the client uses an access token for requests to the MCP server. That resource server should validate received tokens and their required constraints rather than accepting a token merely because it arrived.

The same guidance advises established validation libraries, short-lived access tokens, protected token storage, and distinct credentials for server and end-user flows. A local STDIO MCP server is described separately, with environment-based or embedded-library credential options.

Proposed policy: keep MCP issuer, audience or resource, scopes, and validation configuration in an MCP-specific boundary. Do not make gateway credentials or provider keys stand in for an MCP authorization decision.

Operating limits and review triggers

This article is limited to the supplied excerpts: Cloudflare AI Gateway material dated June 17 and September 22, 2026, and MCP authorization guidance for the protocol revision dated 2026-07-28. Revisit this decision model when those sources change or when that MCP revision is retired or replaced incompatibly.

The proposed alias governance, header-removal rule, rotation review, and MCP validation boundary are application policy. They do not claim provider endorsement, a completed deployment, a provider-error outcome, uninterrupted rotation, performance characteristics, or a universal security guarantee.

Before adopting the model, resolve the target endpoint family, identify the approved non-default aliases, assign concrete credential owners, and determine the MCP issuer, audience or resource, scopes, and validation library for the deployment.