realtime-avatar 0.35.0 → 0.36.0

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/README.md CHANGED
@@ -204,6 +204,36 @@ Two facts follow from that picture and drive everything else:
204
204
 
205
205
  ---
206
206
 
207
+ ## Speech without a live call
208
+
209
+ ```ts
210
+ const speech = await rta.createSpeech(voiceId, { text: "Hello!", format: "wav" }, { signal });
211
+ return new Response(speech.bytes, { headers: { "content-type": speech.contentType } });
212
+ ```
213
+
214
+ Available only from the server entries, `createSpeech` wraps the existing HTTP speech endpoint.
215
+ It returns completed audio, **not streaming audio**, and uses **no LiveKit** or live call.
216
+ It does not listen or provide full-duplex conversation; live calls remain full duplex.
217
+
218
+ The exported `createSpeechRequestSchema` owns `CreateSpeechInput`: text is trimmed and must
219
+ contain 1–2,000 characters; `format` defaults to `mp3` (or choose `wav`); optional `speed` is
220
+ 0.5–2 and `language` is a BCP-47 tag. Unknown fields reject. Use a real workspace-accessible
221
+ `vce_…` or `voice_…` ID. `SpeechResult` contains `Uint8Array<ArrayBuffer>` bytes, validated
222
+ `audio/mpeg` or `audio/wav` content type, and nullable `billedBytes`, `billedCredits`, `requestId`.
223
+ Missing metadata stays null; invalid metadata, mismatched media, empty audio or more than
224
+ 24 MiB rejects. Container signatures are checked, not the full audio codec.
225
+
226
+ Existing RTA authorization and billing apply: `speech:write`, a paid workspace or purchased
227
+ credits, and an accessible voice. Billing counts UTF-8 bytes of trimmed text (one credit per
228
+ 90 bytes, rounded up, minimum one). The endpoint stores neither text nor audio; callers may
229
+ save and replay bytes. Limits are 20 requests per minute and one in progress per workspace.
230
+
231
+ **No automatic retries**, regardless of client `maxRetries`: the endpoint is not idempotent,
232
+ and an ambiguous failure may already be billed. `signal`, `timeoutMs` and `totalTimeoutMs`
233
+ cover the request and binary body; an abort does not guarantee that upstream billing stopped.
234
+ Caller aborts propagate, timeout aborts are `TimeoutError`, and HTTP errors use the existing
235
+ `RealtimeAvatarHttpError` class.
236
+
207
237
  ## Custom voice (webhook)
208
238
 
209
239
  Speak a call in your own voice. Each sentence she is about to say is POSTed, signed, to an
@@ -423,6 +453,9 @@ rta.getRecording(recordingId)
423
453
  rta.getRecordingAccess(recordingId)
424
454
  rta.getConnectionHistory(sessionId) // bounded LiveKit observations; requires usage:read
425
455
 
456
+ // completed speech audio; server only, no LiveKit, never retried; requires speech:write
457
+ rta.createSpeech(voiceId, { text, format?, speed?, language? }, { signal? })
458
+
426
459
  // pre-rendered video (MP4, no live call); server only, requires renders:write / renders:read
427
460
  rta.createRender({ avatarId, voiceId? | voice?, lipGain?, shots }) // 202 queued; one Idempotency-Key across retries
428
461
  rta.waitForRender(renderId) // block until ready | failed; RETURNS a failed render, throws only on timeout
@@ -1,4 +1,4 @@
1
- import { RealtimeAvatar, ROUTE_TIMEOUT_MS, proxyEndRequestSchema, proxyConnectRequestSchema, isQueued, RealtimeAvatarHttpError, RealtimeAvatarError } from './chunk-WHYDSORD.js';
1
+ import { RealtimeAvatar, ROUTE_TIMEOUT_MS, proxyEndRequestSchema, proxyConnectRequestSchema, isQueued, RealtimeAvatarHttpError, RealtimeAvatarError } from './chunk-YHNBW3X6.js';
2
2
 
3
3
  // ../http-client/src/generated/error-semantics.ts
4
4
  var ERROR_SEMANTICS = {
@@ -832,6 +832,38 @@ var liveKitSessionReleaseReasonSchema = z.enum([
832
832
  "manual",
833
833
  "idle_timeout"
834
834
  ]);
835
+ var schema08 = z.string().min(1).max(2e3);
836
+ var schema117 = z.enum(["mp3", "wav"]);
837
+ var schema212 = z.number().min(0.5).max(2);
838
+ var schema37 = z.string().regex(new RegExp("^[A-Za-z0-9-]+$")).min(2).max(16);
839
+ var schema47 = z.strictObject({
840
+ "text": z.string().trim().pipe(schema08),
841
+ "format": schema117.optional(),
842
+ "speed": schema212.optional(),
843
+ "language": schema37.optional()
844
+ });
845
+ var schema56 = z.string().regex(new RegExp("^(vce|voice)_"));
846
+ var schema64 = z.number().min(0);
847
+ var schema74 = z.int().min(1);
848
+ var createSpeechRequestSchema = schema47.extend({
849
+ format: schema47.shape.format.unwrap().default("mp3")
850
+ });
851
+ var speechVoiceIdSchema = schema56;
852
+ var speechContentTypeSchema = z.enum(["audio/mpeg", "audio/wav"]);
853
+ var speechResponseHeadersSchema = z.strictObject({
854
+ "X-RTA-Billed-Credits": z.string().regex(/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/).transform(Number).pipe(schema64).nullable(),
855
+ "X-RTA-Billed-Bytes": z.string().regex(/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/).transform(Number).pipe(schema74).nullable()
856
+ });
857
+ function readSpeechHeaders(headers) {
858
+ const parsed = speechResponseHeadersSchema.parse({
859
+ "X-RTA-Billed-Credits": headers.get("X-RTA-Billed-Credits"),
860
+ "X-RTA-Billed-Bytes": headers.get("X-RTA-Billed-Bytes")
861
+ });
862
+ return {
863
+ billedCredits: parsed["X-RTA-Billed-Credits"],
864
+ billedBytes: parsed["X-RTA-Billed-Bytes"]
865
+ };
866
+ }
835
867
 
836
868
  // ../http-client/src/retry.ts
837
869
  var RETRYABLE_STATUS = /* @__PURE__ */ new Set([408, 500, 502, 503, 504]);
@@ -864,43 +896,43 @@ function isTransient(cause) {
864
896
  const name = cause?.name;
865
897
  return name === "TimeoutError" || name === "TypeError" || name === "FetchError";
866
898
  }
867
- var schema08 = z.string().min(1).max(160);
868
- var schema117 = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value));
869
- var schema212 = z.enum(["cartesia", "fish"]);
870
- var schema37 = z.string().min(1).max(240);
871
- var schema47 = z.string().min(1).max(120);
872
- var schema56 = z.number().min(0.5).max(2);
873
- var schema64 = z.null();
874
- var schema74 = z.union([schema56, schema64]);
899
+ var schema09 = z.string().min(1).max(160);
900
+ var schema118 = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value));
901
+ var schema213 = z.enum(["cartesia", "fish"]);
902
+ var schema38 = z.string().min(1).max(240);
903
+ var schema48 = z.string().min(1).max(120);
904
+ var schema57 = z.number().min(0.5).max(2);
905
+ var schema65 = z.null();
906
+ var schema75 = z.union([schema57, schema65]);
875
907
  var schema84 = z.string().min(1).max(80);
