The google-cloud provider gives sandboxes native GCP credentials so
any Google Cloud SDK works out of the box — Cloud Storage, BigQuery, Drive,
Maps, Discovery Engine, or any other GCP API. A GCE metadata server emulator
on loopback provides credential placeholders that the
sandbox proxy resolves to real tokens at request time. The sandbox process
never holds a real GCP credential.
Quick Start
Import the google-cloud profile first; a gateway serves only the profiles you
imported:
If you already have gcloud configured with Application Default Credentials,
create a provider with automatic credential refresh in one command:
--from-gcloud-adc reads your ADC file, configures OAuth2 refresh on the
gateway, and mints the first access token before the command returns. The
gateway rotates the token automatically — no manual refresh needed.
Authentication Flows
Two credential flows are supported. Choose based on your environment.
Application Default Credentials (gcloud ADC)
Use credentials from gcloud auth application-default login. The gateway
exchanges the refresh token for short-lived access tokens automatically.
Configure credential refresh with the ADC JSON fields:
Find these values in your ADC file at
~/.config/gcloud/application_default_credentials.json.
Trigger the first token mint:
Service Account Key
Use a GCP service account JSON key file. The gateway signs JWTs and
exchanges them for access tokens using the google-service-account-jwt
strategy.
Configuration Keys
Set these with --config key=value during provider creation:
How It Works
When a sandbox starts with the google-cloud provider attached:
- The gateway mints a fresh GCP access token and stores it in the sandbox proxy’s credential resolver.
- A loopback HTTP server on
127.0.0.1:8174emulates the GCE instance metadata API, serving credential placeholders (not real tokens) to GCP SDKs. The sandbox process never holds a real GCP credential. - When the SDK makes an API call, it sends the placeholder in the
Authorizationheader. The sandbox proxy TLS-terminates the outbound connection, resolves the placeholder to the real token, and forwards the request to GCP. - When the token approaches expiry, the gateway refreshes it. The proxy’s resolver is updated atomically — subsequent API calls use the new token automatically.
Configuration values (project_id, region, service_account_email)
are visible in plain text inside the sandbox — they appear as
environment variables and are served by the metadata endpoint. These are
non-secret identifiers, not credentials. Access tokens are never exposed;
only placeholders reach the sandbox process.
Injected Environment Variables
The provider automatically injects these into the sandbox. Non-secret vars are resolved to real values at process spawn time; token vars stay as placeholders for proxy-time resolution.
Using with GCP APIs
The metadata emulator serves tokens with the cloud-platform OAuth2 scope,
which grants access to any GCP API the underlying service account has IAM
permissions for. Add the target API hosts to your sandbox network policy:
Or update a live sandbox directly:
Network Policy
The google-cloud provider type does not include any network policy
endpoints by default. You must add endpoint rules to your sandbox policy
for each GCP API the sandbox needs to reach. See “Using with GCP APIs”
above for an example.
Vertex AI
The google-vertex-ai provider gives selected sandboxes access to native
Google Vertex AI endpoints. OpenShell keeps refresh bootstrap material at the
gateway, rotates short-lived access tokens, and resolves token placeholders
only at endpoints authorized by the provider profile.
OpenShell does not choose a model or transform a request. The workload uses the native Vertex endpoint and request format for its selected model.
Prerequisites
- A GCP project with the Vertex AI API enabled.
- A service account with the Vertex AI User role and a downloaded JSON key for production, or gcloud Application Default Credentials for local development.
- Access to the selected model in the intended Vertex region.
Create a Vertex AI Provider
Import the google-vertex-ai profile first:
Service Account Key
Create the provider with the JSON key as gateway-only bootstrap material:
Configure gateway-managed refresh:
The private key remains in the gateway credential store. Sandboxes receive only an opaque placeholder for the short-lived access token.
gcloud Application Default Credentials
For local development:
--from-gcloud-adc reads authorized-user ADC, configures an OAuth2 refresh
grant at the gateway, and immediately mints GOOGLE_VERTEX_AI_TOKEN. The ADC
file and refresh token do not enter the sandbox.
Vertex AI Configuration Keys
When the provider is attached, OpenShell also projects standard project and
location aliases such as GOOGLE_CLOUD_PROJECT, ANTHROPIC_VERTEX_PROJECT_ID,
CLOUD_ML_REGION, and VERTEX_LOCATION.
Attach the Vertex AI Provider
Attach it while creating a sandbox:
Or attach it to an existing sandbox:
Launch a new process after runtime attachment so it receives the provider environment. Existing processes do not gain newly attached environment variables.
Call the Native Vertex API
Claude models use Vertex’s publisher-model endpoint. Run a request from a new sandbox process:
Use the model ID and location supported by your GCP project. For global, us,
or eu, use the corresponding Google-documented hostname instead of the
regional <location>-aiplatform.googleapis.com form.
Gemini and third-party models use their documented native or OpenAI-compatible Vertex endpoints. Configure the model, URL, streaming mode, and timeout in the client. OpenShell does not rewrite them.
Verify and Troubleshoot Vertex AI
Inspect the attachment and effective policy:
Common failures:
- A missing token variable usually means the process started before provider attachment. Launch a new process.
connection not allowed by policymeans the provider endpoint or caller binary is absent from the effective policy. A gateway global policy override suppresses provider-derived entries.credential_endpoint_mismatchmeans the request destination is outside the provider profile’s endpoint binding.- A Vertex 400 or 404 usually means the model, location, publisher path, or request body does not match the native API.
- A Vertex 401 or 403 can indicate an expired refresh grant or missing GCP IAM
permission. Check
provider refresh statusand the Vertex AI User role.
Provider creation does not verify model access. The native request is the end-to-end check.
Migrate an Existing Vertex Route
An earlier managed route stored the provider and model separately and rewrote requests for the workload. After upgrading, the provider and its refresh state remain, but the route does not.
- Attach the preserved Vertex provider to each intended sandbox.
- Launch new workload processes.
- Move the route’s model and timeout into the client configuration.
- Change the client to the native Vertex endpoint and request format.
- Verify one non-streaming and one streaming native request before production rollout.
Do not attach the provider to every sandbox automatically. The old route was workspace-global; the replacement intentionally grants access per sandbox.