GitbookIO/gitbook · error · Error

AI Search is not enabled for this site.

Error message

AI Search is not enabled for this site.

What it means

Thrown by the streamAskQuestion server action (AI Search 'ask' stream) when the site's AI mode does not enable AI search. Like the chat gate, it fetches server action site context and checks isAISearchEnabled(context.customization.ai.mode); any mode that doesn't include search causes the action to abort before opening the API stream.

Source

Thrown at packages/gitbook/src/components/Search/server-actions.tsx:61

export async function streamAskQuestion({
    asEmbeddable,
    question,
    session,
}: {
    asEmbeddable?: boolean;
    question: string;
    session: SiteInsightsSession;
}) {
    return traceErrorOnly('Search.streamAskQuestion', async () => {
        const responseStream = createStreamableValue<AskAnswerResult | undefined>();

        (async () => {
            const context = await fetchServerActionSiteContext(
                await getServerActionBaseContext({ isEmbeddable: asEmbeddable })
            );

            if (!isAISearchEnabled(context.customization.ai.mode)) {
                throw new Error('AI Search is not enabled for this site.');
            }

            const apiClient = await context.dataFetcher.api();

            const stream = apiClient.orgs.streamAskInSite(
                context.organizationId,
                context.site.id,
                {
                    question,
                    context: {
                        siteSpaceId: context.siteSpace.id,
                    },
                    scope: {
                        mode: 'default',
                        currentSiteSpace: context.siteSpace.id,
                    },
                    session,
                },

View on GitHub (pinned to db67585ee2)

Solutions

  1. Set the site/space AI customization to a mode that enables AI Search (or full AI) in GitBook settings.
  2. Gate the ask-in-search UI on the same isAISearchEnabled(customization.ai.mode) check so the action isn't called when disabled.
  3. Confirm org/site resolution (URL data / middleware) points at the site you configured.
  4. Refresh cache / redeploy so updated customization reaches the server action.

Example fix

// before
const stream = streamAskQuestion({ question });

// after
const aiSearchEnabled = isAISearchEnabled(customization.ai.mode);
const stream = aiSearchEnabled ? streamAskQuestion({ question }) : null;
Defensive patterns

Strategy: validation

Validate before calling

if (!isAISearchEnabled(customization.ai.mode)) {
    disableAskInSearchUI();
} else {
    streamAskQuestion({ question });
}

Type guard

const aiModeEnablesSearch = (
    mode: string | undefined
): mode is string => isAISearchEnabled(mode);

Try / catch

try {
    const stream = streamAskQuestion(input);
} catch (error) {
    if (error instanceof Error && error.message.includes('not enabled')) {
        showFeatureDisabledNotice();
        return;
    }
    throw error;
}

Prevention

When it happens

Trigger: Calling streamAskQuestion on a site whose customization.ai.mode is 'disabled'; a mode that enables only chat but not search (search-only vs chat-only mode mismatch); stale cached customization after the mode was changed; pointing at the wrong org/site so the fetched context has AI off.

Common situations: Site configured with chat-only AI while the UI still exposes the search 'ask' entry; AI turned off org-wide but an old client bundle still calls the action; embedding search on sites where AI was never enabled.

Related errors


AI-assisted analysis of GitbookIO/gitbook@db67585ee2 (2026-08-28). Data as JSON: /api/errors/cc007dbb622dbc09. Report an issue: GitHub.