876
- var schema94 = z.union([schema84, schema64]);
908
+ var schema94 = z.union([schema84, schema65]);
877
909
  var schema104 = z.string().min(2).max(16);
878
- var schema118 = z.union([schema104, schema64]);
910
+ var schema119 = z.union([schema104, schema65]);
879
911
  var schema124 = z.strictObject({
880
- "provider": schema212,
881
- "voice_id": schema37,
882
- "model": schema47.optional(),
883
- "speed": schema74.optional(),
912
+ "provider": schema213,
913
+ "voice_id": schema38,
914
+ "model": schema48.optional(),
915
+ "speed": schema75.optional(),
884
916
  "emotion": schema94.optional(),
885
- "language": schema118.optional()
917
+ "language": schema119.optional()
886
918
  });
887
919
  var schema134 = z.string().min(8).max(80);
888
920
  var schema144 = z.string();
889
921
  var schema154 = z.enum(["video", "live2d"]);
890
922
  var schema163 = z.enum(["image", "video"]);
891
923
  var schema173 = z.enum(["realtime-avatar-live-v1", "realtime-avatar-video-v1"]);
892
- var schema183 = z.union([schema134, schema64]);
924
+ var schema183 = z.union([schema134, schema65]);
893
925
  var schema193 = z.enum(["draft", "preprocessing", "ready", "failed", "disabled", "deleted"]);
894
- var schema202 = z.union([schema144, schema64]);
895
- var schema213 = z.enum(["none", "queued", "generating", "ready", "failed"]);
926
+ var schema202 = z.union([schema144, schema65]);
927
+ var schema214 = z.enum(["none", "queued", "generating", "ready", "failed"]);
896
928
  var schema222 = z.enum(["local", "gemini", "openai"]);
897
929
  var schema232 = z.string().max(200);
898
- var schema242 = z.union([schema232, schema64]);
930
+ var schema242 = z.union([schema232, schema65]);
899
931
  var schema252 = z.strictObject({
900
932
  "provider": schema222,
901
933
  "model": schema242.optional()
902
934
  });
