vercel/ai · error · Error

Failed to load Google credentials: ${error.message}

Error message

Failed to load Google credentials: ${error.message}

What it means

Error "Failed to load Google credentials: ${error.message}" thrown in vercel/ai.

Source

Thrown at packages/google-vertex/src/edge/google-vertex-auth-edge.ts:50

      clientEmail: loadSetting({
        settingValue: undefined,
        settingName: 'clientEmail',
        environmentVariableName: 'GOOGLE_CLIENT_EMAIL',
        description: 'Google client email',
      }),
      privateKey: loadSetting({
        settingValue: undefined,
        settingName: 'privateKey',
        environmentVariableName: 'GOOGLE_PRIVATE_KEY',
        description: 'Google private key',
      }),
      privateKeyId: loadOptionalSetting({
        settingValue: undefined,
        environmentVariableName: 'GOOGLE_PRIVATE_KEY_ID',
      }),
    };
  } catch (error: any) {
    throw new Error(`Failed to load Google credentials: ${error.message}`);
  }
};

// Convert a string to base64url
const base64url = (str: string) => {
  return btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
};
const importPrivateKey = async (pemKey: string) => {
  const pemHeader = '-----BEGIN PRIVATE KEY-----';
  const pemFooter = '-----END PRIVATE KEY-----';

  // Remove header, footer, and any whitespace/newlines
  const pemContents = pemKey
    .replace(pemHeader, '')
    .replace(pemFooter, '')
    .replace(/\s/g, '');

  // Decode base64 to binary

View on GitHub (pinned to 69428b1f8b)

When it happens

Trigger: Thrown at packages/google-vertex/src/edge/google-vertex-auth-edge.ts:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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