@ottervoice/provider-utils
Use this package when authoring a custom provider or talking to your own gateway. App UI code usually does not import it — the bundled factory functions already wrap it.
Main exports
Section titled “Main exports”| Symbol | Use |
|---|---|
CredentialOptions |
apiKey (server only) · broker URL/app auth/session binding · fetch |
createCredentialResolver |
Resolve short-lived tokens / static keys inside adapters |
| SSE helpers | Parse OpenAI-style (and similar) SSE streams |
| WebSocket ASR helpers | Shared skeleton for streaming ASR sessions |
CredentialOptions
Section titled “CredentialOptions”| Field | Notes |
|---|---|
tokenBrokerUrl |
Client-safe only when the token is short-lived and route/model/budget scoped. |
tokenBrokerHeaders |
Application-auth headers sent only to the broker, never to the upstream provider. |
tokenBrokerSessionId |
Voice session id used by the broker for ownership, quota, and audit checks. |
tokenBrokerCredentials |
Set to include for cross-origin cookie auth; same-origin uses the browser default. |
apiKey |
Long-lived key. Server / CLI only — never ship in browsers or apps. |
fetch |
Injectable for tests or non-standard runtimes. |
Token contract: Token broker quick start and examples/token-broker. Providers that cannot issue genuinely scoped credentials (for example a broad bearer token that can select arbitrary OpenRouter models) require a server policy gateway.
import { createCredentialResolver } from '@ottervoice/provider-utils';
const resolve = createCredentialResolver({ tokenBrokerUrl: 'https://api.example.com/api/voice/token', tokenBrokerHeaders: { authorization: `Bearer ${applicationSessionToken}` }, tokenBrokerSessionId: voiceSessionId,}, { provider: 'deepgram', purpose: 'asr',});
const { token, url, expiresAt } = await resolve();Full field tables: API · provider-utils.