{"id":51027193,"url":"https://github.com/deepgram/deepgram-js-sdk-transport-sagemaker","last_synced_at":"2026-06-21T20:30:48.755Z","repository":{"id":360429853,"uuid":"1250112723","full_name":"deepgram/deepgram-js-sdk-transport-sagemaker","owner":"deepgram","description":"SageMaker transport for the Deepgram JS SDK","archived":false,"fork":false,"pushed_at":"2026-05-26T10:25:28.000Z","size":132,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-26T12:27:38.580Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepgram.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-26T10:12:41.000Z","updated_at":"2026-05-26T10:24:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/deepgram/deepgram-js-sdk-transport-sagemaker","commit_stats":null,"previous_names":["deepgram/deepgram-js-sdk-transport-sagemaker"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/deepgram/deepgram-js-sdk-transport-sagemaker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-sdk-transport-sagemaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-sdk-transport-sagemaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-sdk-transport-sagemaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-sdk-transport-sagemaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepgram","download_url":"https://codeload.github.com/deepgram/deepgram-js-sdk-transport-sagemaker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepgram%2Fdeepgram-js-sdk-transport-sagemaker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34625624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-21T20:30:47.160Z","updated_at":"2026-06-21T20:30:48.748Z","avatar_url":"https://github.com/deepgram.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deepgram SageMaker Transport for JavaScript\n\n[![Node.js 20+](https://img.shields.io/badge/node-20%2B-blue)](https://nodejs.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nSageMaker transport for the [Deepgram JavaScript SDK](https://github.com/deepgram/deepgram-js-sdk). It replaces the SDK's default streaming WebSocket transport with SageMaker's bidirectional HTTP/2 runtime API so the rest of the Deepgram client API stays the same.\n\n## Status\n\nThis package targets the pluggable transport interface introduced in Deepgram JS SDK PR `#492`.\n\n## Requirements\n\n- Node.js 20+\n- A Deepgram JS SDK build that includes `transportFactory` support\n- AWS credentials configured for SageMaker access\n- A Deepgram model deployed behind an AWS SageMaker endpoint\n\n## Installation\n\n```bash\nnpm install @deepgram/sdk @deepgram/sagemaker@0.1.1 # x-release-please-version\n```\n\n## Authentication\n\nThis transport uses AWS credentials, not Deepgram API keys. Authentication is handled by the AWS SDK credential chain, including:\n\n1. Environment variables such as `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`\n2. Shared AWS config and credential files\n3. IAM roles\n4. Custom credentials passed through `clientConfig`\n\nThe `apiKey` passed to `DeepgramClient` is unused once this transport is configured, but the SDK still requires a value to construct the client.\n\n## Quickstart\n\n```ts\nimport { DeepgramClient } from \"@deepgram/sdk\";\nimport { createSageMakerTransportFactory } from \"@deepgram/sagemaker\";\n\nconst transportFactory = createSageMakerTransportFactory({\n  endpointName: \"my-deepgram-endpoint\",\n  region: \"us-west-2\",\n});\n\nconst client = new DeepgramClient({\n  apiKey: \"unused\",\n  transportFactory,\n});\n\nconst socket = await client.listen.v1.createConnection({\n  model: \"nova-3\",\n});\n\nsocket.on(\"message\", (message) =\u003e {\n  console.log(message);\n});\n\nsocket.connect();\nsocket.sendMedia(new Uint8Array([1, 2, 3]));\n```\n\nThe transport is transparent: your Deepgram SDK usage stays the same while the underlying stream is routed to SageMaker.\n\n## Configuration\n\n```ts\nimport type { SageMakerConfig } from \"@deepgram/sagemaker\";\n\nconst config: SageMakerConfig = {\n  endpointName: \"my-deepgram-endpoint\",\n  region: \"us-west-2\",\n  targetVariant: \"blue\",\n  clientConfig: {\n    maxAttempts: 2,\n  },\n  // Burst-tuned timeouts and retry behavior (defaults shown):\n  connectionTimeoutMs: 30_000,\n  subscriptionTimeoutMs: 60_000,\n  maxConcurrency: 500,\n  maxRetries: 5,\n  initialBackoffMs: 100,\n  maxBackoffMs: 5_000,\n  backoffMultiplier: 2.0,\n  retryBudgetMs: 30_000,\n  maxReplayBufferBytes: 8 * 1024 * 1024,\n};\n```\n\nAll time-based fields are in milliseconds.\n\n| Field | Required | Default | Description |\n| --- | --- | --- | --- |\n| `endpointName` | Yes | none | SageMaker endpoint name |\n| `region` | No | `us-west-2` | AWS region |\n| `targetVariant` | No | none | Optional SageMaker target variant |\n| `clientConfig` | No | none | Additional AWS client configuration |\n| `connectionTimeoutMs` | No | `30_000` | Max time for the underlying HTTP/2 connect / first response (AWS default is ~2 s — bumped here so cold-start endpoints under burst load have time to accept TLS handshakes). |\n| `subscriptionTimeoutMs` | No | `60_000` | Max time the transport waits for the SageMaker bidi stream to open before failing a connect attempt. A timeout is treated as a transient failure and counts against `maxRetries` / `retryBudgetMs`. |\n| `maxConcurrency` | No | `500` | Cap on simultaneous in-flight HTTP/2 streams. Advisory in JS today — the AWS SDK v3 HTTP/2 client doesn't expose a hard cap, but the knob is kept for surface parity and any future Node-side concurrency limiter. |\n| `maxRetries` | No | `5` | Max retries on transient AWS errors (throttling, transient connect/timeout). Set to `0` to disable internal retry. Terminal errors (auth, validation) bypass this. |\n| `initialBackoffMs` | No | `100` | First backoff delay applied after the initial failure. |\n| `maxBackoffMs` | No | `5_000` | Cap on per-attempt backoff delay regardless of multiplier. |\n| `backoffMultiplier` | No | `2.0` | Exponential growth factor between retry attempts. Must be `\u003e= 1.0`. |\n| `retryBudgetMs` | No | `30_000` | Total wall-clock cap across all retry attempts before giving up. |\n| `maxReplayBufferBytes` | No | `8 * 1024 * 1024` | Cap on the in-memory replay buffer that holds sent-but-unacked stream events. Set to `0` to disable replay (sent events are dropped on internal reset). |\n\n### High-concurrency notes\n\nThe transport's defaults are tuned for high-burst workloads (large numbers of\nstreams opened in a tight loop against an endpoint that may need to scale up).\nIf you open 200–500 streams simultaneously against a cold endpoint, the AWS\nSDK's general-purpose defaults (~2 s connect) will fire before the load\nbalancer has accepted all of the inbound TLS handshakes — you'll see a wave\nof connect / acquire timeouts that look like server-side problems but are\nreally client-side fail-fast tripping early.\n\nShip with the lenient defaults and tighten them only if you need fail-fast\nbehavior in low-latency pipelines:\n\n```ts\nconst transportFactory = createSageMakerTransportFactory({\n  endpointName: \"my-deepgram-endpoint\",\n  region: \"us-east-1\",\n  connectionTimeoutMs: 5_000,\n  subscriptionTimeoutMs: 15_000,\n});\n```\n\n### Retry \u0026 storm absorption\n\nTransient AWS-side failures (`ThrottlingException`, transient connect/timeout\nfailures, `ModelError`/`424` from the upstream container) are absorbed by the\ntransport itself: classified as retryable, retried with jittered exponential\nbackoff up to `maxRetries` and `retryBudgetMs`, with messages buffered during\nthe reset window replayed onto the new stream so audio isn't dropped. Only\n**terminal** errors (auth, validation, resource-not-found) and budget-exhausted\nretryable errors propagate to the application.\n\n```ts\nconst transportFactory = createSageMakerTransportFactory({\n  endpointName: \"my-deepgram-endpoint\",\n  maxRetries: 10,\n  initialBackoffMs: 200,\n  maxBackoffMs: 10_000,\n  retryBudgetMs: 60_000,\n});\n```\n\nSet `maxRetries: 0` to disable internal retry entirely (every transient AWS\nerror then surfaces immediately to the application).\n\nWhen using this transport with the Deepgram JS SDK, also pass `reconnect: false`\non the `DeepgramClient` (or rely on the SDK's auto-disable when\n`transportFactory` is set) so the SDK's wrapper-level retry layer doesn't\ndouble-stack on top of this transport's internal retry.\n\n## Custom AWS Client\n\nIf you already manage the SageMaker runtime client yourself, pass it as the second argument:\n\n```ts\nimport { SageMakerRuntimeHTTP2Client } from \"@aws-sdk/client-sagemaker-runtime-http2\";\nimport { createSageMakerTransportFactory } from \"@deepgram/sagemaker\";\n\nconst awsClient = new SageMakerRuntimeHTTP2Client({\n  region: \"us-west-2\",\n});\n\nconst transportFactory = createSageMakerTransportFactory(\n  { endpointName: \"my-deepgram-endpoint\" },\n  awsClient,\n);\n```\n\nThe returned factory also exposes:\n\n- `transportFactory.client`\n- `transportFactory.config`\n- `transportFactory.create(url, headers, request)`\n- `transportFactory.destroy()`\n\nFor naming parity with the Java and Python packages, the package also exports `SageMakerTransportFactory` as an alias of `createSageMakerTransportFactory`.\n\n## Keepalive Behavior\n\nFor `listen.v1`, `listen.v2`, and `agent.v1`, the transport implements `ping()` by sending a Deepgram `{\"type\":\"KeepAlive\"}` control message through SageMaker.\n\n## How It Works\n\nThe Deepgram SDK still builds the same streaming request metadata it would normally use for a WebSocket connection. This package converts that request into SageMaker's `InvokeEndpointWithBidirectionalStream` API:\n\n```text\nDeepgram JS SDK -\u003e transportFactory(url, headers, request)\n                 -\u003e SageMaker HTTP/2 bidirectional stream\n                 -\u003e your deployed Deepgram model\n```\n\nAudio and text control messages are written into the SageMaker request stream, and transcript or audio responses are surfaced back through the Deepgram transport interface.\n\n## Development\n\n```bash\nnpm install\nnpm run check\nnpm run pack:check\n```\n\n## Examples\n\nThis repo now includes the same five example categories as the Python and Java transport repos:\n\n- `examples/stt.mjs`\n- `examples/flux.mjs`\n- `examples/live-mic.mjs`\n- `examples/live-mic-flux.mjs`\n- `examples/tts.mjs`\n\nRun them with:\n\n```bash\nnpm run example:stt\nnpm run example:flux\nnpm run example:live-mic\nnpm run example:live-mic-flux\nnpm run example:tts\n```\n\nNotes:\n\n- Requires `@deepgram/sdk` \u003e= 5.4.0 (the release that added `transportFactory` support).\n- Live microphone examples also require the optional `mic` package: `npm install mic`.\n- File-based examples expect `spacewalk.wav` in the repo root by default, or `AUDIO_FILE` can point to another WAV file.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgram%2Fdeepgram-js-sdk-transport-sagemaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepgram%2Fdeepgram-js-sdk-transport-sagemaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepgram%2Fdeepgram-js-sdk-transport-sagemaker/lists"}