Skip to content

feat: add ENABLE_BYOR_EXPORT env var and frontend feature flag - #232

Open
tofarr wants to merge 4 commits into
mainfrom
feat/enable-byor-export-env-var
Open

feat: add ENABLE_BYOR_EXPORT env var and frontend feature flag#232
tofarr wants to merge 4 commits into
mainfrom
feat/enable-byor-export-env-var

Conversation

@tofarr

@tofarr tofarr commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

On deployments where billing is not enabled, the API keys page does not show LLM API keys to users. Instead it shows a "buy $10 of credit" paywall, which is misleading because there is no billing flow on self-hosted/enterprise deployments. We need a way for admins to enable LLM API key export via an environment variable, and for the UI to show an appropriate "disabled" message when neither billing nor the env var is active.

Summary

  • Added ENABLE_BYOR_EXPORT environment variable (accepts 'true' and '1') that short-circuits check_byor_export_enabled in the backend so BYOR export is always enabled when set.
  • Exposed enable_byor_export as a frontend feature flag via the web client config injector and WebClientFeatureFlags model.
  • Updated the API keys page (api-keys-manager.tsx) with three-way conditional rendering: (1) disabled message when billing is off AND BYOR export is off, (2) buy-credits paywall when billing is on and payment is required, (3) full LLM key manager otherwise.
  • Updated use-llm-api-key.ts hook to fire the BYOR key fetch when enable_byor_export is true (not just in SaaS mode).
  • Added i18n key SETTINGS$LLM_API_KEY_DISABLED_MESSAGE across all 14 supported languages.

How to Test

  1. Backend (env var short-circuit): Set ENABLE_BYOR_EXPORT=true and call check_byor_export_enabled for a user with no credits / no org flag. It should return True immediately.
  2. Backend (env var unset): With ENABLE_BYOR_EXPORT unset (default false), the existing behavior is unchanged — the check proceeds to the billing/credits logic.
  3. Frontend (disabled message): On a deployment with ENABLE_BILLING unset and ENABLE_BYOR_EXPORT unset, the API keys page should show "LLM API key export is disabled on this deployment. Contact your administrator to enable it." instead of the buy-credits paywall.
  4. Frontend (BYOR export enabled): Set ENABLE_BYOR_EXPORT=true (no billing). The API keys page should show the full LLM key manager with the key, refresh button, copy, and show/hide controls.
  5. Frontend (billing + payment required): On SaaS with billing enabled and a 402 response, the existing buy-credits paywall should still appear.
  6. Tests: PYTHONPATH=".:$PYTHONPATH" poetry run python -m pytest enterprise/tests/unit/test_org_service.py -k byor_export (7 tests pass) and cd frontend && npx vitest run __tests__/components/features/settings/api-keys-manager.test.tsx (4 tests pass).

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

The ENABLE_BYOR_EXPORT env var accepts both 'true' and '1' as truthy values, following the repository convention for env var enable toggles (older Helm charts default to '1'). The _env_flag_enabled helper in default_web_client_config_injector.py was reused for the frontend flag.

Pull request created by an AI agent (OpenHands) on behalf of the user.


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-1728e49

Add an `ENABLE_BYOR_EXPORT` environment variable that short-circuits the
`check_byor_export_enabled` backend check so BYOR export is always enabled
when set to true (accepts 'true' and '1'). Expose `enable_byor_export` as a
frontend feature flag via the web client config so the frontend can gate the
LLM key display on this flag instead of relying solely on HTTP 402 responses.

On the API keys page, when billing is not enabled and BYOR export is not
enabled, show a "disabled" message instead of the buy-credits paywall.

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions github-actions Bot added the type: feat A new feature label Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  enterprise/server
  constants.py
  enterprise/storage
  org_service.py 852-857
  openhands/app_server/web_client
  web_client_models.py
Project Total  

This report was generated by python-coverage-comment-action

tofarr and others added 3 commits August 24, 2026 18:37
Collapse the multi-line `check_byor_export_enabled` call in the env-var test
onto a single line to match ruff's formatting rules.

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants