vercel/ai · error · Error

Google Vertex Interactions models do not support Express Mod

Error message

Google Vertex Interactions models do not support Express Mode API keys. Use standard Google Cloud credentials instead.

What it means

createInteractionsModel in the Vertex provider base throws this Error whenever an Interactions model or agent is requested while Express Mode API-key auth is configured. The Interactions API on Vertex is only reachable with standard Google Cloud credentials, so the provider blocks model creation immediately.

Source

Thrown at packages/google-vertex/src/google-vertex-provider-base.ts:307

      supportedUrls: () => ({
        '*': [
          // HTTP URLs:
          /^https?:\/\/.*$/,
          // Google Cloud Storage URLs:
          /^gs:\/\/.*$/,
        ],
      }),
    });
  };

  const createInteractionsModel = (
    modelIdOrAgent:
      | GoogleInteractionsModelId
      | { agent: GoogleInteractionsAgentName }
      | { managedAgent: string },
  ) => {
    if (apiKey) {
      throw new Error(
        'Google Vertex Interactions models do not support Express Mode API keys. Use standard Google Cloud credentials instead.',
      );
    }

    return new GoogleInteractionsLanguageModel(
      modelIdOrAgent as GoogleInteractionsModelInput,
      {
        // The Interactions API is a location-scoped resource
        // (`.../locations/{region}/interactions`), so it uses the
        // endpoint-style base URL without the `/publishers/google` suffix that
        // the base-model paths carry.
        ...createConfig('interactions', { endpoint: true }),
        generateId: options.generateId ?? generateId,
      },
    );
  };

  const createEmbeddingModel = (modelId: GoogleVertexEmbeddingModelId) =>

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Configure the provider with service-account credentials (GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_SERVICE_ACCOUNT_KEY) and drop the apiKey.
  2. Unset GOOGLE_VERTEX_API_KEY in the environment so ADC is used.
  3. If API-key auth is a hard requirement, use the @ai-sdk/google (Gemini API) provider instead of Vertex for interactions-style usage where supported.

Example fix

// before
const vertex = createGoogleVertex({ apiKey: key });
vertex.interactions({ agent: 'deep-research-pro' });
// after
const vertex = createGoogleVertex({ project: 'my-project', location: 'us-central1' });
vertex.interactions({ agent: 'deep-research-pro' });
Defensive patterns

Strategy: validation

Validate before calling

if (apiKey && wantsInteractions) {
  throw new Error('Interactions models on Vertex require standard Google Cloud credentials, not an API key.');
}

Try / catch

try {
  const m = vertex.interactions(agent);
} catch (e) {
  if (e instanceof Error && e.message.includes('Interactions models do not support Express Mode')) {
    // rebuild provider with service-account credentials
  } else throw e;
}

Prevention

When it happens

Trigger: Calling vertex.interactions('gemini-...') or vertex.interactions({ agent: ... }) / { managedAgent: ... } when the provider has an `apiKey` set (createGoogleVertex({ apiKey }) or GOOGLE_VERTEX_API_KEY env var) — the unconditional `if (apiKey)` check throws.

Common situations: Trying Interactions API with an API key obtained from Express Mode; env var GOOGLE_VERTEX_API_KEY leaking into a deployment that also uses interactions agents; examples copied from Gemini API (AI Studio) docs where API keys are normal.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/77897dd43456caf9. Report an issue: GitHub.