samsar-js 0.48.21 → 0.48.23

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
@@ -161,9 +161,17 @@ const noSubtitles = await samsar.removeSubtitles(
161
161
  { webhookUrl: 'https://example.com/webhook' },
162
162
  );
163
163
 
164
+ // Clone a session and add subtitle/transcript text overlays
165
+ const withSubtitles = await samsar.addSubtitles(
166
+ {
167
+ videoSessionId: noSubtitles.data.session_id ?? noSubtitles.data.request_id!,
168
+ },
169
+ { webhookUrl: 'https://example.com/webhook' },
170
+ );
171
+
164
172
  // Cancel an in-progress render
165
173
  const cancelled = await samsar.cancelRender({
166
- videoSessionId: noSubtitles.data.session_id ?? noSubtitles.data.request_id!,
174
+ videoSessionId: withSubtitles.data.session_id ?? withSubtitles.data.request_id!,
167
175
  });
168
176
  console.log(cancelled.data.status, cancelled.data.cancelled);
169
177
 
@@ -331,15 +339,18 @@ const rollup = await samsar.enhanceAndGenerateRollupBanner({
331
339
 
332
340
  // Check status by request_id (defaults to /v1/status)
333
341
  const status = await samsar.getStatus(video.data.request_id);
342
+ if (status.data.status === 'COMPLETED') {
343
+ console.log(status.data.result_url, status.data.has_subtitles, status.data.result_language);
344
+ }
334
345
 
335
346
  // Fetch the latest render URL for a session (when available)
336
347
  const latest = await samsar.fetchLatestVideoVersion(video.data.session_id ?? video.data.request_id);
337
- console.log(latest.data.result_url ?? latest.data.status);
348
+ console.log(latest.data.result_url ?? latest.data.status, latest.data.has_subtitles, latest.data.result_language);
338
349
 
339
350
  // List completed video sessions for this API key
340
351
  const completedSessions = await samsar.listCompletedVideoSessions();
341
352
  completedSessions.data.forEach((session) => {
342
- console.log(session.session_id, session.langauge, session.result_url);
353
+ console.log(session.session_id, session.result_language ?? session.langauge, session.has_subtitles, session.result_url);
343
354
  });
344
355
 
345
356
  // Publish, edit, or revoke a completed session in the public publication feed (free endpoints)
@@ -505,7 +516,8 @@ Video model support notes:
505
516
  - `createVideoFromImageList` accepts either a provided outro (`outro_image_url`) or server-generated QR outro (`generate_outro_image: true` with `cta_url`). Do not combine the two modes in a single request.
506
517
  - `createVideoFromImageList` can render per-scene footer QR cards by setting `add_footer_animation: true` and providing one `footer_metadata` item per image scene.
507
518
  - `updateVideoOutroImage` accepts either a replacement outro image URL (`outro_image_url`, `outroImageUrl`, `new_outro_image_url`) or a generated QR CTA outro (`generate_outro_image: true` with `cta_url`, or just `cta_url` when no outro image URL is supplied). Generated outro updates reuse the existing session image layers for tiling and only queue frame/video regeneration.
508
- - Main video methods and external-user methods accept the same generated outro and footer parameters. The API can resolve either internal session ids or external `extreq_...` ids on repeated video routes, so client code can keep using `translateVideo`, `joinVideos`, `addVideoOutroImage`, and `updateVideoOutroImage`; the explicit external variants are available when you want to call `/external_users/*` directly. Do not strip the `extreq_` prefix.
519
+ - Main video methods and external-user methods accept the same generated outro and footer parameters. The API can resolve either internal session ids or external `extreq_...` ids on repeated video routes, so client code can keep using `translateVideo`, `joinVideos`, `addSubtitles`, `removeSubtitles`, `addVideoOutroImage`, and `updateVideoOutroImage`; the explicit external variants are available when you want to call `/external_users/*` directly. Do not strip the `extreq_` prefix.
520
+ - Completed video status, latest-version, and completed-session list responses expose `has_subtitles` and `result_language` when the session metadata is available.
509
521
  - `publishPublication`, `editPublication`, and `revokePublication` manage public feed publications for completed sessions through free `/publications/*` endpoints. They work with account API keys, customer sub-account API keys, and client auth tokens when the session belongs to the authenticated actor.
510
522
  - Image-list video pricing is per rendered second: `VEO3.1I2V` and `SEEDANCEI2V` are 75 credits/sec, `KLING3.0` is 50 credits/sec, and `RUNWAYML` is 25 credits/sec.
511
523
 
package/dist/index.d.ts CHANGED
@@ -51,6 +51,8 @@ export interface CreateVideoFromTextInput {
51
51
  languageString?: string | null;
52
52
  enable_subtitles?: boolean;
53
53
  enableSubtitles?: boolean;
54
+ add_subtitles?: boolean;
55
+ addSubtitles?: boolean;
54
56
  session_id?: string;
55
57
  sessionId?: string;
56
58
  sessionID?: string;
@@ -141,6 +143,8 @@ export interface CreateVideoFromImageListInput {
141
143
  font?: FontOptions;
142
144
  enable_subtitles?: boolean;
143
145
  enableSubtitles?: boolean;
146
+ add_subtitles?: boolean;
147
+ addSubtitles?: boolean;
144
148
  session_id?: string;
145
149
  sessionId?: string;
146
150
  sessionID?: string;
@@ -339,6 +343,10 @@ export interface RemoveSubtitlesResponse {
339
343
  remainingCredits?: number | null;
340
344
  [key: string]: unknown;
341
345
  }
346
+ export interface AddSubtitlesInput extends RemoveSubtitlesInput {
347
+ }
348
+ export interface AddSubtitlesResponse extends RemoveSubtitlesResponse {
349
+ }
342
350
  export interface CancelRenderInput {
343
351
  videoSessionId?: string;
344
352
  video_session_id?: string;
@@ -362,6 +370,8 @@ export interface CancelRenderResponse {
362
370
  export interface FetchLatestVideoVersionResponse {
363
371
  session_id: string;
364
372
  result_url?: string;
373
+ has_subtitles?: boolean | null;
374
+ result_language?: string | null;
365
375
  status?: string;
366
376
  message?: string;
367
377
  [key: string]: unknown;
@@ -370,6 +380,8 @@ export interface CompletedVideoSession {
370
380
  session_id: string;
371
381
  langauge: string;
372
382
  language?: string;
383
+ result_language?: string;
384
+ has_subtitles?: boolean | null;
373
385
  result_url: string;
374
386
  [key: string]: unknown;
375
387
  }
@@ -1103,6 +1115,8 @@ export interface GlobalStatusResponse {
1103
1115
  type?: 'image' | 'video' | string;
1104
1116
  provider?: string | null;
1105
1117
  result_url?: string | null;
1118
+ has_subtitles?: boolean | null;
1119
+ result_language?: string | null;
1106
1120
  thumbnail_url?: string | null;
1107
1121
  result_urls?: string[];
1108
1122
  videoLink?: string | null;
@@ -1758,6 +1772,13 @@ export declare class SamsarClient {
1758
1772
  removeSubtitles(input: RemoveSubtitlesInput, options?: {
1759
1773
  webhookUrl?: string;
1760
1774
  } & SamsarRequestOptions): Promise<SamsarResult<RemoveSubtitlesResponse>>;
1775
+ /**
1776
+ * Add subtitle/transcript text overlays by cloning an existing session and re-running
1777
+ * transcription + frame + video generation on the new session.
1778
+ */
1779
+ addSubtitles(input: AddSubtitlesInput, options?: {
1780
+ webhookUrl?: string;
1781
+ } & SamsarRequestOptions): Promise<SamsarResult<AddSubtitlesResponse>>;
1761
1782
  /**
1762
1783
  * Cancel an in-progress render for an existing video session.
1763
1784
  */
@@ -1791,11 +1812,13 @@ export declare class SamsarClient {
1791
1812
  } & SamsarRequestOptions): Promise<SamsarResult<ExternalRequestResponse>>;
1792
1813
  /**
1793
1814
  * Fetch the latest available render URL for a given video session id.
1815
+ * Completed responses include result_url, has_subtitles, and result_language.
1794
1816
  * Maps to GET /video/fetch_latest_version?session_id={sessionId}.
1795
1817
  */
1796
1818
  fetchLatestVideoVersion(sessionId: string, options?: SamsarRequestOptions): Promise<SamsarResult<FetchLatestVideoVersionResponse>>;
1797
1819
  /**
1798
1820
  * List completed video sessions for the authenticated API key.
1821
+ * Each item includes result_url plus session metadata such as has_subtitles and result_language.
1799
1822
  * Maps to GET /video/list_completed_video_sessions.
1800
1823
  */
1801
1824
  listCompletedVideoSessions(options?: SamsarRequestOptions & {
@@ -2001,6 +2024,7 @@ export declare class SamsarClient {
2001
2024
  * Retrieve the status of an asynchronous request by request_id.
2002
2025
  * Defaults to GET /status?request_id={requestId}, but the path can be overridden.
2003
2026
  * Normalizes the response to expose status/result_url for both image and video flows.
2027
+ * Completed video responses can also include has_subtitles and result_language.
2004
2028
  */
2005
2029
  getStatus(requestId: string, options?: SamsarRequestOptions & {
2006
2030
  path?: string;
package/dist/index.js CHANGED
@@ -791,6 +791,51 @@ export class SamsarClient {
791
791
  }
792
792
  return response;
793
793
  }
794
+ /**
795
+ * Add subtitle/transcript text overlays by cloning an existing session and re-running
796
+ * transcription + frame + video generation on the new session.
797
+ */
798
+ async addSubtitles(input, options) {
799
+ const raw = input;
800
+ const videoSessionId = raw.videoSessionId ??
801
+ raw.video_session_id ??
802
+ raw.videoSessionID ??
803
+ raw.session_id ??
804
+ raw.sessionId ??
805
+ raw.sessionID ??
806
+ raw.request_id ??
807
+ raw.requestId;
808
+ if (!videoSessionId) {
809
+ throw new Error('videoSessionId is required for addSubtitles');
810
+ }
811
+ const body = {
812
+ input: {
813
+ ...input,
814
+ videoSessionId: String(videoSessionId),
815
+ },
816
+ webhookUrl: options?.webhookUrl,
817
+ };
818
+ const response = await this.post('video/add_subtitles', body, options);
819
+ const data = response.data;
820
+ if (data && typeof data === 'object') {
821
+ const sessionId = typeof data.sessionID === 'string'
822
+ ? data.sessionID
823
+ : typeof data.session_id === 'string'
824
+ ? data.session_id
825
+ : typeof data.request_id === 'string'
826
+ ? data.request_id
827
+ : undefined;
828
+ const normalizedSessionId = sessionId ? String(sessionId) : undefined;
829
+ const normalizedData = {
830
+ ...data,
831
+ sessionID: data.sessionID ?? normalizedSessionId ?? '',
832
+ session_id: data.session_id ?? normalizedSessionId,
833
+ request_id: data.request_id ?? normalizedSessionId,
834
+ };
835
+ return { ...response, data: normalizedData };
836
+ }
837
+ return response;
838
+ }
794
839
  /**
795
840
  * Cancel an in-progress render for an existing video session.
796
841
  */
@@ -1033,6 +1078,7 @@ export class SamsarClient {
1033
1078
  }
1034
1079
  /**
1035
1080
  * Fetch the latest available render URL for a given video session id.
1081
+ * Completed responses include result_url, has_subtitles, and result_language.
1036
1082
  * Maps to GET /video/fetch_latest_version?session_id={sessionId}.
1037
1083
  */
1038
1084
  async fetchLatestVideoVersion(sessionId, options) {
@@ -1050,6 +1096,7 @@ export class SamsarClient {
1050
1096
  }
1051
1097
  /**
1052
1098
  * List completed video sessions for the authenticated API key.
1099
+ * Each item includes result_url plus session metadata such as has_subtitles and result_language.
1053
1100
  * Maps to GET /video/list_completed_video_sessions.
1054
1101
  */
1055
1102
  async listCompletedVideoSessions(options) {
@@ -1581,6 +1628,7 @@ export class SamsarClient {
1581
1628
  * Retrieve the status of an asynchronous request by request_id.
1582
1629
  * Defaults to GET /status?request_id={requestId}, but the path can be overridden.
1583
1630
  * Normalizes the response to expose status/result_url for both image and video flows.
1631
+ * Completed video responses can also include has_subtitles and result_language.
1584
1632
  */
1585
1633
  async getStatus(requestId, options) {
1586
1634
  if (!requestId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samsar-js",
3
- "version": "0.48.21",
3
+ "version": "0.48.23",
4
4
  "description": "TypeScript client for the Samsar Processor API routes.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",