# @pleach/transport-vertex (/docs/transport-vertex)



<Callout type="warn">
  **Not yet published.** `@pleach/transport-vertex` is marked `private`
  in this monorepo and is not on npm — `npm install @pleach/transport-vertex`
  will not resolve today. This page documents the planned surface; the
  package publishes in a later cut.
</Callout>

`@pleach/transport-vertex` is the Google Vertex AI route for a
Pleach session whose buyer reaches Gemini through their GCP project.
`createVertexProvider(config)` returns an `AgentProvider` that streams
from Vertex's `streamGenerateContent` endpoint. Cascade behavior and
audit shape stay consistent with every other provider; only the
transport and the credential binding change.

## What it provides [#what-it-provides]

* An `AgentProvider` (`execute` + `abort` + `capabilities`) for Gemini
  on Vertex (`gemini-1.5-*`, `gemini-2.0-*`, `gemini-2.5-*`).
  Anthropic-on-Vertex and other families throw
  `"family not yet supported"` at invoke time.
* Auth through `google-auth-library`: Application Default Credentials
  (including workload identity) or an explicit service-account key.
* Region pinning at the provider instance (`location`), plus
  `createResolveRegion(config)` for `AgentAdapter.resolveRegion`.
* Generic auth errors: the stream never carries the underlying
  credential error or an HTTP 401/403 body.
* Per-call abort: each `execute()` owns its own `AbortController`.
  `abort()` cancels every in-flight call.

## Where it fits [#where-it-fits]

`@pleach/transport-vertex` plugs into the same `provider` slot
on `SessionRuntime` that the direct-API providers fill — it
satisfies the `AgentProvider` contract documented in
[Providers](/docs/providers). For the architectural shape of a
Vertex-routed deployment — transport vs family, IAM federation,
region as a hard constraint, cost reconciliation — see
[Cloud-routed agent](/docs/cloud-routed-agent).

## Install [#install]

This package is not on npm yet, so there is no `npm install` step.
Build it from the source repository and add it as a workspace
dependency alongside `@pleach/core`:

```json
{
  "dependencies": {
    "@pleach/core": "0.1.0",
    "@pleach/transport-vertex": "workspace:*"
  }
}
```

Once the package publishes, this page will switch to a regular
`npm install`.

`google-auth-library` (`^9.0.0 || ^10.0.0`) is an **optional** peer
dependency, loaded with a dynamic `import()` on first use. Importing the
package without it is safe. The first `execute()` then yields an
`error` event naming the missing `google-auth-library` peer.

## Credentials [#credentials]

With no `credentials`, the provider uses Application Default
Credentials: `GOOGLE_APPLICATION_CREDENTIALS` (a service-account key or
a workload-identity-federation config), the gcloud SDK, or the metadata
server (GKE Workload Identity, attached service accounts on GCE and
Cloud Run).

```ts
import { createVertexProvider } from "@pleach/transport-vertex";

const provider = createVertexProvider({
  project: "my-project-123",
  location: "us-central1",
  defaultModelId: "gemini-2.5-flash",
});
```

Pass `credentials` (`keyFilename`, an inline `credentials` object,
`scopes`, `projectId`) to use a specific service account. The default
scope is `https://www.googleapis.com/auth/cloud-platform`.

<Callout type="warn">
  **Multi-tenant hosts: omitting `credentials` means ambient ADC.** Calls
  are authenticated, and billed, as whatever identity the host process
  runs under. If you build a provider per tenant, always pass that
  tenant's explicit `credentials`. Otherwise a tenant record with missing
  credentials silently falls back to the host's own service account.
</Callout>

Each provider builds one `GoogleAuth` client on first use and reuses
it, so credential discovery runs once and the library refreshes the
short-lived access token before it expires.

## `location` [#location]

`location` must match `/^[a-z0-9-]+$/` (for example `"us-central1"` or
`"europe-west4"`). It becomes part of the hostname that receives the
token, so anything else throws at construction. `project` and
`location` are both required.

## Auth errors [#auth-errors]

A credential failure yields one `error` event with the fixed text
`"vertex: authentication failed"`, or a fixed message naming a missing
`google-auth-library`. The underlying error goes only to the optional
`onAuthError(error)` hook, and a throwing hook is ignored. An HTTP
401/403 from Vertex is handled the same way: its body isn't echoed, and
the provider drops its `GoogleAuth` client so the next request
re-resolves credentials.

## Configuration [#configuration]

| Field            | Type                        | Notes                                                                                                 |
| ---------------- | --------------------------- | ----------------------------------------------------------------------------------------------------- |
| `project`        | `string`                    | GCP project id.                                                                                       |
| `location`       | `string`                    | Vertex AI location; must match `/^[a-z0-9-]+$/`.                                                      |
| `credentials`    | `GoogleAuthOptions?`        | `keyFilename` / `credentials` / `scopes` / `projectId`. Omit for ambient ADC.                         |
| `onAuthError`    | `(error: unknown) => void?` | Receives the underlying credential error.                                                             |
| `defaultModelId` | `string?`                   | Default Gemini model id; `AgentExecutionConfig.model` overrides per call. A call with neither throws. |
| `apiVersion`     | `string?`                   | Vertex API version. Default `"v1"`; `"v1beta1"` for early-access features.                            |

The package's README and its published type declarations in the
[source repository](https://www.getpleach.com/docs/core) are the
reference. If a claim here disagrees with the source, the source wins.

## Where to go next [#where-to-go-next]

<Cards>
  <Card title="Cloud-routed agent" href="/docs/cloud-routed-agent" description="Transport-vs-family, IAM federation, region pinning, and cost reconciliation to the cloud invoice." />

  <Card title="Providers" href="/docs/providers" description="The AgentProvider contract this transport implements and the cascade rules it threads through." />

  <Card title="Region-pinned agent" href="/docs/region-pinned-agent" description="The sibling shape when family + region pinning is procurement-driven rather than cloud-driven." />
</Cards>
