earendil-works/pi · error

Custom fetch is not supported by the Google Vertex adapter

Error message

Custom fetch is not supported by the Google Vertex adapter

What it means

Like the GenAI adapter, the Vertex adapter rejects injectable custom fetch functions outright, since its transport is bound to the Vertex client. Passing options.fetch (other than globalThis.fetch) is treated as an unsupported configuration and throws before any request.

Solutions

  1. Use the default fetch; the Google Vertex adapter manages its own transport.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/ai/src/api/google-vertex.ts:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/aa10f97897326d18. Report an issue: GitHub.

Appendix: source

Thrown at packages/ai/src/api/google-vertex.ts:99

			content: [],
			api: "google-vertex" as Api,
			provider: model.provider,
			model: model.id,
			usage: {
				input: 0,
				output: 0,
				cacheRead: 0,
				cacheWrite: 0,
				totalTokens: 0,
				cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
			},
			stopReason: "pending",
			timestamp: Date.now(),
		};

		try {
			if (options?.fetch && options.fetch !== globalThis.fetch) {
				throw new Error("Custom fetch is not supported by the Google Vertex adapter");
			}
			const apiKey = resolveApiKey(options);
			// Create the client using either a Vertex API key, if provided, or ADC with project and location
			const client = apiKey
				? createClientWithApiKey(model, apiKey, options?.headers)
				: createClient(model, resolveProject(options), resolveLocation(options), options?.headers, options?.env);
			let params = buildParams(model, context, options);
			const nextParams = await options?.onPayload?.(params, model);
			if (nextParams !== undefined) {
				params = nextParams as GenerateContentParameters;
			}
			const googleStream = await retryGoogleRequest(() => client.models.generateContentStream(params), options);

			stream.push({ type: "start", partial: output });
			let currentBlock: TextContent | ThinkingContent | null = null;
			const blocks = output.content;
			const blockIndex = () => blocks.length - 1;
			for await (const chunk of googleStream) {

View on GitHub (pinned to 4af9d21d3b)