chatboxai/chatbox · error · Error
Missing token for rerank provider: ${providerId}
Error message
Missing token for rerank provider: ${providerId} What it means
Thrown when constructing the CohereClient for reranking if no auth token could be obtained: for providerId==='chatbox-ai' it requires store.get('settings.licenseKey'); for any other provider it requires providerSetting.apiKey. The model string parsed successfully ([93] passed) but the credential is missing.
Source
Thrown at src/main/session-attachment-rag/model-providers.ts:98
const settings = getSettings()
const { providerSetting, formattedApiHost } = getProviderSettings(
{
...settings,
provider: providerId,
modelId,
},
settings
)
let apiHost = formattedApiHost
let token = providerSetting.apiKey
if (providerId === 'chatbox-ai') {
apiHost = getChatboxAPIOrigin()
token = store.get('settings.licenseKey')
}
if (!token) {
throw new Error(`Missing token for rerank provider: ${providerId}`)
}
const client = new CohereClient({
environment: apiHost,
token,
})
return { client, modelId }
} catch (error) {
log.error(`[MODEL] Failed to resolve session attachment rerank provider: ${modelString}`, error)
sentry.withScope((scope) => {
scope.setTag('component', 'session-attachment-rag-model')
scope.setTag('operation', 'get_rerank_provider')
scope.setExtra('rerankModel', modelString)
sentry.captureException(error)
})
throw error
}
},View on GitHub (pinned to 81571269ad)
Solutions
- For chatbox-ai rerank, activate a license (settings.licenseKey).
- For third-party rerank providers, fill in the provider's apiKey in settings before enabling reranking.
- Disable reranking (clear the model string) until credentials are configured.
- Validate apiKey presence at settings-save time so the UI blocks an invalid rerank config.
Example fix
// before
if (!token) throw new Error(`Missing token for rerank provider: ${providerId}`)
// caller pre-check
if (providerId === 'chatbox-ai' ? !store.get('settings.licenseKey') : !providerSetting.apiKey) {
warnUser(`Add credentials for ${providerId} to enable reranking`)
return null
} Defensive patterns
Strategy: validation
Validate before calling
const parsed = parseKnowledgeBaseModelString(modelString)
if (parsed) {
const token = parsed.providerId === 'chatbox-ai' ? store.get('settings.licenseKey') : getProviderSettings({...settings, provider: parsed.providerId, modelId: parsed.modelId}, settings).providerSetting.apiKey
if (!token) { warn(`Add credentials for ${parsed.providerId}`); return null }
} Type guard
function isMissingRerankToken(e: unknown): e is Error { return e instanceof Error && e.message.startsWith('Missing token for rerank provider:') } Try / catch
try { return await getSessionAttachmentRerankProvider(modelString) } catch (e) { if (isMissingRerankToken(e)) { ui.promptAddCredentials(e.message); return null } throw e } Prevention
- Require credentials when saving a rerank model.
- For chatbox-ai rerank, keep the license active.
- Disable reranking when its credentials are removed.
When it happens
Trigger: Rerank model set to a third-party provider whose apiKey is empty in provider settings; or rerank model set to 'chatbox-ai:...' while settings.licenseKey is absent/cleared. The CohereClient constructor would otherwise be called with token=undefined.
Common situations: User configured a rerank model but never entered the provider's API key; license expired for chatbox-ai rerank; provider settings reset; switching providers without migrating credentials.
Related errors
- Invalid rerank model format: ${modelString}
- session attachment embedding model not set
- No content extracted from file
- Failed to search knowledge base (id: ${kbId}). Please try ag
- Session attachment ${id} not found
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/1fed67e8b0cae147.
Report an issue: GitHub.