{"record":{"id":"90ed99a39a888d7e","repo":"linshenkx/prompt-optimizer","slug":"chrome-built-in-ai-is-not-available-in-this-browse","errorCode":null,"errorMessage":"Chrome built-in AI is not available in this browser.","messagePattern":"Chrome built-in AI is not available in this browser\\.","errorType":"exception","errorClass":"RequestConfigError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/llm/adapters/chrome-built-in-adapter.ts","lineNumber":118,"sourceCode":"\n  protected getParameterDefinitions(_modelId: string): readonly ParameterDefinition[] {\n    return []\n  }\n\n  protected getDefaultParameterValues(_modelId: string): Record<string, unknown> {\n    return {}\n  }\n\n  private async createReadySession(initialPrompts?: ChromeLanguageModelPrompt[]) {\n    const status = await checkChromeBuiltInAvailability()\n    if (status.availability === 'downloadable') {\n      throw new RequestConfigError('Chrome built-in AI model is not downloaded. Open the model manager and click download to prepare it.')\n    }\n    if (status.availability === 'downloading') {\n      throw new RequestConfigError('Chrome built-in AI model is still downloading. Please wait for the download to finish.')\n    }\n    if (status.availability !== 'available') {\n      throw new RequestConfigError(status.error || 'Chrome built-in AI is not available in this browser.')\n    }\n\n    return await createChromeBuiltInSession(initialPrompts?.length ? { initialPrompts } : {})\n  }\n\n  private buildPrompt(messages: Message[]): {\n    initialPrompts?: ChromeLanguageModelPrompt[]\n    prompt: ChromeLanguageModelPromptInput\n  } {\n    const normalizedMessages = messages\n      .map((message) => ({\n        role: message.role,\n        content: message.content.trim()\n      }))\n      .filter((message) => message.content)\n    const promptIndex = this.findPromptMessageIndex(normalizedMessages)\n    const initialPrompts = normalizedMessages\n      .filter((_message, index) => index !== promptIndex)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/llm/adapters/chrome-built-in-adapter.ts#L100-L136","documentation":"Fallback error when the Chrome built-in AI availability status is neither 'available', 'downloadable', nor 'downloading' — e.g. 'unavailable' or the API is entirely missing. It uses status.error when present, otherwise this generic message.","triggerScenarios":"Calling session() in a non-Chrome browser, a Chrome build without the Prompt API, hardware/OS not supported, or the API disabled by enterprise policy.","commonSituations":"Firefox/Safari usage, stable Chrome where the flag is off, GPU/architecture requirements unmet, API surface removed in a newer Chrome canary.","solutions":["Verify you're on a Chrome version that ships the Prompt API (Dev/Canary or the enabled flag)","Enable chrome://flags#prompt-api-for-gemini-nano and relaunch","Check status.error from checkChromeBuiltInAvailability() for the precise reason","Provide a feature check before offering the Chrome built-in provider in the UI, and fall back to a cloud adapter"],"exampleFix":"// before\nconst s = await adapter.session()\n\n// after\nimport { checkChromeBuiltInAvailability } from '...'\nconst status = await checkChromeBuiltInAvailability()\nif (status.availability !== 'available') {\n  hideChromeBuiltInOption(status.error)\n} else {\n  const s = await adapter.session()\n}","handlingStrategy":"validation","validationCode":"const status = await checkChromeBuiltInAvailability()\nif (status.availability !== 'available') disableChromeBuiltInProvider(status.error)","typeGuard":"function isChromeAIAvailable(): boolean {\n  return typeof (window as any)?.ai?.languageModel?.create === 'function'\n}","tryCatchPattern":"try { const s = await adapter.session() }\ncatch (e) {\n  if (e instanceof RequestConfigError) return fallbackToCloudAdapter()\n  throw e\n}","preventionTips":["Feature-detect window.ai before listing the provider","Keep a cloud fallback provider configured","Show availability reason in provider UI"],"tags":["chrome","prompt-api","unsupported-browser","feature-detection"],"backgroundTag":"browser-api-unavailable","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}