ruvnet/ruflo · error · AuthenticationError
AUTHENTICATION
AUTHENTICATION
Error message
Google API key is required
What it means
GoogleProvider.doInitialize() runs during provider.initialize(); if config.apiKey is falsy it throws AuthenticationError before any HTTP call. The key is appended as ?key=... on every request to https://generativelanguage.googleapis.com/v1beta (or config.apiUrl).
Source
Thrown at v3/@claude-flow/providers/src/google-provider.ts:129
currency: 'USD',
},
'gemini-pro': {
promptCostPer1k: 0.0005,
completionCostPer1k: 0.0015,
currency: 'USD',
},
},
};
private baseUrl: string = 'https://generativelanguage.googleapis.com/v1beta';
constructor(options: BaseProviderOptions) {
super(options);
}
protected async doInitialize(): Promise<void> {
if (!this.config.apiKey) {
throw new AuthenticationError('Google API key is required', 'google');
}
this.baseUrl = this.config.apiUrl || 'https://generativelanguage.googleapis.com/v1beta';
}
protected async doComplete(request: LLMRequest): Promise<LLMResponse> {
const geminiRequest = this.buildRequest(request);
const model = request.model || this.config.model;
const url = `${this.baseUrl}/models/${model}:generateContent?key=${this.config.apiKey}`;
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), this.config.timeout || 60000);
try {
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(geminiRequest),View on GitHub (pinned to fa13ee4ad6)
Solutions
- Create a key in Google AI Studio and pass it: config: { apiKey: process.env.GOOGLE_API_KEY, model: 'gemini-2.0-flash' }
- Export the env var in the runtime environment and verify with printenv GOOGLE_API_KEY
- Add a startup validator for required env vars so the failure is explicit and early
Example fix
// before
const provider = new GoogleProvider({
name: 'google',
config: { model: 'gemini-2.0-flash' }, // no apiKey -> AuthenticationError at initialize()
});
// after
const provider = new GoogleProvider({
name: 'google',
config: { apiKey: process.env.GOOGLE_API_KEY!, model: 'gemini-2.0-flash' },
}); Defensive patterns
Strategy: validation
Validate before calling
const apiKey = process.env.GOOGLE_API_KEY;
if (!apiKey) {
throw new Error('GOOGLE_API_KEY is not set - cannot create google provider');
}
const provider = new GoogleProvider({ name: 'google', config: { apiKey, model: 'gemini-2.0-flash' } }); Type guard
import { AuthenticationError } from './types.js';
function isAuthError(e: unknown): e is AuthenticationError {
return e instanceof AuthenticationError;
} Try / catch
try {
await provider.initialize();
} catch (e) {
if (e instanceof AuthenticationError) {
throw new Error(`google credentials missing or invalid: ${e.message}`); // fail fast, no retry
}
throw e;
} Prevention
- Assert GOOGLE_API_KEY at startup before constructing providers
- Remember this provider needs an AI Studio API key, not a Vertex service account
- Centralize required-env-var checks in a config validator shared by all providers
When it happens
Trigger: new GoogleProvider({ name: 'google', config: { model: 'gemini-2.0-flash' } }) with no apiKey, or apiKey: process.env.GOOGLE_API_KEY when the variable is unset.
Common situations: GOOGLE_API_KEY (or GEMINI_API_KEY) not exported in CI/containers; .env not loaded; a Vertex AI service-account setup assumed where this provider requires an AI Studio API key instead.
Related errors
- AUTHENTICATION
- AUTHENTICATION
- Config manager is disabled
- Model is required for ${this.name} provider
- RATE_LIMIT
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/f19054c27f62deaa.
Report an issue: GitHub.