@runinfra/sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@runinfra/sdk` are documented here. This project follows
4
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [0.1.1] - 2026-05-23
7
+
8
+ ### Changed
9
+ - **`license`**: `UNLICENSED` → `LicenseRef-Proprietary` (aligns with Python SDK; the prior value was contradictory for a public package).
10
+ - **`repository.url`**: now points at `RightNow-AI/RunInfra-Landing` (the actual source repo). Previous value pointed at the non-existent `RunPipe` slug.
11
+ - **`bugs.url`**: same fix.
12
+ - **`description`**: now states "beta; LLM + embeddings tested, image/audio surfaces experimental" so the registry listing accurately reflects verification state.
13
+
14
+ ### Added
15
+ - **Modality status section** in the README documenting which surfaces are
16
+ contract-tested vs experimental.
17
+ - **`@experimental` JSDoc** on `client.images.*`, `client.audio.speech.*`, and
18
+ `client.audio.transcriptions.*` — these surfaces match the OpenAI HTTP
19
+ envelope but have not been verified end-to-end against a live deployed
20
+ pipeline in the public-gateway canary suite. Test against your own
21
+ deployments before using in production.
22
+ - This `CHANGELOG.md`.
23
+
24
+ ### Provenance
25
+ This is the first release published via GitHub OIDC trusted publishing
26
+ (`.github/workflows/sdk-publish.yml` → `npm` environment). The published
27
+ tarball includes a Sigstore-backed provenance attestation that ties the
28
+ release to a specific CI run. Verify with:
29
+ ```bash
30
+ npm view @runinfra/sdk@0.1.1 dist.attestations
31
+ ```
32
+ v0.1.0 was published from a local machine to bootstrap the Trusted Publisher
33
+ configuration and does not have provenance. All v0.1.1+ releases will.
34
+
35
+ ### Known beta gaps
36
+ - Live-canary coverage is currently restricted to LLM + embeddings. Image,
37
+ TTS, and ASR surfaces are runnable but not yet verified end-to-end.
38
+ - Webhook delivery routes are not shipped; `client.webhooks.create` /
39
+ `.list()` throw `UnsupportedOperationError`. Local signature verification
40
+ (`verifySignature`, `constructEvent`) works.
41
+ - `client.voice.pipeline.create` is not shipped; throws
42
+ `UnsupportedOperationError`.
43
+
44
+ ### Toward 1.0.0 GA
45
+ GA requires all 5 modalities live-canary verified, the workflow
46
+ `bypass_live_canary` flag retired, and the strict gate scripts re-enabled.
47
+
48
+ ## [0.1.0] - 2026-05-22
49
+
50
+ Initial public release. See README for the API surface.
package/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ RunInfra SDK License
2
+ Copyright (c) 2026 RightNow AI, Inc.
3
+
4
+ This software is licensed under a proprietary, source-available license.
5
+ By installing, copying, or using this package you agree to the terms below.
6
+
7
+ 1. Permitted use
8
+ You may use this SDK to integrate your own applications with RunInfra
9
+ inference services hosted at api.runinfra.ai. This includes:
10
+ - Calling the public gateway endpoints documented in the README.
11
+ - Embedding this SDK in your applications (commercial or personal),
12
+ provided your use does not violate Section 2.
13
+
14
+ 2. Restrictions
15
+ You may not:
16
+ - Redistribute or sublicense this SDK in modified form.
17
+ - Use this SDK to reverse-engineer, replicate, or impair the RunInfra
18
+ hosted service.
19
+ - Remove or alter the attribution notices in this LICENSE or in package
20
+ metadata.
21
+ - Misrepresent the origin of this SDK or its packaging artifacts.
22
+
23
+ 3. No warranty
24
+ This SDK is provided "as is", without warranty of any kind, express or
25
+ implied, including but not limited to merchantability, fitness for a
26
+ particular purpose, and non-infringement. In no event shall RightNow AI,
27
+ Inc. or its affiliates be liable for any claim, damages, or other
28
+ liability arising from the use of this SDK.
29
+
30
+ 4. Termination
31
+ This license terminates automatically if you breach any of the
32
+ restrictions in Section 2. Upon termination, you must cease all use of
33
+ this SDK and delete all copies in your possession.
34
+
35
+ 5. Contact
36
+ For commercial licensing inquiries, partnerships, or questions about
37
+ this license, contact licensing@runinfra.ai.
package/README.md CHANGED
@@ -1,364 +1,384 @@
1
- # RunInfra TypeScript SDK
2
-
3
- Access optimized RunInfra deployments through the verified public gateway.
4
-
5
- Requires Node.js 18 or newer.
6
-
7
- ## Install
8
-
9
- ```bash
10
- npm install @runinfra/sdk
11
- ```
12
-
13
- ## Create a client
14
-
15
- Use a workspace-scoped key to reach verified active deployments through the `model` field.
16
- In RunPipe, open Settings, API Keys, Create key, and keep Scope set to Workspace.
17
-
18
- The Deploy tab can create a pipeline-scoped key for one optimized pipeline.
19
- The one-time secret is shown once after creation. Store it as `RUNINFRA_API_KEY`
20
- for app snippets before leaving the page. For repo live canaries, keep the
21
- workspace key in `RUNINFRA_API_KEY` and put the pipeline-scoped key for
22
- `TEST_PIPELINE_ID` in `RUNINFRA_PIPELINE_API_KEY` so flat and pipeline routes
23
- are verified independently.
24
-
25
- After a runbook finishes in RunPipe, choose Open Deploy from the runbook handoff.
26
- Deploy only shows SDK operations that the verified endpoint supports, so copy
27
- the native or OpenAI-compatible snippet from there instead of guessing a route.
28
-
29
- ```ts
30
- import { RunInfra } from "@runinfra/sdk";
31
-
32
- const apiKey = process.env.RUNINFRA_API_KEY;
33
- if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
34
-
35
- const client = new RunInfra({
36
- apiKey,
37
- });
38
- ```
39
-
40
- Use `pipelineId` when the key or integration should be locked to one optimized pipeline.
41
-
42
- ```ts
43
- const apiKey = process.env.RUNINFRA_API_KEY;
44
- if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
45
-
46
- const client = new RunInfra({
47
- apiKey,
48
- pipelineId: "pipe_123",
49
- });
50
- ```
51
-
52
- The default base URL is `https://api.runinfra.ai/v1`.
53
- `pipelineId` is trimmed and URL-encoded before it is added to the base URL. Use either `pipelineId` with the default base URL, or a pipeline-scoped `baseURL` such as `https://api.runinfra.ai/v1/pipe_123`. If both point to the same pipeline, the SDK keeps the URL scoped once.
54
- RunPipe generated native SDK snippets prefer `pipelineId` with the root `https://api.runinfra.ai/v1` base URL. OpenAI-compatible snippets use the pipeline-scoped base URL because the OpenAI SDK has no RunInfra pipeline option.
55
- Custom base URLs must use `http` or `https`. Other schemes and malformed URLs are rejected before a bearer API key can be sent.
56
- Remote custom base URLs must use `https`. Plain `http` is accepted only for local development hosts: `localhost`, `127.0.0.1`, `0.0.0.0`, and `[::1]`.
57
- Custom base URLs must not include usernames or passwords.
58
- Custom base URLs must not include query strings or fragments.
59
-
60
- ## Server-side only
61
-
62
- The TypeScript SDK targets Node.js 18 or newer. RunInfra API keys are bearer secrets. Do not initialize this SDK in browser code with a secret API key. The SDK fails closed when it detects a browser runtime; keep calls on a Node.js server route, API service, or backend job. If you are deliberately using a controlled non-public browser-like runtime, pass `dangerouslyAllowBrowser: true` and own that risk.
63
-
64
- Unknown TypeScript client option keys are rejected so typos such as `baseUrl` or `api_key` do not silently change the gateway, authentication, timeout, retry, or runtime-safety behavior. Use `baseURL` for custom server-side gateway URLs.
65
-
66
- ## Responses and streaming
67
-
68
- ```ts
69
- const stream = await client.responses.create({
70
- model: "llama-3.1-8b",
71
- input: "Hello",
72
- max_output_tokens: 512,
73
- stream: true,
74
- });
75
-
76
- for await (const event of stream) {
77
- if (event.type === "response.output_text.delta") {
78
- process.stdout.write(event.delta ?? "");
79
- }
80
- }
81
-
82
- console.log(stream.requestId);
83
- ```
84
-
85
- ## Supported public routes
86
-
87
- - `models.list()`
88
- - `models.retrieve(model)`
89
- - `responses.create()`
90
- - `chat.completions.create()`
91
- - `embeddings.create()`
92
- - `audio.speech.create()`
93
- - `audio.transcriptions.create()`
94
- - `images.generate()`
95
- - `voice.pipeline.create()`
96
-
97
- ## Text to speech
98
-
99
- TTS deployments can expose named voices or Base/reference-audio voice cloning.
100
- Use `RUNINFRA_TTS_VOICE` when the deployment lists a voice or speaker. Use
101
- `RUNINFRA_TTS_REF_AUDIO` and `RUNINFRA_TTS_REF_TEXT` when the deployment expects
102
- reference-audio input.
103
-
104
- ```ts
105
- const voice = process.env.RUNINFRA_TTS_VOICE?.trim();
106
- const refAudio = process.env.RUNINFRA_TTS_REF_AUDIO?.trim();
107
- const refText = process.env.RUNINFRA_TTS_REF_TEXT?.trim();
108
- const taskType = process.env.RUNINFRA_TTS_TASK_TYPE?.trim() || "Base";
109
-
110
- const speechVoice = voice
111
- ? { voice }
112
- : refAudio && refText
113
- ? { ref_audio: refAudio, ref_text: refText, task_type: taskType }
114
- : null;
115
-
116
- if (!speechVoice) {
117
- throw new Error("Set RUNINFRA_TTS_VOICE, or RUNINFRA_TTS_REF_AUDIO and RUNINFRA_TTS_REF_TEXT.");
118
- }
119
-
120
- const audio = await client.audio.speech.create({
121
- model: "your-tts-model-id",
122
- input: "Hello from your optimized RunInfra endpoint.",
123
- ...speechVoice,
124
- });
125
- ```
126
-
127
- ## Timeouts and retries
128
-
129
- ```ts
130
- const apiKey = process.env.RUNINFRA_API_KEY;
131
- if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
132
-
133
- const client = new RunInfra({
134
- apiKey,
135
- timeoutMs: 60_000,
136
- maxRetries: 2,
137
- retryBaseMs: 250,
138
- });
139
- ```
140
-
141
- The SDK retries transient transport failures and `408`, `409`, `429`, `500`, `502`, `503`, and `504` responses for safe `GET` requests. Charge-bearing `POST` inference requests retry only when you provide `idempotencyKey`, and automatic POST retries are limited to non-streaming JSON calls whose gateway responses can be replayed safely. That covers `responses.create()`, non-streaming `chat.completions.create()`, `embeddings.create()`, and `images.generate()`. Streaming calls, binary TTS responses, and multipart ASR uploads are sent once even when you provide an idempotency key. The gateway still binds idempotency keys for TTS and ASR, so a manual retry with the same key will not run or charge a second inference after the first request settles. Automatic retries honor reasonable `Retry-After` values up to 60 seconds when the header is a plain integer second value or HTTP-date, then fall back to bounded exponential backoff. The SDK does not retry authentication errors, insufficient credits, or unsupported operations.
142
-
143
- If the gateway successfully finishes a request but the response body is too large to replay from the idempotency cache, later calls with the same `idempotencyKey` return `idempotency_replay_unavailable` without running or charging the inference again.
144
-
145
- `timeoutMs` must be positive, `maxRetries` must be a non-negative integer, and `retryBaseMs` must be non-negative. Unknown per-request option keys are rejected so typos do not silently disable idempotency, tracing, timeout, or retry behavior. Invalid values throw `RunInfraError` with `type: "invalid_request_options"` before any network request is sent.
146
-
147
- ## Request validation
148
-
149
- Required request fields are validated before any network request is sent. The model must be a non-blank string, chat messages must be a non-empty array, each chat message must be an object with a non-empty role, Responses input must be a non-empty string or array, Responses input array items must be objects, JSON request bodies must be serializable and contain only finite numbers, embedding input must be a non-empty string or array of non-empty strings, TTS input and image prompts must be non-empty strings, and ASR file must be a Blob. ASR multipart filenames and extra form field names and values are validated before the FormData body is built. Invalid request values throw `RunInfraError` with `type: "invalid_request_options"` and do not reach the gateway or billing path.
150
-
151
- Use per-request options when a call needs a shorter timeout, a trace ID, or a retry-safe idempotency key.
152
- Custom headers are for app metadata only. They cannot override SDK-controlled headers such as `Authorization`, `Content-Type`, `X-Client-Request-Id`, `Idempotency-Key`, `X-RunInfra-SDK`, or `X-RunInfra-SDK-Version`, and they cannot set transport or credential headers such as `Host`, `Cookie`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Proxy-Authorization`, `Api-Key`, `X-API-Key`, `X-Auth-Token`, or `X-Access-Token`.
153
-
154
- ```ts
155
- await client.responses.create(
156
- {
157
- model: "llama-3.1-8b",
158
- input: "Summarize this incident.",
159
- },
160
- {
161
- clientRequestId: crypto.randomUUID(),
162
- idempotencyKey: crypto.randomUUID(),
163
- timeoutMs: 20_000,
164
- maxRetries: 0,
165
- },
166
- );
167
- ```
168
-
169
- ## Typed errors
170
-
171
- The SDK exposes `AuthenticationError`, `PermissionDeniedError`, `RateLimitError`, `InsufficientCreditsError`, `DeploymentError`, `ModelNotFoundError`, `RunInfraTimeoutError`, `RunInfraConnectionError`, `RunInfraStreamParseError`, and `UnsupportedOperationError`.
172
- `RateLimitError` includes `retryAfterMs` when the gateway returns `Retry-After`.
173
- `RunInfraStreamParseError` includes `requestId` when a malformed SSE frame came from a traced gateway response.
174
- `RunInfraTimeoutError` also covers stalled streaming reads, stalled non-streaming JSON body reads, and stalled binary audio `arrayBuffer()` / `blob()` reads after headers arrive, and includes `requestId` when the response was traced.
175
- `RunInfraConnectionError` also covers streaming body transport failures, non-streaming JSON body transport failures, and binary audio `arrayBuffer()` / `blob()` transport failures after headers arrive, and includes `requestId` when the response was traced.
176
-
177
- JSON helpers return typed response objects for the public gateway contract:
178
- `ModelListResponse`, `ModelObject`, `EmbeddingResponse`, `ResponsesCreateResponse`,
179
- `ChatCompletionResponse`, `TranscriptionResponse`, and `ImageGenerationResponse`.
180
- Binary TTS returns `RunInfraAudioResponse`, and streaming calls return `RunInfraStream`.
181
-
182
- ## Traceability
183
-
184
- Every request includes `X-RunInfra-SDK: typescript`, `X-RunInfra-SDK-Version`, and `X-Client-Request-Id`. These headers help support trace requests without changing billing or routing.
185
-
186
- When `idempotencyKey` is provided, the SDK sends it as `Idempotency-Key`. Use a unique value for each logical retry-safe operation. Idempotency keys must be non-blank, ASCII, 255 characters or less, and must not contain secrets or personal data.
187
-
188
- Successful JSON object responses include `_request_id` when the gateway returns `x-request-id`. Streaming responses expose the same value as `stream.requestId`, malformed stream frames raise `RunInfraStreamParseError` with that request id, and binary audio responses expose it as `response.requestId`. Log that value with production errors and customer support reports.
189
-
190
- ## Webhook verification
191
-
192
- Public webhook delivery routes are not shipped yet, but the SDK includes local verification helpers for signed RunInfra webhook deliveries once you receive them in your own server. Always verify the exact raw body before parsing JSON. The `RunInfra-Signature` timestamp must be a non-negative integer Unix second.
193
-
194
- ```ts
195
- import {
196
- WebhookVerificationError,
197
- constructWebhookEvent,
198
- verifyWebhookSignature,
199
- } from "@runinfra/sdk";
200
-
201
- const webhookSecret = process.env.RUNINFRA_WEBHOOK_SECRET;
202
- if (!webhookSecret?.trim()) throw new Error("Set RUNINFRA_WEBHOOK_SECRET before verifying webhook events.");
203
-
204
- const event = constructWebhookEvent({
205
- payload: rawBody,
206
- signatureHeader: request.headers.get("RunInfra-Signature") ?? "",
207
- secret: webhookSecret,
208
- });
209
- ```
210
-
211
- `constructWebhookEvent` verifies the signature, checks timestamp tolerance, and parses JSON. Use `verifyWebhookSignature` when your framework parses JSON separately and you only need to validate the raw delivery. Invalid signatures, stale timestamps, and invalid webhook JSON raise `WebhookVerificationError`.
212
-
213
- ## OpenAI-compatible clients
214
-
215
- OpenAI-compatible clients can use the same verified base URL:
216
-
217
- ```ts
218
- import OpenAI from "openai";
219
-
220
- const apiKey = process.env.RUNINFRA_API_KEY;
221
- if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
222
-
223
- const client = new OpenAI({
224
- apiKey,
225
- baseURL: "https://api.runinfra.ai/v1/pipe_123",
226
- });
227
- ```
228
-
229
- ## Production promotion
230
-
231
- Local package tests prove SDK shape, retry behavior, streaming parsing, and
232
- typed errors. They do not prove that a newly optimized deployment is ready for
233
- customers. For production promotion, run the strict live SDK canary gate from
234
- the RunPipe repo against the same base URL and API key you plan to expose. The gate starts with `test:sdk-live-api-key`, which verifies the plaintext key hashes to an active workspace-scoped `api_keys` row before any paid inference canary runs:
235
-
236
- ```bash
237
- pnpm verify:sdk-release
238
- pnpm test:sdk-canary:live -- --print-env-template
239
- pnpm test:sdk-canary:live -- --env-file .env.sdk-live.local --print-env-status
240
- pnpm sync:sdk-live-env -- --source .env.local --target .env.sdk-live.local
241
- pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json
242
- pnpm bootstrap:sdk-live-key -- --env-file .env.sdk-live.local
243
- pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json
244
- pnpm prepare:sdk-live-env -- --discovery-report artifacts/sdk/live-targets-discovery.json --output .env.sdk-live.local
245
- pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json
246
- pnpm verify:sdk-live-targets -- --env-file .env.sdk-live.local --require-available --discovery-report artifacts/sdk/live-targets-discovery.json
247
- pnpm test:sdk-canary:live -- --env-file .env.sdk-live.local --check-env-only
248
- pnpm test:sdk-canary:live -- --env-file .env.sdk-live.local --discovery-report artifacts/sdk/live-targets-discovery.json --report artifacts/sdk/live-canary.json
249
- pnpm verify:sdk-live-report -- artifacts/sdk/live-canary.json
250
- pnpm test:sdk-canary -- --env-file .env.sdk-live.local --report artifacts/sdk/native-focused-smoke.json
251
- pnpm test:openai-compat -- --env-file .env.sdk-live.local --report artifacts/sdk/openai-focused-smoke.json
252
- pnpm verify:sdk-goal -- --release-report artifacts/sdk/release-verification.json --live-report artifacts/sdk/live-canary.json --live-targets-report artifacts/sdk/live-targets-discovery.json --env-check-report artifacts/sdk/live-canary-env-check.json --focused-smoke-report artifacts/sdk/native-focused-smoke.json --openai-focused-smoke-report artifacts/sdk/openai-focused-smoke.json --report artifacts/sdk/goal-readiness.json
253
- pnpm verify:sdk-publish -- --release-report artifacts/sdk/release-verification.json --goal-report artifacts/sdk/goal-readiness.json --live-report artifacts/sdk/live-canary.json --live-targets-report artifacts/sdk/live-targets-discovery.json --env-check-report artifacts/sdk/live-canary-env-check.json --focused-smoke-report artifacts/sdk/native-focused-smoke.json --openai-focused-smoke-report artifacts/sdk/openai-focused-smoke.json --report artifacts/sdk/publish-readiness.json
254
- ```
255
-
256
- Save the printed template as `.env.sdk-live.local`; it is ignored by git and
257
- should contain the real production gateway, workspace-scoped API key, database
258
- URL, pipeline-scoped API key for the optimized LLM pipeline, `RUNPOD_API_KEY`,
259
- deployed model IDs, the optimized LLM `TEST_PIPELINE_ID`, TTS proof inputs, and
260
- ASR clip path. `RUNPOD_API_KEY` is
261
- used only by discovery to prove checked RunPod endpoint inventory. A checked
262
- inventory needs endpointCount greater than zero, and `endpointCount: 0` blocks
263
- promotion even if old database rows still mention active deployments. Discovery
264
- also blocks any selected target with `endpoint_not_in_runpod_inventory` and
265
- emits `runpod_endpoint_inventory_empty` when RunPod returns no endpoints. For
266
- operator handoffs, set optional `RUNPOD_EXPECTED_ENDPOINT_IDS` to a
267
- comma-separated list of endpoint IDs. Discovery compares those IDs against the
268
- same checked inventory and reports only redacted verified or missing endpoint
269
- IDs, so a wrong RunPod account/scope becomes an explicit blocker.
270
- For TTS, set either `TEST_TTS_VOICE` or both `TEST_TTS_REF_AUDIO` and
271
- `TEST_TTS_REF_TEXT` for Base/voice-cloning models.
272
- `sync:sdk-live-env` copies `RUNPOD_API_KEY` from the source env file when it is
273
- present. If you keep the RunPod key only in the shell, discovery uses that
274
- process value instead of the generated placeholder in `.env.sdk-live.local`.
275
- Use `--print-env-status` before running the canary to see missing, placeholder,
276
- or invalid fields without printing API keys, database URLs, or file paths. Use `pnpm sync:sdk-live-env -- --source .env.local --target .env.sdk-live.local` to copy whitelisted local values such as `DATABASE_URL` without printing secrets, then use `pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json` to inspect
277
- which `active_verified` deployments can satisfy strict modality coverage without
278
- printing API keys, key hashes, or database credentials. Deployments that are
279
- close but not promotable appear under redacted `nearEligibleTargets` with
280
- reasons such as `status_not_active_verified`, `missing_inference_url`, or
281
- `missing_endpoint_id`. The discovery report also includes `nextActions`, so
282
- deployment and SDK agents can follow safe commands without scraping error text.
283
- A skipped probe is diagnostic only. It means discovery intentionally avoided a
284
- live inference call after an earlier eligibility failure; only `passed` probes can promote `targets_available`.
285
- After discovery reports eligible `active_verified` targets, `pnpm bootstrap:sdk-live-key -- --env-file .env.sdk-live.local` can create a workspace-scoped key for that workspace, store only its hash in the database, and write the plaintext once into the ignored live env file without printing it. Rerun discovery after bootstrap so the report proves the selected workspace now has an active workspace-scoped key.
286
- When discovery is complete, use
287
- `pnpm prepare:sdk-live-env -- --discovery-report artifacts/sdk/live-targets-discovery.json --output .env.sdk-live.local`
288
- to fill the deployment model IDs and the optimized LLM `TEST_PIPELINE_ID`, then rerun `discover:sdk-live-targets` against the prepared env file.
289
- `prepare:sdk-live-env` cannot recover a one-time plaintext pipeline secret. Set
290
- `RUNINFRA_PIPELINE_API_KEY` from the Deploy tab for `TEST_PIPELINE_ID` before
291
- strict live canaries, while keeping `RUNINFRA_API_KEY` workspace-scoped for
292
- billing and flat-route verification.
293
- Before running live canaries, run
294
- `pnpm verify:sdk-live-targets -- --env-file .env.sdk-live.local --require-available --discovery-report artifacts/sdk/live-targets-discovery.json`
295
- against the prepared-env discovery report to validate that it is redacted, same-workspace, uses exact live env values, and only promotes callable `active_verified` targets.
296
- If the output file already has `RUNINFRA_API_KEY`, `RUNINFRA_PIPELINE_API_KEY`,
297
- `DATABASE_URL`, `TEST_ASR_FILE`, or local TTS reference inputs, the helper
298
- preserves them and does not print them.
299
-
300
- That gate must cover LLM, embeddings, image, TTS, and ASR endpoints before the
301
- deployment is treated as production verified. Those strict modality targets must
302
- be distinct deployed model IDs in the same workspace, because the promotion
303
- canary uses one workspace-scoped key and then proves billing for every reported
304
- model. The generated live report also records the SDK version and source digest,
305
- so stale canaries cannot promote a newer SDK build.
306
- Focused `pnpm test:sdk-canary -- --report ...` smoke reports also record the
307
- same SDK / Docs / Engine source digest and stay redacted. The raw
308
- OpenAI-compatible focused smoke writes `artifacts/sdk/openai-focused-smoke.json`
309
- and the native SDK smoke writes `artifacts/sdk/native-focused-smoke.json`.
310
- `verify:sdk-goal` rejects either focused smoke report when it was generated from older source,
311
- so focused LLM debugging evidence cannot be reused as fresh promotion evidence.
312
- Each canary result also records redacted `checks` for the required proof checks
313
- it emitted. If a canary exits successfully but misses a required proof line, the
314
- strict report records `missingChecks` and stays blocked. The runner only counts
315
- a proof line when the child canary prints `[ OK ] <required check>`; `[FAIL]` lines do not satisfy promotion evidence. The proof set covers model discovery
316
- and retrieval, LLM responses and streaming,
317
- pipeline-scoped native SDK responses, OpenAI-compatible pipeline-scoped `/v1/responses`, embeddings vectors, image data, TTS audio bytes, ASR transcription text,
318
- OpenAI-compatible auth and error paths, native SDK typed `AuthenticationError`
319
- mapping, request ID propagation, unsupported webhook guards, API key scope, and
320
- billing usage verification. OpenAI-compatible security checks also prove request tracing, HSTS, `nosniff`, path traversal blocking, invalid model 404, missing model 400, and auth failures before publish promotion can pass.
321
- The live-target gate also requires checked RunPod endpoint inventory before
322
- promotion. `selectedTargets.*.runpodEndpointVerified` must be true for every
323
- strict modality.
324
-
325
- Use registry trusted publishing first. Do not provide NPM or PyPI publish tokens.
326
- Registry tokens are not used; publish through GitHub trusted publishing only. If
327
- trusted publishing is unavailable, do not publish until the registry identity is fixed.
328
- The publish-readiness report ties the local release verification,
329
- goal-readiness report, live-target discovery report, and strict live canary
330
- report, plus both focused smoke reports, to the same source digest.
331
- The TypeScript package also runs the same publish-readiness gate from
332
- `prepublishOnly`, so a direct `npm publish` is blocked until that report passes.
333
- Use `pnpm prepare:sdk-publish` to build the npm package, Python wheel, and
334
- Python sdist only after publish readiness passes; the command writes a
335
- source-digest-tied manifest with artifact SHA-256 hashes, byte counts, and
336
- checksummed release / goal / live-target / live-canary proof reports at
337
- `artifacts/sdk/publish/publish-artifacts.json`.
338
- Use `pnpm publish:sdk -- --dry-run` to validate that manifest and print the npm
339
- trusted-publishing and PyPI action handoff without sending packages. The guarded publish wrapper
340
- refuses `--execute` outside CI, validates artifact checksums again, and supports
341
- npm trusted publishing through GitHub OIDC on the Node 22.14.0 publish workflow;
342
- PyPI should be uploaded by `pypa/gh-action-pypi-publish` in the `SDK Publish`
343
- workflow.
344
- GitHub Actions has two SDK-only workflows for the same path. `SDK Release Gate`
345
- runs `pnpm verify:sdk-release` and requires `RUNINFRA_SDK_CI_TOKEN` with
346
- read-only access to the docs and Engine contract repositories. `SDK Publish` is
347
- manual only, defaults to `publish: false`, runs `verify:sdk-release`, creates
348
- the strict live SDK env from GitHub secrets, discovers `active_verified` targets,
349
- prepares the modality env, runs strict live canaries, verifies goal and publish
350
- readiness, prepares artifacts, runs `publish:sdk -- --dry-run`, then uploads the
351
- proof reports and package artifacts. The verification job has no registry OIDC permission;
352
- the npm and PyPI publish jobs download the checked artifacts and are the only
353
- jobs with registry trusted publishing identity. The npm publish job uses GitHub environment `npm`;
354
- the PyPI publish job revalidates the publish manifest before upload and uses GitHub environment `pypi`. The live proof secrets are
355
- `RUNINFRA_SDK_LIVE_API_KEY`, `RUNINFRA_SDK_LIVE_DATABASE_URL`, `RUNPOD_API_KEY`, and
356
- `RUNINFRA_SDK_LIVE_ASR_FILE_BASE64`; voice-less Base TTS canaries can also set
357
- `RUNINFRA_SDK_LIVE_TTS_REF_AUDIO` and `RUNINFRA_SDK_LIVE_TTS_REF_TEXT`. Only
358
- after those gates pass should a maintainer rerun it with `publish: true`; npm
359
- and PyPI must use trusted publishers.
360
- `pnpm verify:sdk-release` also runs SDK secret hygiene and fails if non-test
361
- handoff docs or release files contain full-shaped RunInfra keys, service tokens,
362
- or package publish tokens.
363
-
364
- Co-located voice pipelines are available through the native `client.voice.pipeline.create()` helper on pipeline-scoped keys. The helper posts binary audio to the verified `/pipeline` route and returns the JSON transcript / response envelope. Public webhook create/list calls are intentionally unavailable until their gateway routes are verified, and the SDK throws `UnsupportedOperationError` locally for those webhook capabilities without making a request.
1
+ # RunInfra TypeScript SDK
2
+
3
+ Access optimized RunInfra deployments through the verified public gateway.
4
+
5
+ Requires Node.js 18 or newer.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @runinfra/sdk
11
+ ```
12
+
13
+ ## Modality status (v0.1.1)
14
+
15
+ This SDK is in **beta**. The surfaces below have different verification levels:
16
+
17
+ | Modality | Surface | Status |
18
+ |---|---|---|
19
+ | LLM | `client.chat.completions.create`, `client.responses.create` | Beta, contract-tested |
20
+ | Embeddings | `client.embeddings.create` | Beta, contract-tested |
21
+ | Images | `client.images.generate` | **Experimental**, not live-canary verified |
22
+ | Audio (TTS) | `client.audio.speech.create` | **Experimental**, not live-canary verified |
23
+ | Audio (ASR) | `client.audio.transcriptions.create` | **Experimental**, not live-canary verified |
24
+ | Webhooks | `client.webhooks.*` | Local verification helpers only; remote delivery not shipped |
25
+ | Voice pipeline | `client.voice.pipeline.create` | Not shipped; throws `UnsupportedOperationError` |
26
+
27
+ The HTTP envelopes for experimental surfaces match the OpenAI API contract,
28
+ but we haven't yet completed a full end-to-end live-canary deployment for
29
+ those modalities in the public gateway. They will reach GA in v1.0.0 once
30
+ the canary suite covers all five modalities. Test against your own deployed
31
+ models before using experimental surfaces in production.
32
+
33
+ ## Create a client
34
+
35
+ Use a workspace-scoped key to reach verified active deployments through the `model` field.
36
+ In RunPipe, open Settings, API Keys, Create key, and keep Scope set to Workspace.
37
+
38
+ The Deploy tab can create a pipeline-scoped key for one optimized pipeline.
39
+ The one-time secret is shown once after creation. Store it as `RUNINFRA_API_KEY`
40
+ for app snippets before leaving the page. For repo live canaries, keep the
41
+ workspace key in `RUNINFRA_API_KEY` and put the pipeline-scoped key for
42
+ `TEST_PIPELINE_ID` in `RUNINFRA_PIPELINE_API_KEY` so flat and pipeline routes
43
+ are verified independently.
44
+
45
+ After a runbook finishes in RunPipe, choose Open Deploy from the runbook handoff.
46
+ Deploy only shows SDK operations that the verified endpoint supports, so copy
47
+ the native or OpenAI-compatible snippet from there instead of guessing a route.
48
+
49
+ ```ts
50
+ import { RunInfra } from "@runinfra/sdk";
51
+
52
+ const apiKey = process.env.RUNINFRA_API_KEY;
53
+ if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
54
+
55
+ const client = new RunInfra({
56
+ apiKey,
57
+ });
58
+ ```
59
+
60
+ Use `pipelineId` when the key or integration should be locked to one optimized pipeline.
61
+
62
+ ```ts
63
+ const apiKey = process.env.RUNINFRA_API_KEY;
64
+ if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
65
+
66
+ const client = new RunInfra({
67
+ apiKey,
68
+ pipelineId: "pipe_123",
69
+ });
70
+ ```
71
+
72
+ The default base URL is `https://api.runinfra.ai/v1`.
73
+ `pipelineId` is trimmed and URL-encoded before it is added to the base URL. Use either `pipelineId` with the default base URL, or a pipeline-scoped `baseURL` such as `https://api.runinfra.ai/v1/pipe_123`. If both point to the same pipeline, the SDK keeps the URL scoped once.
74
+ RunPipe generated native SDK snippets prefer `pipelineId` with the root `https://api.runinfra.ai/v1` base URL. OpenAI-compatible snippets use the pipeline-scoped base URL because the OpenAI SDK has no RunInfra pipeline option.
75
+ Custom base URLs must use `http` or `https`. Other schemes and malformed URLs are rejected before a bearer API key can be sent.
76
+ Remote custom base URLs must use `https`. Plain `http` is accepted only for local development hosts: `localhost`, `127.0.0.1`, `0.0.0.0`, and `[::1]`.
77
+ Custom base URLs must not include usernames or passwords.
78
+ Custom base URLs must not include query strings or fragments.
79
+
80
+ ## Server-side only
81
+
82
+ The TypeScript SDK targets Node.js 18 or newer. RunInfra API keys are bearer secrets. Do not initialize this SDK in browser code with a secret API key. The SDK fails closed when it detects a browser runtime; keep calls on a Node.js server route, API service, or backend job. If you are deliberately using a controlled non-public browser-like runtime, pass `dangerouslyAllowBrowser: true` and own that risk.
83
+
84
+ Unknown TypeScript client option keys are rejected so typos such as `baseUrl` or `api_key` do not silently change the gateway, authentication, timeout, retry, or runtime-safety behavior. Use `baseURL` for custom server-side gateway URLs.
85
+
86
+ ## Responses and streaming
87
+
88
+ ```ts
89
+ const stream = await client.responses.create({
90
+ model: "llama-3.1-8b",
91
+ input: "Hello",
92
+ max_output_tokens: 512,
93
+ stream: true,
94
+ });
95
+
96
+ for await (const event of stream) {
97
+ if (event.type === "response.output_text.delta") {
98
+ process.stdout.write(event.delta ?? "");
99
+ }
100
+ }
101
+
102
+ console.log(stream.requestId);
103
+ ```
104
+
105
+ ## Supported public routes
106
+
107
+ - `models.list()`
108
+ - `models.retrieve(model)`
109
+ - `responses.create()`
110
+ - `chat.completions.create()`
111
+ - `embeddings.create()`
112
+ - `audio.speech.create()`
113
+ - `audio.transcriptions.create()`
114
+ - `images.generate()`
115
+ - `voice.pipeline.create()`
116
+
117
+ ## Text to speech
118
+
119
+ TTS deployments can expose named voices or Base/reference-audio voice cloning.
120
+ Use `RUNINFRA_TTS_VOICE` when the deployment lists a voice or speaker. Use
121
+ `RUNINFRA_TTS_REF_AUDIO` and `RUNINFRA_TTS_REF_TEXT` when the deployment expects
122
+ reference-audio input.
123
+
124
+ ```ts
125
+ const voice = process.env.RUNINFRA_TTS_VOICE?.trim();
126
+ const refAudio = process.env.RUNINFRA_TTS_REF_AUDIO?.trim();
127
+ const refText = process.env.RUNINFRA_TTS_REF_TEXT?.trim();
128
+ const taskType = process.env.RUNINFRA_TTS_TASK_TYPE?.trim() || "Base";
129
+
130
+ const speechVoice = voice
131
+ ? { voice }
132
+ : refAudio && refText
133
+ ? { ref_audio: refAudio, ref_text: refText, task_type: taskType }
134
+ : null;
135
+
136
+ if (!speechVoice) {
137
+ throw new Error("Set RUNINFRA_TTS_VOICE, or RUNINFRA_TTS_REF_AUDIO and RUNINFRA_TTS_REF_TEXT.");
138
+ }
139
+
140
+ const audio = await client.audio.speech.create({
141
+ model: "your-tts-model-id",
142
+ input: "Hello from your optimized RunInfra endpoint.",
143
+ ...speechVoice,
144
+ });
145
+ ```
146
+
147
+ ## Timeouts and retries
148
+
149
+ ```ts
150
+ const apiKey = process.env.RUNINFRA_API_KEY;
151
+ if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
152
+
153
+ const client = new RunInfra({
154
+ apiKey,
155
+ timeoutMs: 60_000,
156
+ maxRetries: 2,
157
+ retryBaseMs: 250,
158
+ });
159
+ ```
160
+
161
+ The SDK retries transient transport failures and `408`, `409`, `429`, `500`, `502`, `503`, and `504` responses for safe `GET` requests. Charge-bearing `POST` inference requests retry only when you provide `idempotencyKey`, and automatic POST retries are limited to non-streaming JSON calls whose gateway responses can be replayed safely. That covers `responses.create()`, non-streaming `chat.completions.create()`, `embeddings.create()`, and `images.generate()`. Streaming calls, binary TTS responses, and multipart ASR uploads are sent once even when you provide an idempotency key. The gateway still binds idempotency keys for TTS and ASR, so a manual retry with the same key will not run or charge a second inference after the first request settles. Automatic retries honor reasonable `Retry-After` values up to 60 seconds when the header is a plain integer second value or HTTP-date, then fall back to bounded exponential backoff. The SDK does not retry authentication errors, insufficient credits, or unsupported operations.
162
+
163
+ If the gateway successfully finishes a request but the response body is too large to replay from the idempotency cache, later calls with the same `idempotencyKey` return `idempotency_replay_unavailable` without running or charging the inference again.
164
+
165
+ `timeoutMs` must be positive, `maxRetries` must be a non-negative integer, and `retryBaseMs` must be non-negative. Unknown per-request option keys are rejected so typos do not silently disable idempotency, tracing, timeout, or retry behavior. Invalid values throw `RunInfraError` with `type: "invalid_request_options"` before any network request is sent.
166
+
167
+ ## Request validation
168
+
169
+ Required request fields are validated before any network request is sent. The model must be a non-blank string, chat messages must be a non-empty array, each chat message must be an object with a non-empty role, Responses input must be a non-empty string or array, Responses input array items must be objects, JSON request bodies must be serializable and contain only finite numbers, embedding input must be a non-empty string or array of non-empty strings, TTS input and image prompts must be non-empty strings, and ASR file must be a Blob. ASR multipart filenames and extra form field names and values are validated before the FormData body is built. Invalid request values throw `RunInfraError` with `type: "invalid_request_options"` and do not reach the gateway or billing path.
170
+
171
+ Use per-request options when a call needs a shorter timeout, a trace ID, or a retry-safe idempotency key.
172
+ Custom headers are for app metadata only. They cannot override SDK-controlled headers such as `Authorization`, `Content-Type`, `X-Client-Request-Id`, `Idempotency-Key`, `X-RunInfra-SDK`, or `X-RunInfra-SDK-Version`, and they cannot set transport or credential headers such as `Host`, `Cookie`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Proxy-Authorization`, `Api-Key`, `X-API-Key`, `X-Auth-Token`, or `X-Access-Token`.
173
+
174
+ ```ts
175
+ await client.responses.create(
176
+ {
177
+ model: "llama-3.1-8b",
178
+ input: "Summarize this incident.",
179
+ },
180
+ {
181
+ clientRequestId: crypto.randomUUID(),
182
+ idempotencyKey: crypto.randomUUID(),
183
+ timeoutMs: 20_000,
184
+ maxRetries: 0,
185
+ },
186
+ );
187
+ ```
188
+
189
+ ## Typed errors
190
+
191
+ The SDK exposes `AuthenticationError`, `PermissionDeniedError`, `RateLimitError`, `InsufficientCreditsError`, `DeploymentError`, `ModelNotFoundError`, `RunInfraTimeoutError`, `RunInfraConnectionError`, `RunInfraStreamParseError`, and `UnsupportedOperationError`.
192
+ `RateLimitError` includes `retryAfterMs` when the gateway returns `Retry-After`.
193
+ `RunInfraStreamParseError` includes `requestId` when a malformed SSE frame came from a traced gateway response.
194
+ `RunInfraTimeoutError` also covers stalled streaming reads, stalled non-streaming JSON body reads, and stalled binary audio `arrayBuffer()` / `blob()` reads after headers arrive, and includes `requestId` when the response was traced.
195
+ `RunInfraConnectionError` also covers streaming body transport failures, non-streaming JSON body transport failures, and binary audio `arrayBuffer()` / `blob()` transport failures after headers arrive, and includes `requestId` when the response was traced.
196
+
197
+ JSON helpers return typed response objects for the public gateway contract:
198
+ `ModelListResponse`, `ModelObject`, `EmbeddingResponse`, `ResponsesCreateResponse`,
199
+ `ChatCompletionResponse`, `TranscriptionResponse`, and `ImageGenerationResponse`.
200
+ Binary TTS returns `RunInfraAudioResponse`, and streaming calls return `RunInfraStream`.
201
+
202
+ ## Traceability
203
+
204
+ Every request includes `X-RunInfra-SDK: typescript`, `X-RunInfra-SDK-Version`, and `X-Client-Request-Id`. These headers help support trace requests without changing billing or routing.
205
+
206
+ When `idempotencyKey` is provided, the SDK sends it as `Idempotency-Key`. Use a unique value for each logical retry-safe operation. Idempotency keys must be non-blank, ASCII, 255 characters or less, and must not contain secrets or personal data.
207
+
208
+ Successful JSON object responses include `_request_id` when the gateway returns `x-request-id`. Streaming responses expose the same value as `stream.requestId`, malformed stream frames raise `RunInfraStreamParseError` with that request id, and binary audio responses expose it as `response.requestId`. Log that value with production errors and customer support reports.
209
+
210
+ ## Webhook verification
211
+
212
+ Public webhook delivery routes are not shipped yet, but the SDK includes local verification helpers for signed RunInfra webhook deliveries once you receive them in your own server. Always verify the exact raw body before parsing JSON. The `RunInfra-Signature` timestamp must be a non-negative integer Unix second.
213
+
214
+ ```ts
215
+ import {
216
+ WebhookVerificationError,
217
+ constructWebhookEvent,
218
+ verifyWebhookSignature,
219
+ } from "@runinfra/sdk";
220
+
221
+ const webhookSecret = process.env.RUNINFRA_WEBHOOK_SECRET;
222
+ if (!webhookSecret?.trim()) throw new Error("Set RUNINFRA_WEBHOOK_SECRET before verifying webhook events.");
223
+
224
+ const event = constructWebhookEvent({
225
+ payload: rawBody,
226
+ signatureHeader: request.headers.get("RunInfra-Signature") ?? "",
227
+ secret: webhookSecret,
228
+ });
229
+ ```
230
+
231
+ `constructWebhookEvent` verifies the signature, checks timestamp tolerance, and parses JSON. Use `verifyWebhookSignature` when your framework parses JSON separately and you only need to validate the raw delivery. Invalid signatures, stale timestamps, and invalid webhook JSON raise `WebhookVerificationError`.
232
+
233
+ ## OpenAI-compatible clients
234
+
235
+ OpenAI-compatible clients can use the same verified base URL:
236
+
237
+ ```ts
238
+ import OpenAI from "openai";
239
+
240
+ const apiKey = process.env.RUNINFRA_API_KEY;
241
+ if (!apiKey) throw new Error("Set RUNINFRA_API_KEY before running this snippet.");
242
+
243
+ const client = new OpenAI({
244
+ apiKey,
245
+ baseURL: "https://api.runinfra.ai/v1/pipe_123",
246
+ });
247
+ ```
248
+
249
+ ## Production promotion
250
+
251
+ Local package tests prove SDK shape, retry behavior, streaming parsing, and
252
+ typed errors. They do not prove that a newly optimized deployment is ready for
253
+ customers. For production promotion, run the strict live SDK canary gate from
254
+ the RunPipe repo against the same base URL and API key you plan to expose. The gate starts with `test:sdk-live-api-key`, which verifies the plaintext key hashes to an active workspace-scoped `api_keys` row before any paid inference canary runs:
255
+
256
+ ```bash
257
+ pnpm verify:sdk-release
258
+ pnpm test:sdk-canary:live -- --print-env-template
259
+ pnpm test:sdk-canary:live -- --env-file .env.sdk-live.local --print-env-status
260
+ pnpm sync:sdk-live-env -- --source .env.local --target .env.sdk-live.local
261
+ pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json
262
+ pnpm bootstrap:sdk-live-key -- --env-file .env.sdk-live.local
263
+ pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json
264
+ pnpm prepare:sdk-live-env -- --discovery-report artifacts/sdk/live-targets-discovery.json --output .env.sdk-live.local
265
+ pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json
266
+ pnpm verify:sdk-live-targets -- --env-file .env.sdk-live.local --require-available --discovery-report artifacts/sdk/live-targets-discovery.json
267
+ pnpm test:sdk-canary:live -- --env-file .env.sdk-live.local --check-env-only
268
+ pnpm test:sdk-canary:live -- --env-file .env.sdk-live.local --discovery-report artifacts/sdk/live-targets-discovery.json --report artifacts/sdk/live-canary.json
269
+ pnpm verify:sdk-live-report -- artifacts/sdk/live-canary.json
270
+ pnpm test:sdk-canary -- --env-file .env.sdk-live.local --report artifacts/sdk/native-focused-smoke.json
271
+ pnpm test:openai-compat -- --env-file .env.sdk-live.local --report artifacts/sdk/openai-focused-smoke.json
272
+ pnpm verify:sdk-goal -- --release-report artifacts/sdk/release-verification.json --live-report artifacts/sdk/live-canary.json --live-targets-report artifacts/sdk/live-targets-discovery.json --env-check-report artifacts/sdk/live-canary-env-check.json --focused-smoke-report artifacts/sdk/native-focused-smoke.json --openai-focused-smoke-report artifacts/sdk/openai-focused-smoke.json --report artifacts/sdk/goal-readiness.json
273
+ pnpm verify:sdk-publish -- --release-report artifacts/sdk/release-verification.json --goal-report artifacts/sdk/goal-readiness.json --live-report artifacts/sdk/live-canary.json --live-targets-report artifacts/sdk/live-targets-discovery.json --env-check-report artifacts/sdk/live-canary-env-check.json --focused-smoke-report artifacts/sdk/native-focused-smoke.json --openai-focused-smoke-report artifacts/sdk/openai-focused-smoke.json --report artifacts/sdk/publish-readiness.json
274
+ ```
275
+
276
+ Save the printed template as `.env.sdk-live.local`; it is ignored by git and
277
+ should contain the real production gateway, workspace-scoped API key, database
278
+ URL, pipeline-scoped API key for the optimized LLM pipeline, `RUNPOD_API_KEY`,
279
+ deployed model IDs, the optimized LLM `TEST_PIPELINE_ID`, TTS proof inputs, and
280
+ ASR clip path. `RUNPOD_API_KEY` is
281
+ used only by discovery to prove checked RunPod endpoint inventory. A checked
282
+ inventory needs endpointCount greater than zero, and `endpointCount: 0` blocks
283
+ promotion even if old database rows still mention active deployments. Discovery
284
+ also blocks any selected target with `endpoint_not_in_runpod_inventory` and
285
+ emits `runpod_endpoint_inventory_empty` when RunPod returns no endpoints. For
286
+ operator handoffs, set optional `RUNPOD_EXPECTED_ENDPOINT_IDS` to a
287
+ comma-separated list of endpoint IDs. Discovery compares those IDs against the
288
+ same checked inventory and reports only redacted verified or missing endpoint
289
+ IDs, so a wrong RunPod account/scope becomes an explicit blocker.
290
+ For TTS, set either `TEST_TTS_VOICE` or both `TEST_TTS_REF_AUDIO` and
291
+ `TEST_TTS_REF_TEXT` for Base/voice-cloning models.
292
+ `sync:sdk-live-env` copies `RUNPOD_API_KEY` from the source env file when it is
293
+ present. If you keep the RunPod key only in the shell, discovery uses that
294
+ process value instead of the generated placeholder in `.env.sdk-live.local`.
295
+ Use `--print-env-status` before running the canary to see missing, placeholder,
296
+ or invalid fields without printing API keys, database URLs, or file paths. Use `pnpm sync:sdk-live-env -- --source .env.local --target .env.sdk-live.local` to copy whitelisted local values such as `DATABASE_URL` without printing secrets, then use `pnpm discover:sdk-live-targets -- --env-file .env.sdk-live.local --probe-inference --report artifacts/sdk/live-targets-discovery.json` to inspect
297
+ which `active_verified` deployments can satisfy strict modality coverage without
298
+ printing API keys, key hashes, or database credentials. Deployments that are
299
+ close but not promotable appear under redacted `nearEligibleTargets` with
300
+ reasons such as `status_not_active_verified`, `missing_inference_url`, or
301
+ `missing_endpoint_id`. The discovery report also includes `nextActions`, so
302
+ deployment and SDK agents can follow safe commands without scraping error text.
303
+ A skipped probe is diagnostic only. It means discovery intentionally avoided a
304
+ live inference call after an earlier eligibility failure; only `passed` probes can promote `targets_available`.
305
+ After discovery reports eligible `active_verified` targets, `pnpm bootstrap:sdk-live-key -- --env-file .env.sdk-live.local` can create a workspace-scoped key for that workspace, store only its hash in the database, and write the plaintext once into the ignored live env file without printing it. Rerun discovery after bootstrap so the report proves the selected workspace now has an active workspace-scoped key.
306
+ When discovery is complete, use
307
+ `pnpm prepare:sdk-live-env -- --discovery-report artifacts/sdk/live-targets-discovery.json --output .env.sdk-live.local`
308
+ to fill the deployment model IDs and the optimized LLM `TEST_PIPELINE_ID`, then rerun `discover:sdk-live-targets` against the prepared env file.
309
+ `prepare:sdk-live-env` cannot recover a one-time plaintext pipeline secret. Set
310
+ `RUNINFRA_PIPELINE_API_KEY` from the Deploy tab for `TEST_PIPELINE_ID` before
311
+ strict live canaries, while keeping `RUNINFRA_API_KEY` workspace-scoped for
312
+ billing and flat-route verification.
313
+ Before running live canaries, run
314
+ `pnpm verify:sdk-live-targets -- --env-file .env.sdk-live.local --require-available --discovery-report artifacts/sdk/live-targets-discovery.json`
315
+ against the prepared-env discovery report to validate that it is redacted, same-workspace, uses exact live env values, and only promotes callable `active_verified` targets.
316
+ If the output file already has `RUNINFRA_API_KEY`, `RUNINFRA_PIPELINE_API_KEY`,
317
+ `DATABASE_URL`, `TEST_ASR_FILE`, or local TTS reference inputs, the helper
318
+ preserves them and does not print them.
319
+
320
+ That gate must cover LLM, embeddings, image, TTS, and ASR endpoints before the
321
+ deployment is treated as production verified. Those strict modality targets must
322
+ be distinct deployed model IDs in the same workspace, because the promotion
323
+ canary uses one workspace-scoped key and then proves billing for every reported
324
+ model. The generated live report also records the SDK version and source digest,
325
+ so stale canaries cannot promote a newer SDK build.
326
+ Focused `pnpm test:sdk-canary -- --report ...` smoke reports also record the
327
+ same SDK / Docs / Engine source digest and stay redacted. The raw
328
+ OpenAI-compatible focused smoke writes `artifacts/sdk/openai-focused-smoke.json`
329
+ and the native SDK smoke writes `artifacts/sdk/native-focused-smoke.json`.
330
+ `verify:sdk-goal` rejects either focused smoke report when it was generated from older source,
331
+ so focused LLM debugging evidence cannot be reused as fresh promotion evidence.
332
+ Each canary result also records redacted `checks` for the required proof checks
333
+ it emitted. If a canary exits successfully but misses a required proof line, the
334
+ strict report records `missingChecks` and stays blocked. The runner only counts
335
+ a proof line when the child canary prints `[ OK ] <required check>`; `[FAIL]` lines do not satisfy promotion evidence. The proof set covers model discovery
336
+ and retrieval, LLM responses and streaming,
337
+ pipeline-scoped native SDK responses, OpenAI-compatible pipeline-scoped `/v1/responses`, embeddings vectors, image data, TTS audio bytes, ASR transcription text,
338
+ OpenAI-compatible auth and error paths, native SDK typed `AuthenticationError`
339
+ mapping, request ID propagation, unsupported webhook guards, API key scope, and
340
+ billing usage verification. OpenAI-compatible security checks also prove request tracing, HSTS, `nosniff`, path traversal blocking, invalid model 404, missing model 400, and auth failures before publish promotion can pass.
341
+ The live-target gate also requires checked RunPod endpoint inventory before
342
+ promotion. `selectedTargets.*.runpodEndpointVerified` must be true for every
343
+ strict modality.
344
+
345
+ Use registry trusted publishing first. Do not provide NPM or PyPI publish tokens.
346
+ Registry tokens are not used; publish through GitHub trusted publishing only. If
347
+ trusted publishing is unavailable, do not publish until the registry identity is fixed.
348
+ The publish-readiness report ties the local release verification,
349
+ goal-readiness report, live-target discovery report, and strict live canary
350
+ report, plus both focused smoke reports, to the same source digest.
351
+ The TypeScript package also runs the same publish-readiness gate from
352
+ `prepublishOnly`, so a direct `npm publish` is blocked until that report passes.
353
+ Use `pnpm prepare:sdk-publish` to build the npm package, Python wheel, and
354
+ Python sdist only after publish readiness passes; the command writes a
355
+ source-digest-tied manifest with artifact SHA-256 hashes, byte counts, and
356
+ checksummed release / goal / live-target / live-canary proof reports at
357
+ `artifacts/sdk/publish/publish-artifacts.json`.
358
+ Use `pnpm publish:sdk -- --dry-run` to validate that manifest and print the npm
359
+ trusted-publishing and PyPI action handoff without sending packages. The guarded publish wrapper
360
+ refuses `--execute` outside CI, validates artifact checksums again, and supports
361
+ npm trusted publishing through GitHub OIDC on the Node 22.14.0 publish workflow;
362
+ PyPI should be uploaded by `pypa/gh-action-pypi-publish` in the `SDK Publish`
363
+ workflow.
364
+ GitHub Actions has two SDK-only workflows for the same path. `SDK Release Gate`
365
+ runs `pnpm verify:sdk-release` and requires `RUNINFRA_SDK_CI_TOKEN` with
366
+ read-only access to the docs and Engine contract repositories. `SDK Publish` is
367
+ manual only, defaults to `publish: false`, runs `verify:sdk-release`, creates
368
+ the strict live SDK env from GitHub secrets, discovers `active_verified` targets,
369
+ prepares the modality env, runs strict live canaries, verifies goal and publish
370
+ readiness, prepares artifacts, runs `publish:sdk -- --dry-run`, then uploads the
371
+ proof reports and package artifacts. The verification job has no registry OIDC permission;
372
+ the npm and PyPI publish jobs download the checked artifacts and are the only
373
+ jobs with registry trusted publishing identity. The npm publish job uses GitHub environment `npm`;
374
+ the PyPI publish job revalidates the publish manifest before upload and uses GitHub environment `pypi`. The live proof secrets are
375
+ `RUNINFRA_SDK_LIVE_API_KEY`, `RUNINFRA_SDK_LIVE_DATABASE_URL`, `RUNPOD_API_KEY`, and
376
+ `RUNINFRA_SDK_LIVE_ASR_FILE_BASE64`; voice-less Base TTS canaries can also set
377
+ `RUNINFRA_SDK_LIVE_TTS_REF_AUDIO` and `RUNINFRA_SDK_LIVE_TTS_REF_TEXT`. Only
378
+ after those gates pass should a maintainer rerun it with `publish: true`; npm
379
+ and PyPI must use trusted publishers.
380
+ `pnpm verify:sdk-release` also runs SDK secret hygiene and fails if non-test
381
+ handoff docs or release files contain full-shaped RunInfra keys, service tokens,
382
+ or package publish tokens.
383
+
384
+ Co-located voice pipelines are available through the native `client.voice.pipeline.create()` helper on pipeline-scoped keys. The helper posts binary audio to the verified `/pipeline` route and returns the JSON transcript / response envelope. Public webhook create/list calls are intentionally unavailable until their gateway routes are verified, and the SDK throws `UnsupportedOperationError` locally for those webhook capabilities without making a request.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const RUNINFRA_SDK_VERSION = "0.1.0";
1
+ export declare const RUNINFRA_SDK_VERSION = "0.1.1";
2
2
  export interface RunInfraOptions {
3
3
  apiKey: string;
4
4
  pipelineId?: string;
@@ -252,6 +252,15 @@ export declare class RunInfra {
252
252
  readonly responses: {
253
253
  create: ResponsesCreate;
254
254
  };
255
+ /**
256
+ * Audio surfaces (text-to-speech + speech-to-text).
257
+ *
258
+ * @experimental As of v0.1.1, these methods have NOT been verified end-to-end
259
+ * against a live deployed pipeline in our canary suite. The HTTP envelope
260
+ * matches the OpenAI Audio API contract and the request/response shapes are
261
+ * stable, but you should test against your own deployed model before using
262
+ * in production. Live-canary verification is tracked for v1.0.0 GA.
263
+ */
255
264
  readonly audio: {
256
265
  speech: {
257
266
  create: (request: SpeechRequest, options?: RunInfraRequestOptions) => Promise<RunInfraAudioResponse>;
@@ -264,6 +273,15 @@ export declare class RunInfra {
264
273
  list: (options?: RunInfraRequestOptions) => Promise<ModelListResponse>;
265
274
  retrieve: (model: string, options?: RunInfraRequestOptions) => Promise<ModelObject>;
266
275
  };
276
+ /**
277
+ * Image generation surface.
278
+ *
279
+ * @experimental As of v0.1.1, this method has NOT been verified end-to-end
280
+ * against a live deployed pipeline in our canary suite. The HTTP envelope
281
+ * matches the OpenAI Images API contract, but you should test against your
282
+ * own deployed model before using in production. Live-canary verification
283
+ * is tracked for v1.0.0 GA.
284
+ */
267
285
  readonly images: {
268
286
  generate: (request: ImageGenerateRequest, options?: RunInfraRequestOptions) => Promise<ImageGenerationResponse>;
269
287
  };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHmac, timingSafeEqual } from "node:crypto";
2
- export const RUNINFRA_SDK_VERSION = "0.1.0";
2
+ export const RUNINFRA_SDK_VERSION = "0.1.1";
3
3
  const MAX_AUTOMATIC_RETRY_AFTER_MS = 60_000;
4
4
  export class RunInfraError extends Error {
5
5
  status;
@@ -896,8 +896,26 @@ export class RunInfra {
896
896
  chat;
897
897
  embeddings;
898
898
  responses;
899
+ /**
900
+ * Audio surfaces (text-to-speech + speech-to-text).
901
+ *
902
+ * @experimental As of v0.1.1, these methods have NOT been verified end-to-end
903
+ * against a live deployed pipeline in our canary suite. The HTTP envelope
904
+ * matches the OpenAI Audio API contract and the request/response shapes are
905
+ * stable, but you should test against your own deployed model before using
906
+ * in production. Live-canary verification is tracked for v1.0.0 GA.
907
+ */
899
908
  audio;
900
909
  models;
910
+ /**
911
+ * Image generation surface.
912
+ *
913
+ * @experimental As of v0.1.1, this method has NOT been verified end-to-end
914
+ * against a live deployed pipeline in our canary suite. The HTTP envelope
915
+ * matches the OpenAI Images API contract, but you should test against your
916
+ * own deployed model before using in production. Live-canary verification
917
+ * is tracked for v1.0.0 GA.
918
+ */
901
919
  images;
902
920
  webhooks;
903
921
  voice;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@runinfra/sdk",
3
- "version": "0.1.0",
4
- "description": "RunInfra SDK for optimized inference deployments",
5
- "license": "UNLICENSED",
3
+ "version": "0.1.1",
4
+ "description": "RunInfra SDK for optimized inference deployments (beta; LLM + embeddings tested, image/audio surfaces experimental)",
5
+ "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://runinfra.ai/docs/tools-sdks/runinfra-sdk",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/RightNow-AI/RunPipe.git",
10
- "directory": "sdks/typescript"
9
+ "url": "git+https://github.com/RightNow-AI/runinfra-sdk.git",
10
+ "directory": "typescript"
11
11
  },
12
12
  "bugs": {
13
- "url": "https://github.com/RightNow-AI/RunPipe/issues"
13
+ "url": "https://github.com/RightNow-AI/runinfra-sdk/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "runinfra",
@@ -39,14 +39,21 @@
39
39
  "files": [
40
40
  "dist",
41
41
  "README.md",
42
+ "CHANGELOG.md",
43
+ "LICENSE",
42
44
  "package.json"
43
45
  ],
44
46
  "publishConfig": {
45
47
  "access": "public"
46
48
  },
47
49
  "sideEffects": false,
50
+ "devDependencies": {
51
+ "@types/node": "^22.7.5",
52
+ "typescript": "^5.6.3",
53
+ "vitest": "^2.1.3"
54
+ },
48
55
  "scripts": {
49
- "build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json",
50
- "test": "node ../../node_modules/vitest/vitest.mjs run src/index.test.ts --root ../.."
56
+ "build": "tsc -p tsconfig.json",
57
+ "test": "vitest run src/index.test.ts"
51
58
  }
52
59
  }