continuedev/continue · critical · Error
AskSage adapter: missing apiKey. Provide it in your configur
Error message
AskSage adapter: missing apiKey. Provide it in your configuration.
What it means
The AskSage adapter needs an API key to authenticate (either directly or exchanged for a session token with email). getSessionToken throws immediately when apiKey is falsy, meaning the adapter was constructed without a key. Check your config/environment for the AskSage API key.
Source
Thrown at packages/openai-adapters/src/apis/AskSage.ts:74
private email?: string;
private sessionTokenPromise: Promise<string> | null = null;
private tokenTimestamp: number = 0;
private fetchFn: typeof fetch;
constructor(private config: AskSageConfig) {
this.apiBase = config.apiBase ?? DEFAULT_API_URL;
this.userApiUrl = config.env?.userApiUrl ?? DEFAULT_USER_API_URL;
this.apiKey = config.apiKey;
this.email = config.env?.email;
this.fetchFn = customFetch(config.requestOptions);
}
/**
* Get session token from API key + email, or use API key directly
*/
private async getSessionToken(): Promise<string> {
if (!this.apiKey) {
throw new Error(
"AskSage adapter: missing apiKey. Provide it in your configuration.",
);
}
// If no email, use API key directly
if (!this.email || this.email.length === 0) {
return this.apiKey;
}
const url = this.userApiUrl.replace(/\/$/, "") + "/get-token-with-api-key";
const res = await this.fetchFn(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email: this.email, api_key: this.apiKey }),
});
const data = (await res.json()) as AskSageTokenResponse;
if (parseInt(String(data.status)) !== 200) {View on GitHub (pinned to 5522c6f44c)
Solutions
- Set the apiKey in the adapter constructor/config from your environment
- Verify the env var name and that it's loaded (print process.env keys in CI)
- Add a startup assertion that apiKey is non-empty before first use
Example fix
// before
const api = new AskSage({ apiKey: process.env.ASKSAGE_API_KEY /* undefined */ });
// after
const apiKey = process.env.ASKSAGE_API_KEY;
if (!apiKey) throw new Error('ASKSAGE_API_KEY not set');
const api = new AskSage({ apiKey }); Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.ASKSAGE_API_KEY) throw new Error('ASKSAGE_API_KEY not set'); Type guard
function hasAskSageCreds(cfg: { apiKey?: string; email?: string }): boolean {
return typeof cfg.apiKey === 'string' && cfg.apiKey.length > 0;
} Try / catch
try { await api.chatCompletionNonStream(body, signal); }
catch (e) { if (/missing apiKey/.test(String(e))) { failFast('Configure ASKSAGE_API_KEY'); } throw e; } Prevention
- Assert required env vars at startup, not on first request
- Use a config schema validator (zod) for adapter construction
When it happens
Trigger: Constructing the AskSage adapter with empty/undefined apiKey and invoking any chat completion (which calls getToken→getSessionToken).
Common situations: Missing ASKSAUGE_API_KEY-style env var; typo'd config key name; key loaded from a .env file that isn't being read in the current environment (CI, prod).
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
Related errors
- Error getting access token: + JSON.stringify(data)
- VertexAI in express mode (apiKey only) cannot be configured
- region and projectId are required for VertexAI (when not usi
- [Continue] Azure endpoint detected but API key appears to be
- URL is not defined in params
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/9c2c60791ac1e34e.
Report an issue: GitHub.