{"record":{"id":"9458aa570595d7e6","repo":"vercel/ai","slug":"google-vertex-tuned-models-do-not-support-express","errorCode":null,"errorMessage":"Google Vertex tuned models do not support Express Mode API keys. Use standard Google Cloud credentials instead.","messagePattern":"Google Vertex tuned models do not support Express Mode API keys\\. Use standard Google Cloud credentials instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/google-vertex/src/google-vertex-provider-base.ts","lineNumber":281,"sourceCode":"        `ai-sdk/google-vertex/${VERSION}`,\n      );\n    };\n\n    return {\n      provider: `google.vertex.${name}`,\n      headers: getHeaders,\n      fetch: apiKey\n        ? createExpressModeFetch(apiKey, options.fetch)\n        : options.fetch,\n      baseURL: loadBaseURL({ endpoint }),\n    };\n  };\n\n  const createChatModel = (modelId: GoogleVertexModelId) => {\n    const endpoint = isEndpointModelId(modelId);\n\n    if (endpoint && apiKey) {\n      throw new Error(\n        'Google Vertex tuned models do not support Express Mode API keys. Use standard Google Cloud credentials instead.',\n      );\n    }\n\n    return new GoogleLanguageModel(modelId, {\n      ...createConfig('chat', { endpoint }),\n      generateId: options.generateId ?? generateId,\n      supportedUrls: () => ({\n        '*': [\n          // HTTP URLs:\n          /^https?:\\/\\/.*$/,\n          // Google Cloud Storage URLs:\n          /^gs:\\/\\/.*$/,\n        ],\n      }),\n    });\n  };\n","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/google-vertex/src/google-vertex-provider-base.ts#L263-L299","documentation":"createChatModel in the Vertex provider base throws this Error when a model id that resolves to a tuned-model endpoint is combined with Express Mode API-key authentication. Tuned Vertex endpoints require standard Google Cloud auth (service account / ADC), so the provider rejects the combination at model creation time.","triggerScenarios":"Constructing vertex('projects/.../locations/.../endpoints/...') or an endpoint-style tuned model id while the provider was configured with `apiKey` (Express Mode), e.g. createGoogleVertex({ apiKey: ... }) or GOOGLE_VERTEX_API_KEY set — `isEndpointModelId(modelId)` is true and `apiKey` is set.","commonSituations":"Using an Express Mode API key for quick local prototyping, then switching to a tuned/deployed model endpoint; CI environments where GOOGLE_VERTEX_API_KEY is exported alongside endpoint model ids; misunderstanding that Express Mode covers all Vertex features.","solutions":["Remove the apiKey / GOOGLE_VERTEX_API_KEY and authenticate with service-account credentials (GOOGLE_SERVICE_ACCOUNT_KEY / GOOGLE_APPLICATION_CREDENTIALS or workload identity).","Use a base model id instead of a tuned endpoint if Express Mode must be kept.","Create a second provider instance without apiKey specifically for tuned endpoint models."],"exampleFix":"// before\nconst vertex = createGoogleVertex({ apiKey: process.env.GOOGLE_VERTEX_API_KEY });\nconst model = vertex('projects/p/locations/us-central1/endpoints/123');\n// after\nconst vertex = createGoogleVertex({ project: 'p', location: 'us-central1' }); // ADC/service account\nconst model = vertex('projects/p/locations/us-central1/endpoints/123');","handlingStrategy":"validation","validationCode":"const usingApiKey = Boolean(process.env.GOOGLE_VERTEX_API_KEY || apiKeyOption);\nconst isEndpointModel = modelId.includes('/endpoints/');\nif (usingApiKey && isEndpointModel) {\n  throw new Error('Tuned Vertex endpoints require service-account auth, not an Express Mode API key.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return vertex(modelId);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Express Mode API keys')) {\n    // recreate provider with ADC/service-account credentials\n  } else throw e;\n}","preventionTips":["Don't set GOOGLE_VERTEX_API_KEY in environments that also use tuned endpoints.","Use workload identity or GOOGLE_APPLICATION_CREDENTIALS as the default Vertex auth.","Document that Express Mode API keys only support base chat models."],"tags":["authentication","google-vertex","express-mode","config"],"backgroundTag":"incompatible-auth-method","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}