feat: per-call API key provider for multi-tenant embedders (v1.2.0) - #126
Merged
rbuchmayer-pplx merged 1 commit intoJul 27, 2026
Merged
Conversation
rbuchmayer-pplx
marked this pull request as ready for review
July 27, 2026 19:39
The API key was a module-level env read baked into every upstream call,
so an embedder hosting the server for more than one key had no way to
route each request's own credentials. createPerplexityServer now accepts
{ apiKey: () => string | undefined }, threaded through every upstream
call including the server-side cancel path. A configured provider fully
replaces the env var: returning no key fails the call rather than
silently billing the process-wide key.
rbuchmayer-pplx
force-pushed
the
feat-api-key-provider
branch
from
July 27, 2026 19:41
ab354f6 to
d19120b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The library entry point added in 1.1.0 still resolved the API key from a module-level env read, so an embedder hosting the server for more than one key (one server instance per request, each with its own credentials) had no way to route the right key per call.
createPerplexityServer(serviceOrigin?, { apiKey?: () => string | undefined }): an optional per-call key provider, threaded through every upstream call including the fire-and-forget server-side cancelDesign note: we considered resolving keys from the SDK's per-request
extra.authInfoinstead. The provider option keeps the standalone server single-tenant by default (inbound bearer headers are never interpreted as upstream credentials) and leaves auth policy to the embedder; hosts that use SDK auth middleware can bridge it in their provider closure.Tests: provider key used end to end through a real client (env ignored), provider-returns-no-key fails without touching the network, cancel path carries the provider key. Suite at 89.
Note: merging publishes 1.2.0 (the publish workflow triggers on
package.jsonchanges).