Host a gateway for Claude Code on Cloud Run

Claude apps gateway on Cloud Run lets you route Claude Code and Claude Desktop requests through a self-hosted proxy to Gemini Enterprise Agent Platform. You can authenticate developers through corporate single sign-on (SSO) and enforce central policies and spend controls without storing API keys on workstations.

Why use Claude apps gateway

Claude apps gateway is a self-hosted proxy service built into the claude binary that sits between developer Claude Code clients and a model provider, like Agent Platform. Hosting the gateway on Cloud Run helps you address common challenges when rolling out local coding agents like Claude Code across an engineering team:

  • Eliminate credential sprawl: a developer signs in through your identity provider using OpenID Connect (OIDC) SSO, such as Google Workspace, Microsoft Entra ID, or Okta, and receives a short-lived session. No API keys or Google Cloud credentials live on developer workstations.
  • Enforce consistent policies: administrators configure allowed models, tool permissions, and default settings centrally. When a developer signs in, these settings apply automatically.
  • Control token spend: administrators can track per-user spend and set daily, weekly, or monthly per-developer spend caps, either as a default across the organization or a group, or as an override for an individual developer.

When to use it

Use Claude apps gateway when your organization needs Claude Code inference to run through your own Google Cloud infrastructure for data residency, central governance, or cost attribution.

On Google Cloud, inference traffic and usage data remain inside your perimeter, and the gateway exports per-request usage metrics over the OpenTelemetry Protocol (OTLP) to an observability stack that you control. This architecture suits regulated industries and organizations that manage Claude Code as a centrally governed, auditable developer tool.

Why host on Cloud Run

Claude apps gateway runs as a stateless container backed by a PostgreSQL database:

  • Automatic scaling: Cloud Run scales the gateway automatically as developers use it, with no virtual machines or clusters to manage, and you pay only for the resources that you use.
  • Server-side credentials: the gateway uses a dedicated service identity with the Agent Platform User role (roles/aiplatform.user) attached to the Cloud Run service. Cloud credentials stay on the server through Application Default Credentials (ADC) and aren't distributed to developers.

Architecture and request flow

The following diagram shows the reference architecture for running Claude apps gateway on Cloud Run:

Architecture of Claude apps gateway hosted on Cloud Run.
Figure 1. Architecture of Claude apps gateway on Cloud Run.

Before developers sign in, you configure the gateway URL in Claude Code's managed settings on developer workstations (forceLoginMethod: "gateway" and forceLoginGatewayUrl), because /login doesn't show a gateway option by default. The gateway URL must also resolve to a private or loopback IP address, such as an internal Application Load Balancer hostname over Cloud VPN or Cloud Interconnect, or gcloud run services proxy for local testing; /login rejects public .run.app URLs.

After the workstation settings and private hostname are configured, the gateway processes developer requests as follows:

  1. The gateway URL is set on the developer's machine, normally through managed settings. There's no gateway option in the login picker.
  2. The gateway hostname generally needs to resolve only to private addresses. By default, the run.app URL is public, so /login rejects it unless run.app is set up to resolve privately.
  3. A developer runs /login in Claude Code and signs in with corporate SSO through the gateway.
  4. Claude Code sends requests to the gateway's private address through an internal Application Load Balancer.
  5. The gateway verifies policy rules and spend limits, and then forwards the request to Claude models on Agent Platform through the endpoint you configure (global, or a multi-region endpoint such as us or eu when you need data residency).
  6. The gateway records usage metrics and exports them over OTLP to your observability stack.

Behind the gateway, Cloud SQL for PostgreSQL (version 14 or later with a private IP address) stores sessions and rate-limit counters. Secret Manager stores gateway.yaml, the JSON Web Token (JWT) signing key, the OIDC client secret, and the database URL. Artifact Registry stores the gateway container image.

Get started

To deploy Claude apps gateway on Cloud Run, see the following resources:

What's next