Skip to content

feat(realtime): add speed="fast" option and supported_speeds model capability - #70

Open
AdirAmsalem wants to merge 2 commits into
mainfrom
conductor/fast-mode-speed-fast-realtime-option-decart-python
Open

AdirAmsalem wants to merge 2 commits into
mainfrom
conductor/fast-mode-speed-fast-realtime-option-decart-python

Conversation

@AdirAmsalem

@AdirAmsalem AdirAmsalem commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Description

Adds fast mode to the realtime API in the Python SDK.

Fast mode (speed="fast") serves the session from a higher-compute tier for lower latency and higher throughput; output quality is unchanged. It is currently available for lucy-2.5 / lucy-latest and lucy-vton-3.5 / lucy-vton-latest, in the US region only, and is billed at 2x the standard realtime rate for those models. Other models ignore the option. Omit it (the default) for standard mode.

What changes for users:

  • RealtimeConnectOptions accepts an optional speed (type RealtimeSpeed, exported from decart and decart.realtime), alongside the existing resolution option. It is kept across automatic reconnects.
  • Each model definition advertises the speed tiers it supports via supported_speeds, so callers can check capability before connecting. Passing speed for a model that does not support it emits a one-time warning and the session proceeds in standard mode.
  • README, examples README, and the playground (--speed fast) document the option.

Usage

from decart import DecartClient, models
from decart.realtime import RealtimeClient, RealtimeConnectOptions

client = DecartClient(api_key=os.getenv("DECART_API_KEY"))
realtime = await RealtimeClient.connect(
    base_url=client.realtime_base_url,
    api_key=client.api_key,
    local_track=local_track,
    options=RealtimeConnectOptions(
        model=models.realtime("lucy-2.5"),
        on_remote_stream=on_remote_stream,
        speed="fast",  # omit for standard mode
    ),
)

models.realtime("lucy-2.5").supported_speeds  # ("fast",)

Docs: https://docs.platform.decart.ai/sdks/python

Verification

uv sync --all-extras
uv run black --check decart/ tests/ examples/ playground/   -> 41 files would be left unchanged
uv run ruff check decart/ tests/ examples/ playground/      -> All checks passed
uv run mypy decart/                                         -> 37 errors, identical to main (pre-existing; CI runs mypy with continue-on-error)
uv run pytest tests/ -v                                     -> 96 passed
uv run python -m py_compile examples/*.py playground/playground.py -> ok

Live test (production API, 2026-09-23 15:04 UTC)

Ran the SDK's own RealtimeClient.connect path from a sandbox with a synthetic LiveKit video source, held each session ~5s, then disconnected. Every case reached connected then generating and received a remote inference track with ~90 frames in 5s.

Case Model speed Result
Default path lucy-2.5 unset connected, no warning
Fast path lucy-2.5 "fast" connected, no warning
Fast path lucy-vton-3.5 "fast" connected, no warning
Ignored path lucy-2.1 "fast" connected; SDK emitted the "does not support speed" warning

Compatibility

Additive and backward compatible: speed defaults to unset, the default connection path is unchanged (pinned by a test), and no model ids, aliases, or defaults change. No version bump.

…pability

Add an optional `speed` on `RealtimeConnectOptions` (`RealtimeSpeed = Literal["fast"]`),
appended to the signaling URL as `&speed=fast` exactly like `resolution` and omitted when
unset, so the default path produces byte-identical URLs. The LiveKit manager redials with
the stored URL, so reconnects keep the parameter.

Expose the tier as a model capability via `ModelDefinition.supported_speeds` (default `()`),
set to `("fast",)` on the realtime entries lucy-2.5, lucy-latest, lucy-vton-3.5 and
lucy-vton-latest only. Passing `speed` for any other model emits a one-shot UserWarning
and still sends the parameter (the server ignores it).

Export `RealtimeSpeed` from `decart` and `decart.realtime`, document fast mode in the
README and examples README, add a `--speed fast` flag to the playground, and add unit
tests for the URL building, warning, reconnect and capability pin.
@AdirAmsalem
AdirAmsalem marked this pull request as ready for review September 23, 2026 15:13
The two warning tests recorded every warning in their window and asserted on the
total. On some Python versions aiohttp "Unclosed client session" ResourceWarnings
from sessions created by earlier tests are raised during GC inside that window,
which made the assertion order-dependent. Filter the recorded warnings down to the
speed warning before asserting.

This branch has not been deployed

No deployments
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