Skip to content

feat(payments-sdk): add opt-in preview feature flag - #2737

Merged
steebchen merged 14 commits into
mainfrom
claude/rename-llmgateway-payments-sdk-l60gt2
Jun 28, 2026
Merged

steebchen merged 14 commits into
mainfrom
claude/rename-llmgateway-payments-sdk-l60gt2

Conversation

@steebchen

@steebchen steebchen commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Introduces an opt-in preview feature flag for the Payments SDK (embeddable end-user payments functionality). This allows the feature to be gradually rolled out to users while maintaining backward compatibility.

Key Changes

  • Database Schema: Added payments_sdk_enabled boolean column to the project table (defaults to false) via the generated migration under packages/db/migrations.
  • API Routes: Updated project schema validation in both apps/api/src/routes/projects.ts and apps/api/src/routes/organization.ts to include the new payments_sdk_enabled field.
  • Server-side preview enforcement: The preview gate is enforced in the API, not just the dashboard:
    • PATCH /projects/{id} rejects attempts to enable end-user settings when paymentsSdkEnabled is false.
    • POST /keys/platform now gates platform-key (SDK platform secret) minting on the same flag via a requirePaymentsSdkPreview option on the shared assertPlatformKeyAdminAccess check. Previously an owner/admin could mint Payments SDK platform secrets for a preview-disabled project by calling the API directly (the dashboard button being disabled was the only guard); on projects with endUserEnabled=true those keys could then mint sessions. Listing and revoking existing keys remain allowed.
  • UI Components:
    • Added preview feature opt-in check in sdk-settings.tsx with explanatory comment
    • Updated sidebar label from "SDK" to "Payments SDK" in dashboard-sidebar.tsx
    • Updated SDK settings page title in sdk/page.tsx
  • Documentation:
    • Renamed and updated feature documentation from "LLM SDK" to "Embeddable Payments"
    • Updated learn guide title and description to reflect Payments SDK naming
    • Updated learn index to reference correct documentation path
  • Blog & Redirects:
    • Renamed blog post from "embeddable-ai-credits" to "embeddable-payments-sdk"
    • Added permanent redirects in both docs and UI next.config.ts to maintain backward compatibility with old URLs

Tests

  • apps/api/src/routes/keys-api.spec.ts: the test project now opts into the preview, and a new case asserts that POST /keys/platform returns 403 (and mints no key) when paymentsSdkEnabled is false.

https://claude.ai/code/session_01GUABgidv5iUJEeew7gPrVc

Summary by CodeRabbit

  • New Features

    • Added a new Payments SDK preview setting for projects, with opt-in controls and a read-only preview state until enabled.
    • Project and organization project responses now include Payments SDK availability.
  • Bug Fixes

    • Tightened permissions for updating end-user payment settings.
    • Improved error messages when Payments SDK settings can’t be changed.
  • Documentation

    • Renamed LLM SDK references to Payments SDK across docs, dashboard copy, and blog content.
    • Updated links and redirects to the new Embeddable Payments pages.

Rename the embeddable end-user SDK from "LLM SDK" to "Payments SDK" and
the docs feature page to "Embeddable Payments", clarifying it is a
payments + end-user sessions product (not an AI client SDK like the
OpenAI SDK).

Gate the feature as preview/opt-in via a new DB-only
project.paymentsSdkEnabled flag. The dashboard shows a read-only preview
until it is enabled, and the projects API rejects enabling end-user
settings unless opted in.

Add redirects so renamed pages don't 404:
- docs: /features/llm-sdk -> /features/embeddable-payments
- ui blog: /blog/embeddable-ai-credits-stripe-for-ai -> /blog/embeddable-payments-sdk

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUABgidv5iUJEeew7gPrVc
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a paymentsSdkEnabled boolean column (default false) to the project table via migration, exposes it in API response schemas, and gates end-user settings writes behind it with specific 403 messages. The dashboard UI enters a read-only preview state when the flag is false. All "LLM SDK" references are renamed to "Payments SDK" / "Embeddable Payments" across UI, docs, blog, and redirects.

Changes

Payments SDK preview flag and rebrand

