feat: add --anthropic-key option for direct Anthropic API access (BYOK)#271
Open
okedeji wants to merge 2 commits intoPostHog:mainfrom
Open
feat: add --anthropic-key option for direct Anthropic API access (BYOK)#271okedeji wants to merge 2 commits intoPostHog:mainfrom
okedeji wants to merge 2 commits intoPostHog:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The wizard is currently blocked for frameworks that rely on the agentic flow (e.g., Next.js App Router). When it tries to call the LLM gateway, the gateway returns 401s (
Authentication required), so no Claude calls can be made. OAuth and MCP init succeed, but the wizard can’t progress because it can’t reach the gateway. There’s no fallback path.Solution
Add a
--anthropic-keyCLI flag (andPOSTHOG_WIZARD_ANTHROPIC_KEYenv var) so users can provide their own Anthropic API key. When this is set, the wizard skips the PostHog LLM gateway and sends Claude requests directly to api.anthropic.com.Everything else stays the same (OAuth, MCP auth, env tools, post‑agent steps). The gateway is still the default; this is just an escape hatch.
Why this helps
Usage
CLI flag
npx @posthog/wizard --anthropic-key sk-ant-xxxEnvironment variable
POSTHOG_WIZARD_ANTHROPIC_KEY=sk-ant-xxx npx @posthog/wizardWorks with CI mode
npx @posthog/wizard --ci --region us --api-key phx_xxx --anthropic-key sk-ant-xxx --install-dir .Test plan
pnpm build: compiles with zero errorspnpm test: 124 tests pass, 0 failurespnpm fix: 0 lint errors--anthropic-keyis not providedImage Reference