vercel/ai · error · Error

Google Vertex Chirp speech models do not support Express Mod

Error message

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

What it means

createSpeechModel throws this Error when a model id starting with 'chirp' (Vertex Chirp TTS) is requested under Express Mode API-key authentication. Chirp speech models require standard Google Cloud credential headers, so the provider refuses to build the model with an apiKey present.

Source

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

  const createEmbeddingModel = (modelId: GoogleVertexEmbeddingModelId) =>
    new GoogleVertexEmbeddingModel(modelId, createConfig('embedding'));

  const createImageModel = (modelId: GoogleVertexImageModelId) =>
    new GoogleVertexImageModel(modelId, {
      ...createConfig('image'),
      generateId: options.generateId ?? generateId,
    });

  const createVideoModel = (modelId: GoogleVertexVideoModelId) =>
    new GoogleVertexVideoModel(modelId, {
      ...createConfig('video'),
      generateId: options.generateId ?? generateId,
    });

  const createSpeechModel = (modelId: GoogleVertexSpeechModelId) => {
    if (modelId.startsWith('chirp')) {
      if (apiKey) {
        throw new Error(
          'Google Vertex Chirp speech models do not support Express Mode API keys. Use standard Google Cloud credentials instead.',
        );
      }

      const config = createConfig('speech');
      return new GoogleVertexCloudTTSSpeechModel(modelId, {
        provider: config.provider,
        headers: config.headers,
        fetch: config.fetch,
      });
    }

    return new GoogleSpeechModel(modelId, createConfig('speech'));
  };

  // Cloud Speech-to-Text reuses the Vertex auth headers from createConfig, but
  // targets the Speech-to-Text API.
  const createTranscriptionModel = (

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Switch the provider to service-account/ADC authentication and remove the apiKey.
  2. Use a non-chirp Vertex speech model that supports API-key auth if key-based auth must stay.
  3. Instantiate a separate provider without apiKey for speech models.

Example fix

// before
const vertex = createGoogleVertex({ apiKey: process.env.GOOGLE_VERTEX_API_KEY });
const speech = vertex.speech('chirp-3-hd');
// after
const vertex = createGoogleVertex({ project: 'my-project', location: 'us-central1' });
const speech = vertex.speech('chirp-3-hd');
Defensive patterns

Strategy: validation

Validate before calling

if (apiKey && modelId.startsWith('chirp')) {
  throw new Error('Chirp speech models require service-account auth, not an Express Mode API key.');
}

Try / catch

try {
  const model = vertex.speech(modelId);
} catch (e) {
  if (e instanceof Error && e.message.includes('Chirp speech models do not support Express Mode')) {
    // switch provider instance to ADC credentials
  } else throw e;
}

Prevention

When it happens

Trigger: vertex.speech('chirp-3-hd') (any id with the 'chirp' prefix) while createGoogleVertex received `apiKey` / GOOGLE_VERTEX_API_KEY is set — the nested `if (apiKey)` inside the chirp branch throws.

Common situations: Adding text-to-speech to an app already configured with an Express Mode API key for chat; assuming one auth method works for every Vertex capability; CI with GOOGLE_VERTEX_API_KEY exported globally.

Related errors


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