Layer / File(s) Summary
DB schema and migration
packages/db/src/schema.ts, packages/db/migrations/1782650426_spicy_slipstream.sql, packages/db/migrations/meta/_journal.json
Adds payments_sdk_enabled boolean column (not null, default false) to the project table and registers the migration in the journal.
API response schemas and PATCH access control
apps/api/src/routes/organization.ts, apps/api/src/routes/projects.ts
Extends projectSchema in both routes to include paymentsSdkEnabled. In PATCH /projects/{id}, tightens role-check 403 messaging to "Payments SDK settings" and adds a second 403 guard rejecting end-user setting updates when paymentsSdkEnabled is false.
Dashboard SdkSettings preview gating
apps/ui/src/components/settings/sdk-settings.tsx
Derives isPreview from initialProject.paymentsSdkEnabled; when true, renders a "Preview — opt-in only" banner and disables the end-user sessions toggle, markup percent input, allowed-origins textarea, Save Settings button, and Create Test/Live Key buttons.
Dashboard UI copy and sidebar rebrand
apps/ui/src/components/dashboard/dashboard-sidebar.tsx, apps/ui/src/app/dashboard/.../settings/sdk/page.tsx
Renames sidebar nav label from "SDK" to "Payments SDK" and updates the settings page heading and card title/description to match.
Docs rebrand and redirects
apps/docs/content/features/embeddable-payments.mdx, apps/docs/content/learn/sdk-settings.mdx, apps/docs/content/learn/index.mdx, apps/docs/next.config.ts, apps/ui/next.config.ts
Renames "LLM SDK" to "Payments SDK" / "Embeddable Payments" throughout docs pages and navigation, adds a permanent redirect from /features/llm-sdk to /features/embeddable-payments, and redirects the old blog slug.
Blog post rebrand
apps/ui/src/content/blog/2026-06-07-embeddable-payments-sdk.md
Rewrites front matter (id, slug, title, summary) and body copy from "LLM SDK / AI credits" framing to "Payments SDK / Embeddable Payments," updating the Try-it section to reference opt-in steps.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • theopenco/llmgateway#2582: Directly modifies the same apps/api/src/routes/projects.ts PATCH endpoint and end-user settings logic that this PR extends with the paymentsSdkEnabled gate.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding an opt-in preview feature flag for the Payments SDK.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/rename-llmgateway-payments-sdk-l60gt2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title Add Payments SDK opt-in preview feature flag feat(payments-sdk): add opt-in preview feature flag Jun 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 383b8d0706

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1 @@
ALTER TABLE "project" ADD COLUMN "payments_sdk_enabled" boolean DEFAULT false NOT NULL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Backfill projects already using the SDK

For any project that already had end_user_enabled = true before this migration, this initializes payments_sdk_enabled to false. The new dashboard/API gate then treats those live SDK projects as preview-only/read-only and PATCH /projects/{id} rejects changes to markup/origins, so existing users lose the ability to manage their Payments SDK settings unless someone manually flips the new flag. Backfill from existing end_user_enabled rows or otherwise preserve those projects during the migration.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d72f63de3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +265 to +266
preview and enabled on an opt-in basis. The settings below are
read-only until it is enabled for your project — contact us to get

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Disable revoke controls in preview mode

When paymentsSdkEnabled is false, this banner tells admins the SDK settings are read-only, and the save/create controls are disabled, but existing platform keys below can still be revoked because the Revoke button and deleteSecret path are not gated by isPreview. For projects that already have platform keys but are now in preview mode, an admin can still perform a destructive change from a page that claims it is read-only; either disable revocation in preview or make the exception explicit.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c138784011

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// The Payments SDK is a preview feature that must be opted into directly in
// the database. Until then the dashboard only renders a preview, so reject
// any attempt to enable end-user settings through the API.
if (isUpdatingEndUserSettings && !project.paymentsSdkEnabled) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate platform-key APIs on the preview flag

This server-side preview check only covers PATCH /projects/{id}. I checked the platform-key route in apps/api/src/routes/keys-api.ts: POST /keys/platform goes through assertPlatformKeyAdminAccess, which verifies ownership/role but never reads project.paymentsSdkEnabled, so an owner/admin can still create Payments SDK platform secrets for a preview-disabled project by calling the API directly; on projects that already have endUserEnabled=true, those keys can be used to mint sessions. Put the same preview guard in the platform-key API/shared access check instead of relying on the dashboard button being disabled.

Useful? React with 👍 / 👎.

@steebchen
steebchen added this pull request to the merge queue Jun 28, 2026
@steebchen
steebchen removed this pull request from the merge queue due to a manual request Jun 28, 2026
@steebchen
steebchen merged commit a13d7e7 into main Jun 28, 2026
12 checks passed
@steebchen
steebchen deleted the claude/rename-llmgateway-payments-sdk-l60gt2 branch June 28, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants