Skip to content

feat: apiKeyProvider covers the HTTP APIs (process, queue, files, tokens) - #226

Merged
AdirAmsalem merged 1 commit into
mainfrom
conductor/apikeyprovider-for-http-apis
Oct 15, 2026
Merged

AdirAmsalem merged 1 commit into
mainfrom
conductor/apikeyprovider-for-http-apis

Conversation

@AdirAmsalem

@AdirAmsalem AdirAmsalem commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Apps that authenticate with short-lived client tokens can now use one client for everything: apiKeyProvider supplies the credential for every HTTP request (process, queue, files, tokens), not just realtime connects and reconnects. Until now the HTTP APIs ignored it, so a browser app had to mint a token and build a new client before every batch call. The provider is called right before each request, including every submitAndPoll status poll and the result download, and wins over apiKey; without a provider nothing changes, and proxy mode never calls it. Because the API checks the token once the request body has fully arrived, the docs now say to mint upload tokens with an expiresIn that covers the upload.

Usage

const client = createDecartClient({ apiKeyProvider: () => fetchClientTokenFromYourServer() });

// The provider runs before the submit, each status poll and the result download.
const result = await client.queue.submitAndPoll({ model: models.video("lucy-latest"), prompt, data: videoFile });

Note

Medium Risk
Auth behavior changes for apps using apiKeyProvider with batch/HTTP APIs (more provider calls, different keys per poll); proxy and static apiKey paths are unchanged.

Overview
apiKeyProvider now supplies credentials for all direct HTTP APIs, not only realtime connect/reconnect. createDecartClient builds a shared getApiKey from createCredentialSource when a provider is set in non-proxy mode; process, queue, files, and tokens call it immediately before each request (including every submitAndPoll status poll and the result download). The provider overrides a static apiKey; behavior is unchanged when no provider is configured. Proxy mode still sends no API key and does not invoke the provider for HTTP.

Docs and JSDoc now describe per-request minting, no SDK caching, and that upload tokens need an expiresIn long enough for the body to finish uploading because auth is checked after the request body arrives. Unit tests cover per-request keys, invalid provider results, and proxy mode skipping the provider.

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

…ens)

`createDecartClient({ apiKeyProvider })` now resolves the credential for every
HTTP request too, not only for realtime connects and reconnects. The provider
is called right before each request (including every `submitAndPoll` status
poll and the result download) and wins over `apiKey`. Its result goes through
the same checks as a realtime dial's (`INVALID_API_KEY` for an empty or
non-string result, `TOKEN_EXPIRED` for an already expired client token).
Without a provider nothing changes; proxy mode sends no key and never calls it.

Docs note that the API checks the token once the request body has fully
arrived, so uploads need a token minted with an `expiresIn` that covers them.
@AdirAmsalem
AdirAmsalem merged commit 6e9e1e9 into main Oct 15, 2026
4 checks passed
@AdirAmsalem
AdirAmsalem deleted the conductor/apikeyprovider-for-http-apis branch October 15, 2026 18:41
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