toeverything/AFFiNE · error · Error
OpenAI-compatible endpoints require OpenAI provider.
Error message
OpenAI-compatible endpoints require OpenAI provider.
What it means
A consistency guard in BYOK key normalization: workspace BYOK keys may declare a credential definition whose endpoint kind is 'openai_compatible', but such endpoints can only be used when the key's provider is exactly 'openai'. It fires when a key for a different provider (e.g. Anthropic) is paired with an openai_compatible endpoint definition; the faulting input is the key.provider vs key.definition.endpoint.kind combination.
Source
Thrown at packages/frontend/apps/electron/src/main/byok-storage/handlers.ts:170
)
);
}
function normalizeKey(
key: WorkspaceByokKeyInput,
existing?: WorkspaceByokKey,
defaultSortOrder = 0
): WorkspaceByokKey {
if (!allowedProviders.has(key.provider)) {
throw new Error('Unsupported BYOK provider.');
}
const credential = key.credential ?? existing?.credential;
const definition = key.definition ?? existing?.definition;
if (
definition?.endpoint.kind === 'openai_compatible' &&
key.provider !== 'openai'
) {
throw new Error('OpenAI-compatible endpoints require OpenAI provider.');
}
if (!key.id || !key.name || !credential || !isValidDefinition(definition)) {
throw new Error('Invalid BYOK key.');
}
return {
id: key.id,
provider: key.provider,
name: key.name,
description: hasOwnField(key, 'description')
? (key.description ?? null)
: (existing?.description ?? null),
credential,
definition,
sortOrder: hasOwnField(key, 'sortOrder')
? (key.sortOrder ?? defaultSortOrder)
: (existing?.sortOrder ?? defaultSortOrder),
enabled: hasOwnField(key, 'enabled')
? (key.enabled ?? true)View on GitHub (pinned to b4c8548c09)
Solutions
- Select the OpenAI provider when using an OpenAI-compatible custom endpoint.
- Do not combine a custom base URL with a non-OpenAI provider type.
- Change the provider setting to OpenAI and retry saving the key.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/frontend/apps/electron/src/main/byok-storage/handlers.ts:170 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/be4467c6df691e75.
Report an issue: GitHub.