Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(hobby): support BYO AI keys and gate cloud-only replay summaries (#61823)

Paul D'Ambrac72ad44720f0
diff --git a/bin/deploy-hobby b/bin/deploy-hobby
index 06f9df546c51..fadaa25f0d1d 100755
--- a/bin/deploy-hobby
+++ b/bin/deploy-hobby
@@ -132,6 +132,26 @@ fi
if [ -f .env ]; then
echo "Existing .env found, preserving configuration"
else
+ # Optional AI provider keys. PostHog's AI features (the Max assistant, SQL/regex assist)
+ # run on your own LLM provider key. These are safe to leave blank now — you can add them
+ # to .env later and apply with bin/upgrade-hobby. An env var set before running this
+ # script (e.g. ANTHROPIC_API_KEY=... ./deploy-hobby) is used as-is without prompting.
+ # Only prompt on an interactive terminal — a piped/non-interactive install
+ # (CI, `curl | bash`) skips the prompts and relies on the env vars instead.
+ # Read silently (-s) — these are secrets and shouldn't echo to the terminal/scrollback.
+ if [ -t 0 ] && [ -z "$ANTHROPIC_API_KEY" ]; then
+ echo ""
+ echo "PostHog AI runs on an Anthropic API key."
+ echo "Enter one to enable PostHog AI now, or leave blank to skip (you can add it later):"
+ read -rs ANTHROPIC_API_KEY
+ echo
+ fi
+ if [ -t 0 ] && [ -z "$OPENAI_API_KEY" ]; then
+ echo "Optionally enter an OpenAI API key to enable SQL and regex AI assist, or leave blank to skip:"
+ read -rs OPENAI_API_KEY
+ echo
+ fi
+
POSTHOG_SECRET=$(head -c 28 /dev/urandom | sha224sum -b | head -c 56)
ENCRYPTION_SALT_KEYS=$(openssl rand -hex 16)
cat > .env <<EOF
@@ -144,6 +164,13 @@ CADDY_TLS_BLOCK=$TLS_BLOCK
CADDY_HOST="$DOMAIN, http://, https://"
POSTHOG_APP_TAG=$POSTHOG_APP_TAG
EOF
+ # Only persist AI keys that were actually provided — skip writing a blank
+ # ANTHROPIC_API_KEY= line that would just clutter .env with an empty assignment.
+ # (A blank value is harmless either way: bin/upgrade-hobby greps for
+ # ^ANTHROPIC_API_KEY=.+, so an empty value counts as missing and the user is
+ # still offered the key on the next upgrade.)
+ [ -n "$ANTHROPIC_API_KEY" ] && echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" >> .env
+ [ -n "$OPENAI_API_KEY" ] && echo "OPENAI_API_KEY=$OPENAI_API_KEY" >> .env
fi
# Download GeoLite2-City.mmdb if it doesn't exist
diff --git a/bin/upgrade-hobby b/bin/upgrade-hobby
index ef92b84257b1..0f54506fdb68 100755
--- a/bin/upgrade-hobby
+++ b/bin/upgrade-hobby
@@ -110,6 +110,31 @@ else
fi
fi
+# PostHog's AI features (the Max assistant, SQL/regex assist) run on your own LLM provider key.
+# If none is configured yet, offer to add one. Existing keys are never touched — we only append
+# when the key is absent, so this is safe to run on every upgrade.
+# Only prompt on an interactive terminal so a non-interactive upgrade doesn't block on stdin.
+# Match `KEY=<value>` (note the trailing `.+`): a blank `KEY=` counts as missing, so a user who
+# skipped the key at install still gets prompted. Read silently (-s) — these are secrets.
+if [ -t 0 ] && ! grep -qE "^ANTHROPIC_API_KEY=.+" .env; then
+ echo ""
+ echo "PostHog AI runs on an Anthropic API key, which isn't configured yet."
+ read -rsp "Enter an Anthropic API key to enable PostHog AI (leave blank to skip): " ANTHROPIC_API_KEY_INPUT
+ echo
+ if [ -n "$ANTHROPIC_API_KEY_INPUT" ]; then
+ echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY_INPUT" >> .env
+ echo "Added ANTHROPIC_API_KEY to .env file"
+ fi
+fi
+if [ -t 0 ] && ! grep -qE "^OPENAI_API_KEY=.+" .env; then
+ read -rsp "Enter an OpenAI API key to enable SQL and regex AI assist (leave blank to skip): " OPENAI_API_KEY_INPUT
+ echo
+ if [ -n "$OPENAI_API_KEY_INPUT" ]; then
+ echo "OPENAI_API_KEY=$OPENAI_API_KEY_INPUT" >> .env
+ echo "Added OPENAI_API_KEY to .env file"
+ fi
+fi
+
# Check if session recording storage migration marker exists
if ! grep -q "SESSION_RECORDING_STORAGE_MIGRATED_TO_SEAWEEDFS" .env; then
echo ""
diff --git a/docker-compose.hobby.yml b/docker-compose.hobby.yml
index e774221ffde0..004897dd4c3d 100644
--- a/docker-compose.hobby.yml
+++ b/docker-compose.hobby.yml
@@ -103,6 +103,9 @@ services:
PERSONHOG_ADDR: 'personhog-router:50052'
PERSONHOG_ENABLED: 'true'
PERSONHOG_ROLLOUT_PERCENTAGE: '100'
+ # AI provider keys for PostHog's AI features. Blank unless set in .env.
+ ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
+ OPENAI_API_KEY: ${OPENAI_API_KEY:-}
image: $REGISTRY_URL:$POSTHOG_APP_TAG
depends_on:
db:
@@ -148,6 +151,9 @@ services:
PERSONHOG_ADDR: 'personhog-router:50052'
PERSONHOG_ENABLED: 'true'
PERSONHOG_ROLLOUT_PERCENTAGE: '100'
+ # AI provider keys for PostHog's AI features. Blank unless set in .env.
+ ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
+ OPENAI_API_KEY: ${OPENAI_API_KEY:-}
depends_on:
- db
- redis7
@@ -389,6 +395,9 @@ services:
environment:
SITE_URL: https://$DOMAIN
SECRET_KEY: $POSTHOG_SECRET
+ # AI provider keys for PostHog's AI features. Blank unless set in .env.
+ ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
+ OPENAI_API_KEY: ${OPENAI_API_KEY:-}
depends_on:
- db
- redis7
diff --git a/frontend/src/scenes/max/Max.tsx b/frontend/src/scenes/max/Max.tsx
index e0951c955076..c783c182a438 100644
--- a/frontend/src/scenes/max/Max.tsx
+++ b/frontend/src/scenes/max/Max.tsx
@@ -29,6 +29,7 @@ import { SidePanelTab } from '~/types'
import { AiFirstMaxInstance } from './components/AiFirstMaxInstance'
import { AnimatedBackButton } from './components/AnimatedBackButton'
+import { MaxNotConfigured } from './components/MaxNotConfigured'
import { SidebarQuestionInput } from './components/SidebarQuestionInput'
import { SidebarQuestionInputWithSuggestions } from './components/SidebarQuestionInputWithSuggestions'
import { ThreadAutoScroller } from './components/ThreadAutoScroller'
@@ -95,6 +96,7 @@ export const MaxInstance = React.memo(function MaxInstance({ sidePanel, tabId }:
} = useValues(maxLogic(logicProps))
const { startNewConversation, goBack } = useActions(maxLogic(logicProps))
const { openSidePanelMax } = useActions(maxGlobalLogic)
+ const { isMaxAvailable } = useValues(maxGlobalLogic)
const threadProps: MaxThreadLogicProps = {
...logicProps,
@@ -104,7 +106,9 @@ export const MaxInstance = React.memo(function MaxInstance({ sidePanel, tabId }:
const { closeSidePanel } = useActions(sidePanelLogic)
- const content = (
+ const content = !isMaxAvailable ? (
+ <MaxNotConfigured />
+ ) : (
<BindLogic logic={maxLogic} props={logicProps}>
<BindLogic logic={maxThreadLogic} props={threadProps}>
{conversationHistoryVisible ? (
diff --git a/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx b/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx
index 598397b73499..f5731ba126d6 100644
--- a/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx
+++ b/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx
@@ -15,6 +15,7 @@ import { maxGlobalLogic } from '../maxGlobalLogic'
import { maxLogic } from '../maxLogic'
import { MaxThreadLogicProps, maxThreadLogic } from '../maxThreadLogic'
import { Thread } from '../Thread'
+import { MaxNotConfigured } from './MaxNotConfigured'
import { SidebarQuestionInputWithSuggestions } from './SidebarQuestionInputWithSuggestions'
import { ThreadAutoScroller } from './ThreadAutoScroller'
@@ -91,6 +92,7 @@ interface AiFirstMaxInstanceProps {
export function AiFirstMaxInstance({ tabId }: AiFirstMaxInstanceProps): JSX.Element {
const { threadVisible, threadLogicKey, conversation, conversationId } = useValues(maxLogic({ panelId: tabId }))
const { startNewConversation } = useActions(maxLogic({ panelId: tabId }))
+ const { isMaxAvailable } = useValues(maxGlobalLogic)
const threadProps: MaxThreadLogicProps = {
panelId: tabId,
@@ -104,12 +106,16 @@ export function AiFirstMaxInstance({ tabId }: AiFirstMaxInstanceProps): JSX.Elem
<BindLogic logic={maxThreadLogic} props={threadProps}>
<div className="flex flex-col grow overflow-hidden">
<ChatHeader conversationId={conversationId} tabId={tabId} />
- <ChatArea
- threadVisible={threadVisible}
- conversationId={conversationId}
- conversation={conversation}
- onStartNewConversation={startNewConversation}
- />
+ {isMaxAvailable ? (
+ <ChatArea
+ threadVisible={threadVisible}
+ conversationId={conversationId}
+ conversation={conversation}
+ onStartNewConversation={startNewConversation}
+ />
+ ) : (
+ <MaxNotConfigured />
+ )}
</div>
</BindLogic>
</BindLogic>
diff --git a/frontend/src/scenes/max/components/MaxNotConfigured.tsx b/frontend/src/scenes/max/components/MaxNotConfigured.tsx
new file mode 100644
index 000000000000..219b691e0e8d
--- /dev/null
+++ b/frontend/src/scenes/max/components/MaxNotConfigured.tsx
@@ -0,0 +1,45 @@
+import { IconLock } from '@posthog/icons'
+import { Link } from '@posthog/lemon-ui'
+
+import { Logomark } from 'lib/brand/Logomark'
+import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
+
+/**
+ * Shown when PostHog AI (Max) is rendered on a self-hosted instance with no LLM provider key
+ * configured. Max runs on Anthropic, so without ANTHROPIC_API_KEY it would otherwise fail at
+ * call time — here we tell the user how to enable it instead.
+ */
+export function MaxNotConfigured(): JSX.Element {
+ return (
+ <div className="flex flex-col items-center justify-center text-center grow gap-4 px-4 py-8 max-w-prose mx-auto">
+ <div className="flex *:h-full *:w-12 p-2 select-none opacity-60">
+ <Logomark />
+ </div>
+ <div>
+ <h2 className="text-xl font-bold mb-2 flex items-center justify-center gap-2">
+ <IconLock />
+ PostHog AI isn't set up yet
+ </h2>
+ <p className="text-sm text-tertiary text-pretty mb-0">
+ PostHog AI runs on your own LLM provider key. Set <code>ANTHROPIC_API_KEY</code> for this instance
+ and restart PostHog to start chatting.
+ </p>
+ </div>
+ <CodeSnippet language={Language.Bash} className="w-full text-left">
+ ANTHROPIC_API_KEY=sk-ant-...
+ </CodeSnippet>
+ <p className="text-sm text-tertiary text-pretty mb-0">
+ On a hobby deploy, add the key to your <code>.env</code> file and run <code>./bin/upgrade-hobby</code>,
+ or set it during install.{' '}
+ <Link
+ to="https://posthog.com/docs/self-host/configure/environment-variables?utm_medium=in-product&utm_campaign=max-not-configured"
+ target="_blank"
+ targetBlankIcon
+ data-attr="max-not-configured-configure-key"
+ >
+ Configuring environment variables
+ </Link>
+ </p>
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/max/maxGlobalLogic.test.ts b/frontend/src/scenes/max/maxGlobalLogic.test.ts
index 1852b9904018..e5fe7d7ccc3e 100644
--- a/frontend/src/scenes/max/maxGlobalLogic.test.ts
+++ b/frontend/src/scenes/max/maxGlobalLogic.test.ts
@@ -1,6 +1,8 @@
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -68,6 +70,27 @@ describe('maxGlobalLogic', () => {
)
})
+ describe('isMaxAvailable selector', () => {
+ it.each([
+ { realm: 'a not-yet-loaded preflight', preflight: null, expected: true },
+ { realm: 'PostHog Cloud', preflight: { cloud: true }, expected: true },
+ {
+ realm: 'self-hosted with an Anthropic key',
+ preflight: { cloud: false, is_debug: false, anthropic_available: true },
+ expected: true,
+ },
+ {
+ realm: 'self-hosted without a key',
+ preflight: { cloud: false, is_debug: false, anthropic_available: false },
+ expected: false,
+ },
+ ])('is $expected on $realm', async ({ preflight, expected }) => {
+ preflightLogic.actions.loadPreflightSuccess(preflight as any)
+
+ await expectLogic(logic).toMatchValues({ isMaxAvailable: expected })
+ })
+ })
+
describe('editInsightToolRegistered selector', () => {
it('returns true when contextual create_insight tool is registered', async () => {
// Initially should be false (only static tool available)
diff --git a/frontend/src/scenes/max/maxGlobalLogic.tsx b/frontend/src/scenes/max/maxGlobalLogic.tsx
index 28693d1352b3..83aa58d10598 100644
--- a/frontend/src/scenes/max/maxGlobalLogic.tsx
+++ b/frontend/src/scenes/max/maxGlobalLogic.tsx
@@ -9,6 +9,7 @@ import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { newInternalTab } from 'lib/utils/newInternalTab'
import { organizationLogic } from 'scenes/organizationLogic'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { sceneLogic } from 'scenes/sceneLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -89,6 +90,8 @@ export const maxGlobalLogic = kea<maxGlobalLogicType>([
['featureFlags'],
sidePanelStateLogic,
['sidePanelOpen', 'selectedTab'],
+ preflightLogic,
+ ['preflight', 'isCloudOrDev'],
],
actions: [router, ['locationChanged'], sidePanelStateLogic, ['openSidePanel']],
})),
@@ -231,6 +234,14 @@ export const maxGlobalLogic = kea<maxGlobalLogicType>([
(s) => [s.currentOrganization],
(currentOrganization): boolean => !!currentOrganization?.is_ai_data_processing_approved,
],
+ // On Cloud/dev a provider key is always present. On a self-hosted (hobby) instance Max only
+ // works once ANTHROPIC_API_KEY is configured, so we surface a "set the key" state instead.
+ // Treat a not-yet-loaded preflight (null) as available so the empty-state doesn't flash
+ // before preflight resolves — once loaded we gate on cloud/dev or the key being present.
+ isMaxAvailable: [
+ (s) => [s.isCloudOrDev, s.preflight],
+ (isCloudOrDev, preflight): boolean => !preflight || !!isCloudOrDev || !!preflight.anthropic_available,
+ ],
dataProcessingApprovalDisabledReason: [
(s) => [s.currentOrganization],
(currentOrganization): string | null =>
diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.test.ts b/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.test.ts
index 5b86c2ab14eb..f54c602be897 100644
--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.test.ts
+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.test.ts
@@ -2,6 +2,7 @@ import { MOCK_TEAM_ID } from 'lib/api.mock'
import { expectLogic } from 'kea-test-utils'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SessionSummaryContent } from 'scenes/session-recordings/player/player-meta/types'
import { useMocks } from '~/mocks/jest'
@@ -249,11 +250,16 @@ describe('notebookNodePersonFeedLogic', () => {
})
describe('canSummarize selector', () => {
- it('returns true', async () => {
+ // AI session summaries are PostHog Cloud only, so the block is gated on isCloudOrDev.
+ it.each([
+ { realm: 'PostHog Cloud', preflight: { cloud: true }, expected: true },
+ { realm: 'self-hosted', preflight: { cloud: false, is_debug: false }, expected: false },
+ ])('is $expected on $realm', async ({ preflight, expected }) => {
logic = notebookNodePersonFeedLogic({ personId: 'test-person-123' })
logic.mount()
+ preflightLogic.actions.loadPreflightSuccess(preflight as any)
- expect(logic.values.canSummarize).toBe(true)
+ expect(logic.values.canSummarize).toBe(expected)
})
})
diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts b/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts
index 6916e1780772..8b66604efd14 100644
--- a/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts
+++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodePersonFeed/notebookNodePersonFeedLogic.ts
@@ -1,8 +1,9 @@
-import { actions, afterMount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { pluralize } from 'lib/utils'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SessionSummaryContent } from 'scenes/session-recordings/player/player-meta/types'
import { performQuery } from '~/queries/query'
@@ -22,6 +23,10 @@ export const notebookNodePersonFeedLogic = kea<notebookNodePersonFeedLogicType>(
path((key) => ['scenes', 'notebooks', 'Notebook', 'Nodes', 'notebookNodePersonFeedLogic', key]),
key(({ personId }) => personId),
+ connect(() => ({
+ values: [preflightLogic, ['isCloudOrDev']],
+ })),
+
actions({
summarizeSessions: true,
summarizeSession: (sessionId: string) => ({ sessionId }),
@@ -90,7 +95,8 @@ export const notebookNodePersonFeedLogic = kea<notebookNodePersonFeedLogicType>(
})),
selectors({
- canSummarize: [() => [], () => true],
+ // AI session summaries are PostHog Cloud only, so hide the whole block on self-hosted.
+ canSummarize: [(s) => [s.isCloudOrDev], (isCloudOrDev): boolean => !!isCloudOrDev],
numSessionsWithRecording: [
(s) => [s.sessionIdsWithRecording],
(sessionIdsWithRecording) => sessionIdsWithRecording.length,
diff --git a/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx b/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx
index d37b98c9199f..743559fdb443 100644
--- a/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx
+++ b/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx
@@ -11,6 +11,7 @@ import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerL
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
import { sessionRecordingEventUsageLogic } from '../sessionRecordingEventUsageLogic'
@@ -73,6 +74,7 @@ function formatSessionSummary(summary: SessionSummaryContent, sessionId: string)
export function PlayerSummaryDock(): JSX.Element | null {
const { featureFlags } = useValues(featureFlagLogic)
+ const { isCloudOrDev } = useValues(preflightLogic)
const { logicProps, sessionRecordingId, sessionPlayerData } = useValues(sessionRecordingPlayerLogic)
const {
sessionSummary,
@@ -157,6 +159,18 @@ export function PlayerSummaryDock(): JSX.Element | null {
>
Cancel summarization
</LemonButton>
+ ) : !isCloudOrDev ? (
+ // AI session summaries run on PostHog Cloud only — show the standard upsell.
+ <LemonButton
+ size="small"
+ type="secondary"
+ icon={<IconMagicWand />}
+ to={urls.moveToPostHogCloud()}
+ tooltip="AI session summaries are a PostHog Cloud feature (separate from PostHog AI, which runs on your own provider key)"
+ data-attr="session-summary-move-to-cloud"
+ >
+ Summarize with PostHog Cloud
+ </LemonButton>
) : (
<LemonButton
size="small"
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx
index 3476160f04ad..fec135ae9ab8 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx
@@ -26,6 +26,7 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { colonDelimitedDuration } from 'lib/utils'
import { DraggableToNotebook } from 'scenes/notebooks/AddToNotebook/DraggableToNotebook'
import { asDisplay } from 'scenes/persons/person-utils'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SimpleTimeLabel } from 'scenes/session-recordings/components/SimpleTimeLabel'
import { countryTitleFrom } from 'scenes/session-recordings/player/player-meta/playerMetaLogic'
import { TimestampFormat, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'
@@ -275,6 +276,7 @@ const RecordingSummaryIcon = memo(function RecordingSummaryIcon({
}): JSX.Element | null {
const { loadingBySessionId, summaryBySessionId } = useValues(sessionSummaryProgressLogic)
const { startSummarization } = useActions(sessionSummaryProgressLogic)
+ const { isCloudOrDev } = useValues(preflightLogic)
const isSummarizing = !!loadingBySessionId[recording.id]
const summaryOutcome = selectOutcome([summaryBySessionId[recording.id]?.session_outcome, recording.summary_outcome])
@@ -303,6 +305,11 @@ const RecordingSummaryIcon = memo(function RecordingSummaryIcon({
</Tooltip>
)
}
+ // AI summaries are PostHog Cloud only — hide the per-row trigger on self-hosted. The upsell
+ // lives on the replay page dock (PlayerSummaryDock) rather than repeating per list row.
+ if (!isCloudOrDev) {
+ return null
+ }
return (
<LemonButton
type="tertiary"
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 9fe56060c0fd..168868661547 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -4397,6 +4397,7 @@ export interface PreflightStatus {
is_test?: boolean
licensed_users_available?: number | null
openai_available?: boolean
+ anthropic_available?: boolean
site_url?: string
instance_preferences?: InstancePreferencesInterface
buffer_conversion_seconds?: number
diff --git a/posthog/api/test/test_preflight.py b/posthog/api/test/test_preflight.py
index f089e37055f8..8cb2afcd0e41 100644
--- a/posthog/api/test/test_preflight.py
+++ b/posthog/api/test/test_preflight.py
@@ -69,6 +69,7 @@ class TestPreflight(APIBaseTest, QueryMatchingTest):
# we calculate this here because otherwise it is non-deterministic when running locally
# it can be overridden in tests by passing in options
"openai_available": bool(os.environ.get("OPENAI_API_KEY")),
+ "anthropic_available": bool(os.environ.get("ANTHROPIC_API_KEY")),
"is_test": True,
**options,
}
diff --git a/posthog/views.py b/posthog/views.py
index 87f53a65ddda..31183d778018 100644
--- a/posthog/views.py
+++ b/posthog/views.py
@@ -242,6 +242,9 @@ def preflight_check(request: HttpRequest) -> JsonResponse:
if not in_cloud
else None,
"openai_available": bool(os.environ.get("OPENAI_API_KEY")),
+ # Max runs on Anthropic, so it needs its own signal — otherwise self-hosted instances
+ # render the assistant but fail at call time with no key configured.
+ "anthropic_available": bool(os.environ.get("ANTHROPIC_API_KEY")),
"site_url": settings.SITE_URL,
"instance_preferences": settings.INSTANCE_PREFERENCES,
"buffer_conversion_seconds": settings.BUFFER_CONVERSION_SECONDS,