From 2b77d1994e1fcd2411e4ce839f44f8f714ce9e7f Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 12 Sep 2026 16:17:02 +0100 Subject: [PATCH] feat(docs): use the docs agent key by default The widget now ships with the docs agent's embed token, so the site works without any environment configuration. NEXT_PUBLIC_DOCSGPT_API_KEY still overrides it for staging. The key is public either way. NEXT_PUBLIC_* is inlined at build time, so it lands in the client bundle whichever way it is supplied, and every documented DocsGPT embed carries its key in the page. Abuse is bounded by the agent's daily request and token limits, enforced by check_usage on the answer and stream routes. --- docs/components/DocsGPTChatWidget.jsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/components/DocsGPTChatWidget.jsx b/docs/components/DocsGPTChatWidget.jsx index 9f688ac0..785f461b 100644 --- a/docs/components/DocsGPTChatWidget.jsx +++ b/docs/components/DocsGPTChatWidget.jsx @@ -13,7 +13,15 @@ const DocsGPTWidget = dynamic( const apiHost = process.env.NEXT_PUBLIC_DOCSGPT_API_HOST || 'https://gptcloud.arc53.com'; -const apiKey = process.env.NEXT_PUBLIC_DOCSGPT_API_KEY; + +// Public embed token for the docs agent, the same way every documented +// DocsGPT embed carries one. It reaches the browser either way, since +// NEXT_PUBLIC_* is inlined at build time. Abuse is capped by the agent's +// daily request and token limits, so rotate the agent key if it needs +// revoking. NEXT_PUBLIC_DOCSGPT_API_KEY overrides it for staging. +const apiKey = + process.env.NEXT_PUBLIC_DOCSGPT_API_KEY || + '0e714713-1bc6-4aae-a595-aa0b3bf317b3'; export function DocsGPTChatWidget() { const { resolvedTheme } = useTheme(); @@ -21,9 +29,9 @@ export function DocsGPTChatWidget() { useEffect(() => setMounted(true), []); - // No key means no widget. Falling through would silently use the demo key - // baked into the package default. - if (!apiKey || !mounted) return null; + // Hold off until next-themes has resolved, so the widget does not flash + // the wrong theme on first paint. + if (!mounted) return null; return (