903
- var schema262 = z.union([schema252, schema64]);
935
+ var schema262 = z.union([schema252, schema65]);
904
936
  var schema272 = z.strictObject({
905
937
  "id": schema134,
906
938
  "tenantId": schema134,
@@ -911,34 +943,34 @@ var schema272 = z.strictObject({
911
943
  "sourceAssetId": schema183,
912
944
  "status": schema193,
913
945
  "error": schema202,
914
- "idleVideoStatus": schema213,
946
+ "idleVideoStatus": schema214,
915
947
  "defaultVoiceId": schema202,
916
948
  "llm": schema262,
917
949
  "createdAt": schema144,
918
950
  "updatedAt": schema144
919
951
  });
920
952
  var createLive2dAvatarInputSchema = z.strictObject({
921
- displayName: schema08,
922
- settings: schema117.optional(),
923
- metadata: schema117.optional(),
953
+ displayName: schema09,
954
+ settings: schema118.optional(),
955
+ metadata: schema118.optional(),
924
956
  voice: schema124
925
957
  });
926
958
  var avatarResponseSchema = schema272;
927
- var schema09 = z.url().regex(new RegExp("^https:\\/\\/")).max(500);
928
- var schema119 = z.string().min(16).max(200);
929
- var schema214 = z.string().min(1).max(200);
930
- var schema38 = z.string().min(2).max(35);
931
- var schema48 = z.literal([8e3, 16e3, 22050, 24e3, 44100, 48e3]);
932
- var schema57 = z.int().min(1e3).max(15e3);
933
- var schema65 = z.strictObject({
934
- "url": schema09,
935
- "secret": schema119,
936
- "voice_id": schema214.optional(),
937
- "language": schema38.optional(),
938
- "sample_rate": schema48.optional(),
939
- "timeout_ms": schema57.optional()
959
+ var schema010 = z.url().regex(new RegExp("^https:\\/\\/")).max(500);
960
+ var schema120 = z.string().min(16).max(200);
961
+ var schema215 = z.string().min(1).max(200);
962
+ var schema39 = z.string().min(2).max(35);
963
+ var schema49 = z.literal([8e3, 16e3, 22050, 24e3, 44100, 48e3]);
964
+ var schema58 = z.int().min(1e3).max(15e3);
965
+ var schema66 = z.strictObject({
966
+ "url": schema010,
967
+ "secret": schema120,
968
+ "voice_id": schema215.optional(),
969
+ "language": schema39.optional(),
970
+ "sample_rate": schema49.optional(),
971
+ "timeout_ms": schema58.optional()
940
972
  });
941
- var schema75 = z.literal("voice.synthesize");
973
+ var schema76 = z.literal("voice.synthesize");
942
974
  var schema85 = z.literal(1);
943
975
  var schema95 = z.string().min(1).max(200);
944
976
  var schema105 = z.string().min(1).max(200);
@@ -955,17 +987,17 @@ var schema174 = z.union([schema155, schema164]);
955
987
  var schema184 = z.string();
956
988
  var schema194 = z.union([schema184, schema164]);
957
989
  var schema203 = z.literal("pcm_s16le");
958
- var schema215 = z.literal([8e3, 16e3, 22050, 24e3, 44100, 48e3]);
990
+ var schema216 = z.literal([8e3, 16e3, 22050, 24e3, 44100, 48e3]);
959
991
  var schema223 = z.object({
960
992
  "encoding": schema203,
961
- "sample_rate": schema215,
993
+ "sample_rate": schema216,
962
994
  "channels": schema85
963
995
  });
964
996
  var schema233 = z.string().min(1).max(64);
965
997
  var schema243 = z.string().max(200);
966
998
  var schema253 = z.record(schema233, schema243).refine((value) => Object.keys(value).length <= 16, { message: "Too many keys: at most 16" });
967
999
  var schema263 = z.object({
968
- "type": schema75,
1000
+ "type": schema76,
969
1001
  "version": schema85,
970
1002
  "performance": schema1110.optional(),
971
1003
  "request_id": schema125,
@@ -976,7 +1008,7 @@ var schema263 = z.object({
976
1008
  "output": schema223,
977
1009
  "client_metadata": schema253
978
1010
  });
979
- var voiceWebhookWireSchema = schema65;
1011
+ var voiceWebhookWireSchema = schema66;
980
1012
  var voiceWebhookOptionsSchema = z.strictObject({
981
1013
  url: voiceWebhookWireSchema.shape.url,
982
1014
  secret: voiceWebhookWireSchema.shape.secret,
@@ -997,16 +1029,16 @@ function voiceWebhookToWire(input) {
997
1029
  };
998
1030
  }
999
1031
  var voiceWebhookRequestSchema = schema263;
1000
- var schema010 = z.url().regex(new RegExp("^\\s*[Hh][Tt][Tt][Pp][Ss]:\\/\\/")).max(500);
1001
- var schema120 = z.string().min(16).max(4096);
1002
- var schema216 = z.boolean();
1003
- var schema39 = z.literal("external");
1004
- var schema49 = z.strictObject({
1005
- "renderer": schema39
1032
+ var schema011 = z.url().regex(new RegExp("^\\s*[Hh][Tt][Tt][Pp][Ss]:\\/\\/")).max(500);
1033
+ var schema121 = z.string().min(16).max(4096);
1034
+ var schema217 = z.boolean();
1035
+ var schema310 = z.literal("external");
1036
+ var schema410 = z.strictObject({
1037
+ "renderer": schema310
1006
1038
  });
1007
- var schema58 = z.literal("v1");
1008
- var schema66 = z.literal("correlated_pcm_v1");
1009
- var schema76 = z.literal("speech_segments_v1");
1039
+ var schema59 = z.literal("v1");
1040
+ var schema67 = z.literal("correlated_pcm_v1");
1041
+ var schema77 = z.literal("speech_segments_v1");
1010
1042
  var schema86 = z.literal("v1");
1011
1043
  var schema96 = z.literal(true);
1012
1044
  var schema106 = z.object({
@@ -1020,13 +1052,13 @@ var schema126 = z.object({
1020
1052
  "audio_output": schema1111
1021
1053
  });
1022
1054
  var schema136 = z.strictObject({
1023
- "base_url": schema010,
1024
- "token": schema120,
1025
- "fail_closed": schema216.optional(),
1026
- "visible_character": schema49.optional(),
1027
- "performance": schema58.optional(),
1028
- "audio_output": schema66.optional(),
1029
- "text_output": schema76.optional()
1055
+ "base_url": schema011,
1056
+ "token": schema121,
1057
+ "fail_closed": schema217.optional(),
1058
+ "visible_character": schema410.optional(),
1059
+ "performance": schema59.optional(),
1060
+ "audio_output": schema67.optional(),
1061
+ "text_output": schema77.optional()
1030
1062
  }).superRefine((value, ctx) => {
1031
1063
  if (value["audio_output"] !== void 0) {
1032
1064
  const result = schema106.safeParse(value);
@@ -1060,32 +1092,32 @@ function externalLlmToWire(input) {
1060
1092
  ...options.textOutput !== void 0 ? { text_output: options.textOutput } : {}
1061
1093
  });
1062
1094
  }
1063
- var schema011 = z.string().min(8).max(80);
1064
- var schema121 = z.enum(["eou", "llm", "tts", "decision", "hold", "e2e"]);
1065
- var schema217 = z.literal("interrupt_stop");
1066
- var schema310 = z.union([schema121, schema217]);
1067
- var schema410 = z.int().max(9007199254740991).gt(0);
1068
- var schema59 = z.number().min(0);
1069
- var schema67 = z.strictObject({
1070
- "count": schema410,
1071
- "max": schema59,
1072
- "p50": schema59,
1073
- "p90": schema59
1095
+ var schema012 = z.string().min(8).max(80);
1096
+ var schema127 = z.enum(["eou", "llm", "tts", "decision", "hold", "e2e"]);
1097
+ var schema218 = z.literal("interrupt_stop");
1098
+ var schema311 = z.union([schema127, schema218]);
1099
+ var schema411 = z.int().max(9007199254740991).gt(0);
1100
+ var schema510 = z.number().min(0);
1101
+ var schema68 = z.strictObject({
1102
+ "count": schema411,
1103
+ "max": schema510,
1104
+ "p50": schema510,
1105
+ "p90": schema510
1074
1106
  });
1075
- var schema77 = z.partialRecord(schema310, schema67);
1107
+ var schema78 = z.partialRecord(schema311, schema68);
1076
1108
  var schema87 = z.literal("available");
1077
1109
  var schema97 = z.literal("dialogue");
1078
1110
  var schema107 = z.string().regex(new RegExp("^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d))|(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?)$"));
1079
1111
  var schema1112 = z.null();
1080
- var schema127 = z.union([schema107, schema1112]);
1112
+ var schema128 = z.union([schema107, schema1112]);
1081
1113
  var schema137 = z.int().min(0).max(9007199254740991);
1082
1114
  var schema146 = z.strictObject({
1083
- "first_at": schema127,
1084
- "last_at": schema127,
1115
+ "first_at": schema128,
1116
+ "last_at": schema128,
1085
1117
  "lines": schema137
1086
1118
  });
1087
1119
  var schema156 = z.strictObject({
1088
- "latency_ms": schema77,
1120
+ "latency_ms": schema78,
1089
1121
  "status": schema87,
1090
1122
  "sourceRole": schema97,
1091
1123
  "coverage": schema146
@@ -1098,7 +1130,7 @@ var schema185 = z.strictObject({
1098
1130
  });
1099
1131
  var schema195 = z.union([schema156, schema185]);
1100
1132
  var schema204 = z.string().min(1).max(200);
1101
- var schema218 = z.union([schema204, schema1112]);
1133
+ var schema219 = z.union([schema204, schema1112]);
1102
1134
  var schema224 = z.string().regex(new RegExp("^[0-9a-f]{40}$"));
1103
1135
  var schema234 = z.union([schema224, schema1112]);
1104
1136
  var schema244 = z.literal("cloudflare-worker-version");
@@ -1117,17 +1149,17 @@ var schema322 = z.strictObject({
1117
1149
  "workerObservedAt": schema31
1118
1150
  });
1119
1151
  var schema332 = z.strictObject({
1120
- "deploymentId": schema218,
1152
+ "deploymentId": schema219,
1121
1153
  "workerRevision": schema234,
1122
1154
  "provenance": schema322
1123
1155
  });
1124
1156
  var schema342 = z.string();
1125
1157
  var schema352 = z.union([schema342, schema1112]);
1126
1158
  var schema362 = z.enum(["reserved", "started", "released", "failed"]);
1127
- var schema372 = z.union([schema59, schema1112]);
1159
+ var schema372 = z.union([schema510, schema1112]);
1128
1160
  var schema382 = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value));
1129
1161
  var schema392 = z.strictObject({
1130
- "sessionId": schema011,
1162
+ "sessionId": schema012,
1131
1163
  "speechDiagnostics": schema195.optional(),
1132
1164
  "releaseIdentity": schema332.optional(),
1133
1165
  "avatarId": schema352,
@@ -1157,7 +1189,9 @@ function toSessionsPage(page) {
1157
1189
  // ../http-client/src/client.ts
1158
1190
  var DEFAULT_BASE_URL = "https://realtimeavatar.ai/api/v1";
1159
1191
  var RENDER_MISMATCH = "Render response did not match the SDK contract";
1160
- var SDK_VERSION = "0.35.0";
1192
+ var SPEECH_MISMATCH = "Speech response did not match the SDK contract";
1193
+ var MAX_SPEECH_RESPONSE_BYTES = 24 * 1024 * 1024;
1194
+ var SDK_VERSION = "0.36.0";
1161
1195
  var RealtimeAvatar = class {
1162
1196
  #apiKey;
1163
1197
  #baseUrl;
@@ -1719,6 +1753,45 @@ var RealtimeAvatar = class {
1719
1753
  async creditBalance() {
1720
1754
  return await this.#json(await this.#request("GET", "/credits/balance"));
1721
1755
  }
1756
+ /** Completed speech audio, without a call or LiveKit. Never automatically retried. */
1757
+ async createSpeech(voiceId, input, options = {}) {
1758
+ const id = speechVoiceIdSchema.parse(voiceId);
1759
+ const json = createSpeechRequestSchema.parse(input);
1760
+ const timeout = AbortSignal.timeout(Math.max(0, Math.min(this.#timeoutMs, this.#totalTimeoutMs ?? Infinity)));
1761
+ const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
1762
+ const response = await this.#request("POST", `/voices/${encodeURIComponent(id)}/speech`, {
1763
+ json,
1764
+ signal,
1765
+ maxRetries: 0
1766
+ });
1767
+ if (!response.ok) {
1768
+ try {
1769
+ await this.#json(response);
1770
+ } finally {
1771
+ signal.throwIfAborted();
1772
+ }
1773
+ throw new RealtimeAvatarError(SPEECH_MISMATCH);
1774
+ }
1775
+ let metadata;
1776
+ try {
1777
+ const contentType = speechContentTypeSchema.parse(response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase());
1778
+ const expected = { wav: "audio/wav", mp3: "audio/mpeg" };
1779
+ if (contentType !== expected[json.format]) throw new RealtimeAvatarError(SPEECH_MISMATCH);
1780
+ const requestId = response.headers.get("x-request-id");
1781
+ if (requestId !== null && !isRequestId(requestId)) throw new RealtimeAvatarError(SPEECH_MISMATCH);
1782
+ metadata = { contentType, ...readSpeechHeaders(response.headers), requestId };
1783
+ const length = response.headers.get("content-length");
1784
+ if (length !== null && (!/^[0-9]+$/.test(length) || Number(length) > MAX_SPEECH_RESPONSE_BYTES)) {
1785
+ throw new RealtimeAvatarError(SPEECH_MISMATCH);
1786
+ }
1787
+ } catch {
1788
+ await response.body?.cancel().catch(() => {
1789
+ });
1790
+ throw new RealtimeAvatarError(SPEECH_MISMATCH);
1791
+ }
1792
+ const bytes = await readSpeechBytes(response, signal, metadata.contentType);
1793
+ return { bytes, ...metadata };
1794
+ }
1722
1795
  // ── internals ────────────────────────────────────────────────────────────
1723
1796
  async #request(method, path, init = {}) {
1724
1797
  const headers = {
@@ -1734,25 +1807,29 @@ var RealtimeAvatar = class {
1734
1807
  body = JSON.stringify(init.json);
1735
1808
  }
1736
1809
  if (MUTATING.has(method)) headers["idempotency-key"] = newIdempotencyKey();
1810
+ const maxRetries = init.maxRetries ?? this.#maxRetries;
1737
1811
  const deadline = this.#totalTimeoutMs === void 0 ? Infinity : Date.now() + this.#totalTimeoutMs;
1738
1812
  let lastError;
1739
1813
  for (let attempt = 0; ; attempt++) {
1740
1814
  const startedAt = Date.now();
1741
1815
  try {
1742
- const signal = AbortSignal.timeout(Math.max(0, Math.min(this.#timeoutMs, deadline - startedAt)));
1816
+ const timeout = AbortSignal.timeout(Math.max(0, Math.min(this.#timeoutMs, deadline - startedAt)));
1817
+ const signal = init.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
1818
+ signal.throwIfAborted();
1743
1819
  const response = await this.#fetch(`${this.#baseUrl}${path}`, { method, headers, body, signal });
1744
- if (attempt >= this.#maxRetries || !RETRYABLE_STATUS.has(response.status)) return response;
1820
+ if (attempt >= maxRetries || !RETRYABLE_STATUS.has(response.status)) return response;
1745
1821
  const wait = backoffMs(attempt, response.headers.get("retry-after"));
1746
1822
  if (!retryFits(startedAt, wait, deadline)) return response;
1747
1823
  await response.body?.cancel().catch(() => {
1748
1824
  });
1749
1825
  await sleep(wait);
1750
1826
  } catch (cause) {
1827
+ init.signal?.throwIfAborted();
1751
1828
  lastError = cause;
1752
1829
  const wait = backoffMs(attempt, null);
1753
- if (attempt >= this.#maxRetries || !isTransient(cause) || isStream(body) || !retryFits(startedAt, wait, deadline)) {
1830
+ if (attempt >= maxRetries || !isTransient(cause) || isStream(body) || !retryFits(startedAt, wait, deadline)) {
1754
1831
  throw new RealtimeAvatarError(
1755
- `${method} ${path} failed after ${attempt + 1} attempt(s): ${cause.message}`,
1832
+ `${method} ${path} failed after ${attempt + 1} attempt(s): ${cause instanceof Error ? cause.message : String(cause)}`,
1756
1833
  { cause: lastError }
1757
1834
  );
1758
1835
  }
@@ -1788,6 +1865,47 @@ var RealtimeAvatar = class {
1788
1865
  return parsed.data;
1789
1866
  }
1790
1867
  };
1868
+ async function readSpeechBytes(response, signal, contentType) {
1869
+ if (!response.body) throw new RealtimeAvatarError(SPEECH_MISMATCH);
1870
+ const reader = response.body.getReader();
1871
+ const cancel = () => {
1872
+ void reader.cancel().catch(() => {
1873
+ });
1874
+ };
1875
+ signal.addEventListener("abort", cancel, { once: true });
1876
+ const chunks = [];
1877
+ let size = 0;
1878
+ try {
1879
+ signal.throwIfAborted();
1880
+ for (; ; ) {
1881
+ const { done, value } = await reader.read();
1882
+ signal.throwIfAborted();
1883
+ if (done) break;
1884
+ size += value.byteLength;
1885
+ if (size > MAX_SPEECH_RESPONSE_BYTES) throw new RealtimeAvatarError(SPEECH_MISMATCH);
1886
+ chunks.push(value);
1887
+ }
1888
+ if (size === 0) throw new RealtimeAvatarError(SPEECH_MISMATCH);
1889
+ const bytes = new Uint8Array(size);
1890
+ let offset = 0;
1891
+ for (const chunk of chunks) {
1892
+ bytes.set(chunk, offset);
1893
+ offset += chunk.byteLength;
1894
+ }
1895
+ const matches = (offset2, text) => [...text].every((character, index) => bytes[offset2 + index] === character.charCodeAt(0));
1896
+ const valid = contentType === "audio/wav" ? size >= 44 && matches(0, "RIFF") && matches(8, "WAVE") : size >= 10 && matches(0, "ID3") || size >= 4 && bytes[0] === 255 && (bytes[1] & 224) === 224;
1897
+ if (!valid) throw new RealtimeAvatarError(SPEECH_MISMATCH);
1898
+ return bytes;
1899
+ } catch (error) {
1900
+ await reader.cancel().catch(() => {
1901
+ });
1902
+ signal.throwIfAborted();
1903
+ throw error;
1904
+ } finally {
1905
+ signal.removeEventListener("abort", cancel);
1906
+ reader.releaseLock();
1907
+ }
1908
+ }
1791
1909
  function isRecord(value) {
1792
1910
  return typeof value === "object" && value !== null && !Array.isArray(value);
1793
1911
  }
@@ -1927,4 +2045,4 @@ var proxyEndRequestSchema = z.object({
1927
2045
  message: "session_id or queue_ticket_id is required"
1928
2046
  });
1929
2047
 
1930
- export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, ROUTE_TIMEOUT_MS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook };
2048
+ export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, ROUTE_TIMEOUT_MS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, createSpeechRequestSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook };
package/dist/express.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CUvcV0Wq.js';
2
- import './types-CpnLuiJU.js';
1
+ import { P as ProxyConfig } from './types-aQOs22YE.js';
2
+ import './types-C_0GpIws.js';
3
3
  import 'zod';
4
4
 
5
5
  type Expressish = {
package/dist/express.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createProxyHandler } from './chunk-ARJEAQQT.js';
2
- import './chunk-WHYDSORD.js';
1
+ import { createProxyHandler } from './chunk-EVATXOT2.js';
2
+ import './chunk-YHNBW3X6.js';
3
3
  import './chunk-MCIXU6XP.js';
4
4
 
5
5
  // ../proxy/src/express.ts
package/dist/hono.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CUvcV0Wq.js';
2
- import './types-CpnLuiJU.js';
1
+ import { P as ProxyConfig } from './types-aQOs22YE.js';
2
+ import './types-C_0GpIws.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/hono.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createProxyHandler } from './chunk-ARJEAQQT.js';
2
- import './chunk-WHYDSORD.js';
1
+ import { createProxyHandler } from './chunk-EVATXOT2.js';
2
+ import './chunk-YHNBW3X6.js';
3
3
  import './chunk-MCIXU6XP.js';
4
4
 
5
5
  // ../proxy/src/hono.ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CallPolicy, C as CallMode, S as StartCallResult, E as EndCallOptions, A as Avatar, b as CreateLive2dAvatarInput, R as RegisteredAvatar, c as AvatarUpdate, d as AvatarSourceSwap, e as ClipLibraryDeclaration, f as ClipLibraryUpdate, L as LoopRedirect, g as ClipLibrary, h as AssetKind, i as Asset, j as ListSessionsOptions, U as UsageSessionPage, k as UsageSession, l as ListRecordingsQuery, m as ListRecordingsResponse, n as RecordingArtifact, o as RecordingAccessResponse, p as CreateRenderInput, q as CreditBalance, T as TranscriptPayload, V as VoiceWebhookRequest } from './types-CpnLuiJU.js';
2
- export { r as AvatarClip, s as CallConnection, t as CallQueued, u as ClipDeclaration, v as ClipLibraryPlan, w as ClipSource, x as ContextMessage, y as EndCallReason, z as ExternalLlm, B as RecordingArtifactStatus, D as RecordingMode, F as RenderShot, G as VideoPolicy, H as VoiceWebhook, I as VoiceWebhookErrorCode, J as isQueued, K as listRecordingsResponseSchema, M as recordingAccessResponseSchema, N as recordingArtifactSchema, O as recordingModeSchema } from './types-CpnLuiJU.js';
1
+ import { a as CallPolicy, C as CallMode, S as StartCallResult, E as EndCallOptions, A as Avatar, b as CreateLive2dAvatarInput, R as RegisteredAvatar, c as AvatarUpdate, d as AvatarSourceSwap, e as ClipLibraryDeclaration, f as ClipLibraryUpdate, L as LoopRedirect, g as ClipLibrary, h as AssetKind, i as Asset, j as ListSessionsOptions, U as UsageSessionPage, k as UsageSession, l as ListRecordingsQuery, m as ListRecordingsResponse, n as RecordingArtifact, o as RecordingAccessResponse, p as CreateRenderInput, q as CreditBalance, r as operations, s as CreateSpeechInput, t as SpeechResult, T as TranscriptPayload, V as VoiceWebhookRequest } from './types-C_0GpIws.js';
2
+ export { u as AvatarClip, v as CallConnection, w as CallQueued, x as ClipDeclaration, y as ClipLibraryPlan, z as ClipSource, B as ContextMessage, D as EndCallReason, F as ExternalLlm, G as RecordingArtifactStatus, H as RecordingMode, I as RenderShot, J as VideoPolicy, K as VoiceWebhook, M as VoiceWebhookErrorCode, N as createSpeechRequestSchema, O as isQueued, P as listRecordingsResponseSchema, Q as recordingAccessResponseSchema, W as recordingArtifactSchema, X as recordingModeSchema } from './types-C_0GpIws.js';
3
3
  import { ConnectionHistoryResponse } from './connection-history.js';
4
4
  import { z } from 'zod';
5
5
 
@@ -470,6 +470,10 @@ declare class RealtimeAvatar {
470
470
  /** Read one session's bounded LiveKit connection history. Requires `usage:read`. */
471
471
  getConnectionHistory(sessionId: string): Promise<ConnectionHistoryResponse>;
472
472
  creditBalance(): Promise<CreditBalance>;
473
+ /** Completed speech audio, without a call or LiveKit. Never automatically retried. */
474
+ createSpeech(voiceId: operations["createSpeech"]["parameters"]["path"]["voiceId"], input: CreateSpeechInput, options?: {
475
+ signal?: AbortSignal;
476
+ }): Promise<SpeechResult>;
473
477
  }
474
478
 
475
479
  /** Base for everything this SDK throws, so `catch (e) { if (e instanceof RealtimeAvatarError) }` works. */
@@ -949,4 +953,4 @@ declare const proxyEndRequestSchema: z.ZodObject<{
949
953
  }>>>;
950
954
  }, z.core.$strict>;
951
955
 
952
- export { Asset, AssetKind, Avatar, AvatarSourceSwap, AvatarUpdate, CallMode, CallPolicy, ClipLibrary, ClipLibraryDeclaration, ClipLibraryUpdate, CreateLive2dAvatarInput, CreateRenderInput, CreditBalance, DEFAULT_FISH_TTS_MODEL, EndCallOptions, type ExternalSpeechSegment, type ExternalTurnContext, type ExternalUtterance, FISH_DELIVERY_MODELS, type FishDelivery, type FishTtsModel, ListRecordingsQuery, ListRecordingsResponse, type ListRendersQuery, type ListRendersResponse, ListSessionsOptions, LoopRedirect, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, type RealtimeAvatarOptions, RealtimeAvatarWebhookError, RecordingAccessResponse, RecordingArtifact, RegisteredAvatar, type Render, type RenderAccessResponse, type RenderFailureCode, type RenderPlayback, type RenderStatus, type ShotTiming, type StartCallOptions, StartCallResult, TranscriptPayload, UsageSession, UsageSessionPage, VoiceWebhookRequest, type WebhookVerificationErrorCode, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook };
956
+ export { Asset, AssetKind, Avatar, AvatarSourceSwap, AvatarUpdate, CallMode, CallPolicy, ClipLibrary, ClipLibraryDeclaration, ClipLibraryUpdate, CreateLive2dAvatarInput, CreateRenderInput, CreateSpeechInput, CreditBalance, DEFAULT_FISH_TTS_MODEL, EndCallOptions, type ExternalSpeechSegment, type ExternalTurnContext, type ExternalUtterance, FISH_DELIVERY_MODELS, type FishDelivery, type FishTtsModel, ListRecordingsQuery, ListRecordingsResponse, type ListRendersQuery, type ListRendersResponse, ListSessionsOptions, LoopRedirect, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, type RealtimeAvatarOptions, RealtimeAvatarWebhookError, RecordingAccessResponse, RecordingArtifact, RegisteredAvatar, type Render, type RenderAccessResponse, type RenderFailureCode, type RenderPlayback, type RenderStatus, type ShotTiming, SpeechResult, type StartCallOptions, StartCallResult, TranscriptPayload, UsageSession, UsageSessionPage, VoiceWebhookRequest, type WebhookVerificationErrorCode, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import './chunk-6KQS7CTR.js';
2
- export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook } from './chunk-WHYDSORD.js';
2
+ export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, createSpeechRequestSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook } from './chunk-YHNBW3X6.js';
3
3
  import './chunk-MCIXU6XP.js';
package/dist/nextjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CUvcV0Wq.js';
2
- import './types-CpnLuiJU.js';
1
+ import { P as ProxyConfig } from './types-aQOs22YE.js';
2
+ import './types-C_0GpIws.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/nextjs.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createProxyHandler } from './chunk-ARJEAQQT.js';
2
- import './chunk-WHYDSORD.js';
1
+ import { createProxyHandler } from './chunk-EVATXOT2.js';
2
+ import './chunk-YHNBW3X6.js';
3
3
  import './chunk-MCIXU6XP.js';
4
4
 
5
5
  // ../proxy/src/nextjs.ts
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { DEFAULT_FISH_TTS_MODEL, ExternalSpeechSegment, ExternalTurnContext, ExternalUtterance, FISH_DELIVERY_MODELS, FishDelivery, FishTtsModel, ListRendersQuery, ListRendersResponse, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarOptions, RealtimeAvatarWebhookError, Render, RenderAccessResponse, RenderFailureCode, RenderPlayback, RenderStatus, ShotTiming, StartCallOptions, WebhookVerificationErrorCode, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook } from './index.js';
2
- export { i as Asset, h as AssetKind, A as Avatar, r as AvatarClip, d as AvatarSourceSwap, c as AvatarUpdate, s as CallConnection, C as CallMode, a as CallPolicy, t as CallQueued, u as ClipDeclaration, g as ClipLibrary, e as ClipLibraryDeclaration, v as ClipLibraryPlan, f as ClipLibraryUpdate, w as ClipSource, x as ContextMessage, b as CreateLive2dAvatarInput, p as CreateRenderInput, q as CreditBalance, E as EndCallOptions, y as EndCallReason, z as ExternalLlm, l as ListRecordingsQuery, m as ListRecordingsResponse, j as ListSessionsOptions, L as LoopRedirect, o as RecordingAccessResponse, n as RecordingArtifact, B as RecordingArtifactStatus, D as RecordingMode, R as RegisteredAvatar, F as RenderShot, S as StartCallResult, T as TranscriptPayload, k as UsageSession, U as UsageSessionPage, G as VideoPolicy, H as VoiceWebhook, I as VoiceWebhookErrorCode, V as VoiceWebhookRequest, J as isQueued, K as listRecordingsResponseSchema, M as recordingAccessResponseSchema, N as recordingArtifactSchema, O as recordingModeSchema } from './types-CpnLuiJU.js';
2
+ export { i as Asset, h as AssetKind, A as Avatar, u as AvatarClip, d as AvatarSourceSwap, c as AvatarUpdate, v as CallConnection, C as CallMode, a as CallPolicy, w as CallQueued, x as ClipDeclaration, g as ClipLibrary, e as ClipLibraryDeclaration, y as ClipLibraryPlan, f as ClipLibraryUpdate, z as ClipSource, B as ContextMessage, b as CreateLive2dAvatarInput, p as CreateRenderInput, s as CreateSpeechInput, q as CreditBalance, E as EndCallOptions, D as EndCallReason, F as ExternalLlm, l as ListRecordingsQuery, m as ListRecordingsResponse, j as ListSessionsOptions, L as LoopRedirect, o as RecordingAccessResponse, n as RecordingArtifact, G as RecordingArtifactStatus, H as RecordingMode, R as RegisteredAvatar, I as RenderShot, t as SpeechResult, S as StartCallResult, T as TranscriptPayload, k as UsageSession, U as UsageSessionPage, J as VideoPolicy, K as VoiceWebhook, M as VoiceWebhookErrorCode, V as VoiceWebhookRequest, N as createSpeechRequestSchema, O as isQueued, P as listRecordingsResponseSchema, Q as recordingAccessResponseSchema, W as recordingArtifactSchema, X as recordingModeSchema } from './types-C_0GpIws.js';
3
3
  import './connection-history.js';
4
4
  import 'zod';
package/dist/server.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import './chunk-6KQS7CTR.js';
2
- export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook } from './chunk-WHYDSORD.js';
2
+ export { DEFAULT_FISH_TTS_MODEL, FISH_DELIVERY_MODELS, RealtimeAvatar, RealtimeAvatarError, RealtimeAvatarHttpError, RealtimeAvatarWebhookError, capacityBusyResponseSchema, clipLibraryDeclarationSchema, createSpeechRequestSchema, externalSpeechSegmentSchema, externalTurnContextSchema, externalUtteranceSchema, fishTtsModelSchema, isQueued, listRecordingsResponseSchema, listRendersResponseSchema, liveKitSessionGrantSchema, proxyConnectRequestSchema, proxyEndRequestSchema, recordingAccessResponseSchema, recordingArtifactSchema, recordingModeSchema, renderAccessResponseSchema, renderSchema, verifyTranscript, verifyVoiceWebhook } from './chunk-YHNBW3X6.js';
3
3
  import './chunk-MCIXU6XP.js';
@@ -1,5 +1,5 @@
1
- import { P as ProxyConfig } from './types-CUvcV0Wq.js';
2
- import './types-CpnLuiJU.js';
1
+ import { P as ProxyConfig } from './types-aQOs22YE.js';
2
+ import './types-C_0GpIws.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { createProxyHandler } from './chunk-ARJEAQQT.js';
2
- import './chunk-WHYDSORD.js';
1
+ import { createProxyHandler } from './chunk-EVATXOT2.js';
2
+ import './chunk-YHNBW3X6.js';
3
3
  import './chunk-MCIXU6XP.js';
4
4
 
5
5
  // src/tanstack-start.ts
@@ -1,67 +1,5 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const createLive2dAvatarInputSchema: z.ZodObject<{
4
- displayName: z.ZodString;
5
- settings: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
6
- metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
7
- voice: z.ZodObject<{
8
- provider: z.ZodEnum<{
9
- cartesia: "cartesia";
10
- fish: "fish";
11
- }>;
12
- voice_id: z.ZodString;
13
- model: z.ZodOptional<z.ZodString>;
14
- speed: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
15
- emotion: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
16
- language: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
17
- }, z.core.$strict>;
18
- }, z.core.$strict>;
19
- declare const avatarResponseSchema: z.ZodObject<{
20
- id: z.ZodString;
21
- tenantId: z.ZodString;
22
- displayName: z.ZodString;
23
- renderer: z.ZodEnum<{
24
- video: "video";
25
- live2d: "live2d";
26
- }>;
27
- sourceKind: z.ZodEnum<{
28
- video: "video";
29
- image: "image";
30
- }>;
31
- modelId: z.ZodEnum<{
32
- "realtime-avatar-live-v1": "realtime-avatar-live-v1";
33
- "realtime-avatar-video-v1": "realtime-avatar-video-v1";
34
- }>;
35
- sourceAssetId: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
36
- status: z.ZodEnum<{
37
- ready: "ready";
38
- failed: "failed";
39
- draft: "draft";
40
- preprocessing: "preprocessing";
41
- disabled: "disabled";
42
- deleted: "deleted";
43
- }>;
44
- error: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
45
- idleVideoStatus: z.ZodEnum<{
46
- ready: "ready";
47
- failed: "failed";
48
- none: "none";
49
- queued: "queued";
50
- generating: "generating";
51
- }>;
52
- defaultVoiceId: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
53
- llm: z.ZodUnion<readonly [z.ZodObject<{
54
- provider: z.ZodEnum<{
55
- local: "local";
56
- gemini: "gemini";
57
- openai: "openai";
58
- }>;
59
- model: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
60
- }, z.core.$strict>, z.ZodNull]>;
61
- createdAt: z.ZodString;
62
- updatedAt: z.ZodString;
63
- }, z.core.$strict>;
64
-
65
3
  interface components {
66
4
  schemas: {
67
5
  LiveKitSessionRequest: {
@@ -3710,6 +3648,68 @@ interface operations {
3710
3648
  };
3711
3649
  }
3712
3650
 
3651
+ declare const createLive2dAvatarInputSchema: z.ZodObject<{
3652
+ displayName: z.ZodString;
3653
+ settings: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
3654
+ metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
3655
+ voice: z.ZodObject<{
3656
+ provider: z.ZodEnum<{
3657
+ cartesia: "cartesia";
3658
+ fish: "fish";
3659
+ }>;
3660
+ voice_id: z.ZodString;
3661
+ model: z.ZodOptional<z.ZodString>;
3662
+ speed: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
3663
+ emotion: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
3664
+ language: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
3665
+ }, z.core.$strict>;
3666
+ }, z.core.$strict>;
3667
+ declare const avatarResponseSchema: z.ZodObject<{
3668
+ id: z.ZodString;
3669
+ tenantId: z.ZodString;
3670
+ displayName: z.ZodString;
3671
+ renderer: z.ZodEnum<{
3672
+ video: "video";
3673
+ live2d: "live2d";
3674
+ }>;
3675
+ sourceKind: z.ZodEnum<{
3676
+ video: "video";
3677
+ image: "image";
3678
+ }>;
3679
+ modelId: z.ZodEnum<{
3680
+ "realtime-avatar-live-v1": "realtime-avatar-live-v1";
3681
+ "realtime-avatar-video-v1": "realtime-avatar-video-v1";
3682
+ }>;
3683
+ sourceAssetId: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
3684
+ status: z.ZodEnum<{
3685
+ ready: "ready";
3686
+ failed: "failed";
3687
+ draft: "draft";
3688
+ preprocessing: "preprocessing";
3689
+ disabled: "disabled";
3690
+ deleted: "deleted";
3691
+ }>;
3692
+ error: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
3693
+ idleVideoStatus: z.ZodEnum<{
3694
+ ready: "ready";
3695
+ failed: "failed";
3696
+ none: "none";
3697
+ queued: "queued";
3698
+ generating: "generating";
3699
+ }>;
3700
+ defaultVoiceId: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
3701
+ llm: z.ZodUnion<readonly [z.ZodObject<{
3702
+ provider: z.ZodEnum<{
3703
+ local: "local";
3704
+ gemini: "gemini";
3705
+ openai: "openai";
3706
+ }>;
3707
+ model: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
3708
+ }, z.core.$strict>, z.ZodNull]>;
3709
+ createdAt: z.ZodString;
3710
+ updatedAt: z.ZodString;
3711
+ }, z.core.$strict>;
3712
+
3713
3713
  declare const listUsageSessionsResponseSchema: z.ZodObject<{
3714
3714
  data: z.ZodArray<z.ZodObject<{
3715
3715
  sessionId: z.ZodString;
@@ -4083,6 +4083,26 @@ declare const externalLlmOptionsSchema: z.ZodObject<{
4083
4083
  }, z.core.$strict>;
4084
4084
  declare function externalLlmToWire(input: z.input<typeof externalLlmOptionsSchema>): z.output<typeof externalLlmWireSchema>;
4085
4085
 
4086
+ declare const createSpeechRequestSchema: z.ZodObject<{
4087
+ text: z.ZodPipe<z.ZodString, z.ZodString>;
4088
+ speed: z.ZodOptional<z.ZodNumber>;
4089
+ language: z.ZodOptional<z.ZodString>;
4090
+ format: z.ZodDefault<z.ZodEnum<{
4091
+ mp3: "mp3";
4092
+ wav: "wav";
4093
+ }>>;
4094
+ }, z.core.$strict>;
4095
+ type CreateSpeechInput = z.input<typeof createSpeechRequestSchema>;
4096
+ declare const speechContentTypeSchema: z.ZodEnum<{
4097
+ "audio/mpeg": "audio/mpeg";
4098
+ "audio/wav": "audio/wav";
4099
+ }>;
4100
+ type SpeechContentType = z.infer<typeof speechContentTypeSchema>;
4101
+ declare function readSpeechHeaders(headers: Headers): {
4102
+ billedCredits: number | null;
4103
+ billedBytes: number | null;
4104
+ };
4105
+
4086
4106
  /**
4087
4107
  * The public shapes. Everything an integrator touches is here, in one file, on purpose:
4088
4108
  * an agent reading this repo should be able to learn the whole surface without following
@@ -4113,6 +4133,13 @@ declare function externalLlmToWire(input: z.input<typeof externalLlmOptionsSchem
4113
4133
  * Verified by mutation: renaming `participant_token` in the generated file fails the typecheck.
4114
4134
  */
4115
4135
 
4136
+ /** DERIVATION: binary bytes are SDK-owned; media types and billing derive from createSpeech's operation. */
4137
+ type SpeechResult = ReturnType<typeof readSpeechHeaders> & {
4138
+ bytes: Uint8Array<ArrayBuffer>;
4139
+ contentType: SpeechContentType;
4140
+ requestId: string | null;
4141
+ };
4142
+
4116
4143
  /**
4117
4144
  * The wire shapes, from the published contract at https://realtimeavatar.ai/openapi.json.
4118
4145
  *
@@ -4580,4 +4607,4 @@ interface TranscriptPayload {
4580
4607
  client_metadata: Record<string, string>;
4581
4608
  }
4582
4609
 
4583
- export { type Avatar as A, type RecordingArtifactStatus as B, type CallMode as C, type RecordingMode as D, type EndCallOptions as E, type RenderShot as F, type VideoPolicy as G, type VoiceWebhook as H, type VoiceWebhookErrorCode as I, isQueued as J, listRecordingsResponseSchema as K, type LoopRedirect as L, recordingAccessResponseSchema as M, recordingArtifactSchema as N, recordingModeSchema as O, type RegisteredAvatar as R, type StartCallResult as S, type TranscriptPayload as T, type UsageSessionPage as U, type VoiceWebhookRequest as V, type CallPolicy as a, type CreateLive2dAvatarInput as b, type AvatarUpdate as c, type AvatarSourceSwap as d, type ClipLibraryDeclaration as e, type ClipLibraryUpdate as f, type ClipLibrary as g, type AssetKind as h, type Asset as i, type ListSessionsOptions as j, type UsageSession as k, type ListRecordingsQuery as l, type ListRecordingsResponse as m, type RecordingArtifact as n, type RecordingAccessResponse as o, type CreateRenderInput as p, type CreditBalance as q, type AvatarClip as r, type CallConnection as s, type CallQueued as t, type ClipDeclaration as u, type ClipLibraryPlan as v, type ClipSource as w, type ContextMessage as x, type EndCallReason as y, type ExternalLlm as z };
4610
+ export { type Avatar as A, type ContextMessage as B, type CallMode as C, type EndCallReason as D, type EndCallOptions as E, type ExternalLlm as F, type RecordingArtifactStatus as G, type RecordingMode as H, type RenderShot as I, type VideoPolicy as J, type VoiceWebhook as K, type LoopRedirect as L, type VoiceWebhookErrorCode as M, createSpeechRequestSchema as N, isQueued as O, listRecordingsResponseSchema as P, recordingAccessResponseSchema as Q, type RegisteredAvatar as R, type StartCallResult as S, type TranscriptPayload as T, type UsageSessionPage as U, type VoiceWebhookRequest as V, recordingArtifactSchema as W, recordingModeSchema as X, type CallPolicy as a, type CreateLive2dAvatarInput as b, type AvatarUpdate as c, type AvatarSourceSwap as d, type ClipLibraryDeclaration as e, type ClipLibraryUpdate as f, type ClipLibrary as g, type AssetKind as h, type Asset as i, type ListSessionsOptions as j, type UsageSession as k, type ListRecordingsQuery as l, type ListRecordingsResponse as m, type RecordingArtifact as n, type RecordingAccessResponse as o, type CreateRenderInput as p, type CreditBalance as q, type operations as r, type CreateSpeechInput as s, type SpeechResult as t, type AvatarClip as u, type CallConnection as v, type CallQueued as w, type ClipDeclaration as x, type ClipLibraryPlan as y, type ClipSource as z };
@@ -1,4 +1,4 @@
1
- import { C as CallMode, a as CallPolicy } from './types-CpnLuiJU.js';
1
+ import { C as CallMode, a as CallPolicy } from './types-C_0GpIws.js';
2
2
 
3
3
  /** The three things a caller can ask the proxy to do. Gate on these, not on URLs. */
4
4
  type ProxyOperation = "connect" | "end" | "avatars" | "credits";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "realtime-avatar",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Realtime Avatar SDK. `realtime-avatar` and the route adapters hold your API key and are server-only; `realtime-avatar/react`, `/browser` and `/tools` never can — importing a server entry into a browser build throws at bundle time.",
5
5
  "license": "MIT",
6
6
  "author": "The Influence Company",