Skip to content

feat(playground): API endpoint dropdown and deployment-provided models - #231

Open
ilay-decart wants to merge 1 commit into
mainfrom
ilay/playground-endpoint-presets
Open

ilay-decart wants to merge 1 commit into
mainfrom
ilay/playground-endpoint-presets

Conversation

@ilay-decart

@ilay-decart ilay-decart commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

The example page (packages/sdk/index.html, which pnpm dev:example serves) gets an API endpoint dropdown and a slot for server-side models, both filled from the environment so the page never hardcodes hosts:

  • VITE_REALTIME_BASE_URLS: a JSON array of {label, url, note?}. It shows the dropdown above the Realtime Base URL field.
    • Picking a preset fills the field, which stays editable.
    • Typing a URL selects the matching preset, or "Custom".
    • The note shows under the dropdown, for example which API key that endpoint needs.
  • VITE_EXTRA_REALTIME_MODELS: comma-separated model names this SDK build does not list. They appear under "This deployment" and connect like "Custom model", by name.
  • Without either variable the page is unchanged: no dropdown, no extra model group.

Two fixes to the base URL field:

  • A bare host (api.example.com) is read as wss://api.example.com. Before, it failed with Invalid base URL before any request.
  • Picking an endpoint re-mints an ephemeral/JWT credential through it, as a model change already does. A credential minted through one endpoint fails on another.

Hosts come from the environment because a deployment that serves this page (Decart's staging) rewrites production hostnames in the checkout at build time and fails the build if any remain.

Testing

Ran vite dev locally, with and without the variables, and drove the page with Playwright against production endpoints:

  • Without the variables: the dropdown is hidden and there is no extra model group.
  • With them:
    • presets and notes render;
    • choosing "Custom" keeps the field;
    • a typed bare host selects its preset;
    • an unknown URL selects "Custom".
  • Real sessions with the base URL typed as a bare host: an extra (server-side) model and lucy-2.6 both reached "Generating" with 1280×720 output.
  • Ephemeral mode: switching endpoints minted through each selected endpoint in turn, and the session connected with the last credential.
  • pnpm lint and pnpm format:check are clean.

Note

Low Risk
Demo-page-only UI and env-driven configuration; no SDK library API changes and default behavior is unchanged when env vars are unset.

Overview
The SDK demo page (packages/sdk/index.html) can now be configured at build time for non-production deployments without hardcoding hosts.

When VITE_REALTIME_BASE_URLS is set, an API endpoint dropdown appears (hidden otherwise). It lists JSON presets (label, url, optional note), syncs with the existing Realtime Base URL field, and re-mints ephemeral/JWT credentials when the endpoint changes. When VITE_EXTRA_REALTIME_MODELS is set, those names show under a “This deployment” model group and connect like custom models (by name, not via models.realtime()).

Base URL handling is centralized in readRealtimeBaseUrl(): bare hosts get wss:// so the SDK no longer fails on “Invalid base URL,” and connect/mint/files paths use that helper instead of raw input trimming.

Reviewed by Cursor Bugbot for commit 661378b. Bugbot is set up for automated code reviews on this repo. Configure here.

The example page reads optional presets from its environment:
VITE_REALTIME_BASE_URLS (JSON [{label, url, note?}]) adds an "API endpoint"
dropdown that fills the Realtime Base URL field, and VITE_EXTRA_REALTIME_MODELS
(comma-separated) lists server-side models this SDK build does not know, which
connect like "Custom model". Without them the page is unchanged.

A bare host in the base URL field is read as wss://<host> instead of failing
with "Invalid base URL", and picking an endpoint re-mints an ephemeral/JWT
credential through it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@decartai/sdk@231

commit: 661378b

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 661378b. Configure here.

Comment thread packages/sdk/index.html
return isCustomModelSelected() ? buildCustomModel() : models.realtime(elements.modelSelect.value);
const value = elements.modelSelect.value;
if (value === CUSTOM_MODEL_OPTION) return buildCustomModel();
if (value.startsWith(EXTRA_MODEL_PREFIX)) return buildCustomModel(value.slice(EXTRA_MODEL_PREFIX.length));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra models inherit leftover dimensions

Low Severity

Deployment extra models reuse buildCustomModel, so they take width and height from the hidden custom-model fields. After a custom-model attempt, those leftover values apply silently to the extra model and the user cannot see or change them.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 661378b. Configure here.

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.

1 participant