samsar-js 0.48.31 → 0.48.33
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 +14 -9
- package/dist/index.d.ts +78 -23
- package/dist/index.js +115 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,10 @@ const video = await samsar.createVideoFromText(
|
|
|
37
37
|
image_model: 'GPTIMAGE2',
|
|
38
38
|
video_model: 'RUNWAYML',
|
|
39
39
|
duration: 30,
|
|
40
|
+
backingtrack_model: 'LYRIA3',
|
|
41
|
+
tts_model: 'OPENAI',
|
|
42
|
+
speakerOptions: { openAISpeakers: ['nova'] },
|
|
43
|
+
inference_model: 'gpt-5.5',
|
|
40
44
|
font_key: 'Poppins',
|
|
41
45
|
enable_subtitles: true,
|
|
42
46
|
},
|
|
@@ -67,6 +71,10 @@ const videoFromImages = await samsar.createVideoFromImageList(
|
|
|
67
71
|
video_model: 'RUNWAYML',
|
|
68
72
|
aspect_ratio: '16:9',
|
|
69
73
|
language: 'en',
|
|
74
|
+
backingtrack_model: 'ELEVENLABS_MUSIC',
|
|
75
|
+
tts_model: 'ELEVENLABS',
|
|
76
|
+
speakerOptions: { elevenLabsSpeakers: ['EXAVITQu4vr4xnSDxMaL'] },
|
|
77
|
+
inference_model: 'gemini-3.1-pro',
|
|
70
78
|
font_key: 'Poppins',
|
|
71
79
|
enable_subtitles: true,
|
|
72
80
|
},
|
|
@@ -330,14 +338,9 @@ await samsar.deleteEmbedding({
|
|
|
330
338
|
source_id: '2',
|
|
331
339
|
});
|
|
332
340
|
|
|
333
|
-
// Remove
|
|
341
|
+
// Remove visible text
|
|
334
342
|
const cleaned = await samsar.removeBrandingFromImage({ image_url: 'https://example.com/photo.png' });
|
|
335
343
|
|
|
336
|
-
// Replace branding/watermark (original image, replacement logo/image)
|
|
337
|
-
const replaced = await samsar.replaceBrandingFromImage({
|
|
338
|
-
image_urls: ['https://example.com/photo.png', 'https://example.com/new-logo.png'],
|
|
339
|
-
});
|
|
340
|
-
|
|
341
344
|
// Extend image set
|
|
342
345
|
const images = await samsar.extendImageList({
|
|
343
346
|
image_urls: ['https://example.com/extra.jpg'],
|
|
@@ -578,10 +581,12 @@ console.log(externalLibrary.data.requests.map((request) => request.request_id));
|
|
|
578
581
|
```
|
|
579
582
|
|
|
580
583
|
Video model support notes:
|
|
581
|
-
- `createVideoFromText` image model keys include: `GPTIMAGE2`, `IMAGEN4`, `SEEDREAM`, `NANOBANANA2`, `CUSTOM_TEXT_TO_IMAGE`.
|
|
582
|
-
- `createVideoFromText` supports these video models: `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `SEEDANCEI2V` (Seedance 1.5), `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V`.
|
|
584
|
+
- `createVideoFromText` image model keys include: `GPTIMAGE2`, `IMAGEN4`, `SEEDREAM`, `NANOBANANA2`, `NANOBANANAPRO`, `CUSTOM_TEXT_TO_IMAGE`.
|
|
585
|
+
- `createVideoFromText` supports these video models: `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `COSMOS3SUPERI2V`, `SEEDANCEI2V` (Seedance 1.5), `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V`.
|
|
583
586
|
- `createVideoFromText` accepts either a provided outro (`outro_image_url`) or server-generated QR outro (`generate_outro_image: true` with `cta_url`). It can also render bottom CTA footer QR cards with `add_footer_animation` and `footer_metadata`; one footer item applies to every generated scene, while multiple items map by scene index.
|
|
584
|
-
- `createVideoFromImageList` supports `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `SEEDANCEI2V`, `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V` via `video_model`; if omitted, it defaults to `RUNWAYML`. Use `aspect_ratio: '16:9'` or `'9:16'`; omitted or invalid values fall back to `16:9`.
|
|
587
|
+
- `createVideoFromImageList` supports `RUNWAYML`, `VEO3.1I2V`, `VEO3.1I2VFAST`, `COSMOS3SUPERI2V`, `SEEDANCEI2V`, `KLINGIMGTOVID3PRO`, and `HAPPYHORSEI2V` via `video_model`; if omitted, it defaults to `RUNWAYML`. It also accepts the same `image_model` keys as text-to-video. Use `aspect_ratio: '16:9'` or `'9:16'`; omitted or invalid values fall back to `16:9`.
|
|
588
|
+
- Text and image-list video creation both accept optional `backingtrack_model` / `backing_track_model` / `backingTrackModel` / `music_provider` / `musicProvider`, `tts_model` / `ttsModel` / `tts_provider` / `ttsProvider`, `speakerOptions` / `speaker_options`, and `inference_model` / `inferenceModel`. The adapter normalizes these to `backingtrack_model`, `tts_model`, `speakerOptions`, and `inference_model` in the request payload. Omit `inference_model` to use the account default; supported request values are `gpt-5.5` and `gemini-3.1-pro`. When `tts_model` is set, Samsar limits assignment to the matching speaker list (`openAISpeakers`, `elevenLabsSpeakers`, or `googleSpeakers`; Google TTS requests should include `googleSpeakerDetails`).
|
|
589
|
+
- `video_model_sub_type` is no longer used by the API and is stripped from text and image-list payloads before sending.
|
|
585
590
|
- `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.
|
|
586
591
|
- `createVideoFromImageList` can render per-scene footer QR cards by setting `add_footer_animation: true` and providing one `footer_metadata` item per image scene.
|
|
587
592
|
- `createVideoFromImageList` can also generate QR outro CTA text and each scene footer CTA from a single link by setting `express_cta_generation: true` with `cta_url`. CamelCase `expressCtaGeneration` and compatibility aliases `auto_generate_cta_text` / `generate_cta_texts` are normalized to the same API field.
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,36 @@ export interface FontOptions {
|
|
|
36
36
|
language?: string;
|
|
37
37
|
family?: string;
|
|
38
38
|
}
|
|
39
|
+
export type BackingTrackModel = 'LYRIA3' | 'LYRIA2' | 'ELEVENLABS_MUSIC' | 'Lyria 3' | 'Lyria 2' | 'ElevenLabs music' | string;
|
|
40
|
+
export type TTSModel = 'ELEVENLABS' | 'OPENAI' | 'GOOGLE' | 'ElevenLabs' | 'OpenAI' | 'Google TTS' | string;
|
|
41
|
+
export type InferenceModel = 'gpt-5.5' | 'GPT 5.5' | 'gemini-3.1-pro' | 'Gemini 3.1 Pro' | string;
|
|
42
|
+
export interface GoogleTTSSpeakerDetail {
|
|
43
|
+
provider?: 'GOOGLE' | string;
|
|
44
|
+
value?: string;
|
|
45
|
+
voiceId?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
languageCode?: string;
|
|
49
|
+
languageCodes?: string[];
|
|
50
|
+
Gender?: 'M' | 'F' | '' | string | null;
|
|
51
|
+
gender?: string;
|
|
52
|
+
genderCode?: string;
|
|
53
|
+
ssmlGender?: string;
|
|
54
|
+
naturalSampleRateHertz?: number | null;
|
|
55
|
+
voiceType?: string;
|
|
56
|
+
previewRequiresAuth?: boolean;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
export interface TTSSpeakerOptions {
|
|
60
|
+
allowOpenAI?: boolean;
|
|
61
|
+
allowElevenLabs?: boolean;
|
|
62
|
+
allowGoogle?: boolean;
|
|
63
|
+
openAISpeakers?: string[];
|
|
64
|
+
elevenLabsSpeakers?: string[];
|
|
65
|
+
googleSpeakers?: string[];
|
|
66
|
+
googleSpeakerDetails?: GoogleTTSSpeakerDetail[];
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
39
69
|
export type V2StepGenerationMode = 'one_step' | 'two_step';
|
|
40
70
|
export interface V2StepGenerationOptions {
|
|
41
71
|
auto_render_full_video?: boolean;
|
|
@@ -50,7 +80,19 @@ export interface CreateVideoFromTextInput extends V2StepGenerationOptions {
|
|
|
50
80
|
duration: number;
|
|
51
81
|
tone?: string;
|
|
52
82
|
aspect_ratio?: string;
|
|
53
|
-
|
|
83
|
+
backingtrack_model?: BackingTrackModel;
|
|
84
|
+
backing_track_model?: BackingTrackModel;
|
|
85
|
+
backingTrackModel?: BackingTrackModel;
|
|
86
|
+
music_provider?: BackingTrackModel;
|
|
87
|
+
musicProvider?: BackingTrackModel;
|
|
88
|
+
tts_model?: TTSModel;
|
|
89
|
+
ttsModel?: TTSModel;
|
|
90
|
+
tts_provider?: TTSModel;
|
|
91
|
+
ttsProvider?: TTSModel;
|
|
92
|
+
inference_model?: InferenceModel;
|
|
93
|
+
inferenceModel?: InferenceModel;
|
|
94
|
+
speakerOptions?: TTSSpeakerOptions;
|
|
95
|
+
speaker_options?: TTSSpeakerOptions;
|
|
54
96
|
font_key?: string;
|
|
55
97
|
fontKey?: string;
|
|
56
98
|
subtitle_font?: string;
|
|
@@ -118,7 +160,7 @@ export interface FooterMetadataItem {
|
|
|
118
160
|
footerLogoImagePath?: string;
|
|
119
161
|
}
|
|
120
162
|
export type ImageListToVideoAspectRatio = '16:9' | '9:16';
|
|
121
|
-
export type ImageListToVideoModel = 'RUNWAYML' | 'VEO3.1I2V' | 'VEO3.1I2VFAST' | 'SEEDANCEI2V' | 'KLINGIMGTOVID3PRO' | 'HAPPYHORSEI2V';
|
|
163
|
+
export type ImageListToVideoModel = 'RUNWAYML' | 'VEO3.1I2V' | 'VEO3.1I2VFAST' | 'COSMOS3SUPERI2V' | 'SEEDANCEI2V' | 'KLINGIMGTOVID3PRO' | 'HAPPYHORSEI2V';
|
|
122
164
|
export interface ImageListToVideoItem {
|
|
123
165
|
image_url?: string;
|
|
124
166
|
imageUrl?: string;
|
|
@@ -155,6 +197,19 @@ export interface CreateVideoFromImageListInput extends V2StepGenerationOptions {
|
|
|
155
197
|
aspectRatio?: ImageListToVideoAspectRatio;
|
|
156
198
|
language?: string;
|
|
157
199
|
languageString?: string | null;
|
|
200
|
+
backingtrack_model?: BackingTrackModel;
|
|
201
|
+
backing_track_model?: BackingTrackModel;
|
|
202
|
+
backingTrackModel?: BackingTrackModel;
|
|
203
|
+
music_provider?: BackingTrackModel;
|
|
204
|
+
musicProvider?: BackingTrackModel;
|
|
205
|
+
tts_model?: TTSModel;
|
|
206
|
+
ttsModel?: TTSModel;
|
|
207
|
+
tts_provider?: TTSModel;
|
|
208
|
+
ttsProvider?: TTSModel;
|
|
209
|
+
inference_model?: InferenceModel;
|
|
210
|
+
inferenceModel?: InferenceModel;
|
|
211
|
+
speakerOptions?: TTSSpeakerOptions;
|
|
212
|
+
speaker_options?: TTSSpeakerOptions;
|
|
158
213
|
font_key?: string;
|
|
159
214
|
fontKey?: string;
|
|
160
215
|
subtitle_font?: string;
|
|
@@ -939,22 +994,6 @@ export interface RemoveBrandingFromImageResponse {
|
|
|
939
994
|
remainingCredits?: number;
|
|
940
995
|
[key: string]: unknown;
|
|
941
996
|
}
|
|
942
|
-
export interface ReplaceBrandingFromImageRequest {
|
|
943
|
-
image_urls: string[];
|
|
944
|
-
}
|
|
945
|
-
export interface ReplaceBrandingFromImageResponse {
|
|
946
|
-
status?: string;
|
|
947
|
-
message?: string;
|
|
948
|
-
request_id?: string;
|
|
949
|
-
session_id?: string;
|
|
950
|
-
global_status_id?: string;
|
|
951
|
-
case_type?: string;
|
|
952
|
-
image_urls: string[];
|
|
953
|
-
userId?: string;
|
|
954
|
-
creditsCharged?: number;
|
|
955
|
-
remainingCredits?: number;
|
|
956
|
-
[key: string]: unknown;
|
|
957
|
-
}
|
|
958
997
|
export interface EnhanceImageRequest {
|
|
959
998
|
image_url: string;
|
|
960
999
|
resolution?: '1k' | '2k' | '3k' | '4k';
|
|
@@ -1866,6 +1905,18 @@ export interface CreditsRechargeResponse {
|
|
|
1866
1905
|
currency: string;
|
|
1867
1906
|
[key: string]: unknown;
|
|
1868
1907
|
}
|
|
1908
|
+
export interface V2CreditsRechargeRequest {
|
|
1909
|
+
credits?: number;
|
|
1910
|
+
credits_to_recharge?: number;
|
|
1911
|
+
creditsToRecharge?: number;
|
|
1912
|
+
[key: string]: unknown;
|
|
1913
|
+
}
|
|
1914
|
+
export interface V2CreditsGrantRequest {
|
|
1915
|
+
credits?: number;
|
|
1916
|
+
credits_to_grant?: number;
|
|
1917
|
+
creditsToGrant?: number;
|
|
1918
|
+
[key: string]: unknown;
|
|
1919
|
+
}
|
|
1869
1920
|
export interface EnableAutoRechargeRequest {
|
|
1870
1921
|
thresholdCredits?: number;
|
|
1871
1922
|
amountUsd?: number;
|
|
@@ -1970,6 +2021,8 @@ export declare class SamsarClient {
|
|
|
1970
2021
|
getV2<T = Record<string, unknown>>(path: string, options?: V2RequestOptions): Promise<SamsarResult<T>>;
|
|
1971
2022
|
createV2Session(options?: V2RequestOptions): Promise<SamsarResult<V2SessionResponse>>;
|
|
1972
2023
|
getV2Credits(options?: V2RequestOptions): Promise<SamsarResult<CreditsBalanceResponse | ExternalCreditsBalanceResponse>>;
|
|
2024
|
+
createV2CreditsRecharge(payload: number | V2CreditsRechargeRequest, options?: V2RequestOptions): Promise<SamsarResult<CreditsRechargeResponse | ExternalCreditsRechargeResponse>>;
|
|
2025
|
+
grantV2Credits(payload: number | V2CreditsGrantRequest, options?: V2RequestOptions): Promise<SamsarResult<ExternalCreditsGrantResponse>>;
|
|
1973
2026
|
getV2UserCredits(options?: V2RequestOptions): Promise<SamsarResult<CreditsBalanceResponse>>;
|
|
1974
2027
|
getV2UserUsageLogs(options?: V2RequestOptions & {
|
|
1975
2028
|
page?: number;
|
|
@@ -1986,6 +2039,7 @@ export declare class SamsarClient {
|
|
|
1986
2039
|
refreshV2UserAppKey(payload?: V2UserAppKeyRefreshRequest, options?: V2RequestOptions): Promise<SamsarResult<V2UserAppKeyResponse>>;
|
|
1987
2040
|
revokeV2UserAppKey(options?: V2RequestOptions): Promise<SamsarResult<V2UserAppKeyResponse>>;
|
|
1988
2041
|
getV2UserPaymentStatus(payload: PaymentStatusRequest, options?: V2RequestOptions): Promise<SamsarResult<PaymentStatusResponse>>;
|
|
2042
|
+
getV2PaymentStatus(payload: PaymentStatusRequest, options?: V2RequestOptions): Promise<SamsarResult<PaymentStatusResponse | ExternalPaymentStatusResponse>>;
|
|
1989
2043
|
createV2LoginToken(options?: V2RequestOptions & {
|
|
1990
2044
|
redirect?: string;
|
|
1991
2045
|
}): Promise<SamsarResult<CreateLoginTokenResponse | ExternalCreateLoginTokenResponse>>;
|
|
@@ -2014,6 +2068,7 @@ export declare class SamsarClient {
|
|
|
2014
2068
|
updateV2VideoOutroImage(input: UpdateVideoOutroImageInput, options?: V2RequestOptions): Promise<SamsarResult<UpdateVideoOutroImageResponse | ExternalRequestResponse>>;
|
|
2015
2069
|
updateV2VideoFooterImage(input: UpdateVideoFooterImageInput, options?: V2RequestOptions): Promise<SamsarResult<UpdateVideoFooterImageResponse | ExternalRequestResponse>>;
|
|
2016
2070
|
addV2VideoOutroImage(input: AddVideoOutroImageInput, options?: V2RequestOptions): Promise<SamsarResult<AddVideoOutroImageResponse | ExternalRequestResponse>>;
|
|
2071
|
+
joinV2Videos(input: JoinVideosInput, options?: V2RequestOptions): Promise<SamsarResult<JoinVideosResponse | ExternalRequestResponse>>;
|
|
2017
2072
|
getV2Status(requestId: string, options?: V2RequestOptions & {
|
|
2018
2073
|
queryParams?: QueryParams;
|
|
2019
2074
|
}): Promise<SamsarResult<GlobalStatusResponse | ExternalStatusResponse>>;
|
|
@@ -2023,6 +2078,10 @@ export declare class SamsarClient {
|
|
|
2023
2078
|
getV2DetailedStatus(requestId: string, options?: V2RequestOptions & {
|
|
2024
2079
|
queryParams?: QueryParams;
|
|
2025
2080
|
}): Promise<SamsarResult<GlobalStatusDetailedResponse | ExternalStatusDetailedResponse>>;
|
|
2081
|
+
/**
|
|
2082
|
+
* Cancel an in-progress v2 render for an existing video session.
|
|
2083
|
+
*/
|
|
2084
|
+
cancelV2Render(input: CancelRenderInput, options?: V2RequestOptions): Promise<SamsarResult<CancelRenderResponse>>;
|
|
2026
2085
|
/**
|
|
2027
2086
|
* Create a new video generation job from text.
|
|
2028
2087
|
*/
|
|
@@ -2285,13 +2344,9 @@ export declare class SamsarClient {
|
|
|
2285
2344
|
*/
|
|
2286
2345
|
getEmbeddingStatus(templateId: string, options?: SamsarRequestOptions): Promise<SamsarResult<EmbeddingStatusResponse>>;
|
|
2287
2346
|
/**
|
|
2288
|
-
* Remove
|
|
2347
|
+
* Remove visible text from an image by URL.
|
|
2289
2348
|
*/
|
|
2290
2349
|
removeBrandingFromImage(payload: RemoveBrandingFromImageRequest, options?: SamsarRequestOptions): Promise<SamsarResult<RemoveBrandingFromImageResponse>>;
|
|
2291
|
-
/**
|
|
2292
|
-
* Replace branding/watermark on an image by providing the original and replacement image URLs.
|
|
2293
|
-
*/
|
|
2294
|
-
replaceBrandingFromImage(payload: ReplaceBrandingFromImageRequest, options?: SamsarRequestOptions): Promise<SamsarResult<ReplaceBrandingFromImageResponse>>;
|
|
2295
2350
|
/**
|
|
2296
2351
|
* Enhance an image by upscaling it with the specified resolution.
|
|
2297
2352
|
*/
|
package/dist/index.js
CHANGED
|
@@ -137,6 +137,10 @@ function normalizeCreateVideoFromTextInput(input) {
|
|
|
137
137
|
['cta_logo', ['cta_logo', 'ctaLogo']],
|
|
138
138
|
['add_footer_animation', ['add_footer_animation', 'addFooterAnimation']],
|
|
139
139
|
['footer_metadata', ['footer_metadata', 'footerMetadata']],
|
|
140
|
+
['backingtrack_model', ['backingtrack_model', 'backing_track_model', 'backingTrackModel', 'music_provider', 'musicProvider']],
|
|
141
|
+
['tts_model', ['tts_model', 'ttsModel', 'tts_provider', 'ttsProvider']],
|
|
142
|
+
['inference_model', ['inference_model', 'inferenceModel']],
|
|
143
|
+
['speakerOptions', ['speakerOptions', 'speaker_options']],
|
|
140
144
|
['enable_subtitles', ['enable_subtitles', 'enableSubtitles']],
|
|
141
145
|
['font_key', ['font_key', 'fontKey']],
|
|
142
146
|
];
|
|
@@ -146,6 +150,8 @@ function normalizeCreateVideoFromTextInput(input) {
|
|
|
146
150
|
normalized[canonicalName] = value;
|
|
147
151
|
}
|
|
148
152
|
}
|
|
153
|
+
delete normalized.video_model_sub_type;
|
|
154
|
+
delete normalized.videoModelSubType;
|
|
149
155
|
assertOptionalBoolean(normalized.enable_subtitles, 'enable_subtitles', 'createVideoFromText');
|
|
150
156
|
assertOptionalBoolean(normalized.add_outro_animation, 'add_outro_animation', 'createVideoFromText');
|
|
151
157
|
assertOptionalBoolean(normalized.add_outro_focus_area, 'add_outro_focus_area', 'createVideoFromText');
|
|
@@ -193,6 +199,10 @@ function normalizeCreateVideoFromImageListInput(input) {
|
|
|
193
199
|
['cta_logo', ['cta_logo', 'ctaLogo']],
|
|
194
200
|
['add_footer_animation', ['add_footer_animation', 'addFooterAnimation']],
|
|
195
201
|
['footer_metadata', ['footer_metadata', 'footerMetadata']],
|
|
202
|
+
['backingtrack_model', ['backingtrack_model', 'backing_track_model', 'backingTrackModel', 'music_provider', 'musicProvider']],
|
|
203
|
+
['tts_model', ['tts_model', 'ttsModel', 'tts_provider', 'ttsProvider']],
|
|
204
|
+
['inference_model', ['inference_model', 'inferenceModel']],
|
|
205
|
+
['speakerOptions', ['speakerOptions', 'speaker_options']],
|
|
196
206
|
['limit_single_narrator', ['limit_single_narrator', 'limitSingleNarrator']],
|
|
197
207
|
['add_narrator_avatar', ['add_narrator_avatar', 'addNarratorAvatar']],
|
|
198
208
|
['enable_subtitles', ['enable_subtitles', 'enableSubtitles']],
|
|
@@ -204,6 +214,8 @@ function normalizeCreateVideoFromImageListInput(input) {
|
|
|
204
214
|
normalized[canonicalName] = value;
|
|
205
215
|
}
|
|
206
216
|
}
|
|
217
|
+
delete normalized.video_model_sub_type;
|
|
218
|
+
delete normalized.videoModelSubType;
|
|
207
219
|
assertOptionalBoolean(normalized.enable_subtitles, 'enable_subtitles');
|
|
208
220
|
assertOptionalBoolean(normalized.add_outro_animation, 'add_outro_animation');
|
|
209
221
|
assertOptionalBoolean(normalized.add_outro_focus_area, 'add_outro_focus_area');
|
|
@@ -557,6 +569,32 @@ export class SamsarClient {
|
|
|
557
569
|
async getV2Credits(options) {
|
|
558
570
|
return this.getV2('credits', options);
|
|
559
571
|
}
|
|
572
|
+
async createV2CreditsRecharge(payload, options) {
|
|
573
|
+
const input = typeof payload === 'number' ? { credits: payload } : (payload ?? {});
|
|
574
|
+
const credits = Number(input.credits ?? input.credits_to_recharge ?? input.creditsToRecharge);
|
|
575
|
+
if (!Number.isFinite(credits) || credits <= 0 || !Number.isInteger(credits)) {
|
|
576
|
+
throw new Error('credits must be a positive integer');
|
|
577
|
+
}
|
|
578
|
+
return this.postV2('credits/recharge', {
|
|
579
|
+
input: {
|
|
580
|
+
...input,
|
|
581
|
+
credits,
|
|
582
|
+
},
|
|
583
|
+
}, options);
|
|
584
|
+
}
|
|
585
|
+
async grantV2Credits(payload, options) {
|
|
586
|
+
const input = typeof payload === 'number' ? { credits: payload } : (payload ?? {});
|
|
587
|
+
const credits = Number(input.credits ?? input.credits_to_grant ?? input.creditsToGrant);
|
|
588
|
+
if (!Number.isFinite(credits) || credits <= 0 || !Number.isInteger(credits)) {
|
|
589
|
+
throw new Error('credits must be a positive integer');
|
|
590
|
+
}
|
|
591
|
+
return this.postV2('credits/grant', {
|
|
592
|
+
input: {
|
|
593
|
+
...input,
|
|
594
|
+
credits,
|
|
595
|
+
},
|
|
596
|
+
}, options);
|
|
597
|
+
}
|
|
560
598
|
async getV2UserCredits(options) {
|
|
561
599
|
return this.getV2('user/credits', options);
|
|
562
600
|
}
|
|
@@ -689,6 +727,24 @@ export class SamsarClient {
|
|
|
689
727
|
query,
|
|
690
728
|
});
|
|
691
729
|
}
|
|
730
|
+
async getV2PaymentStatus(payload, options) {
|
|
731
|
+
const query = {
|
|
732
|
+
...(options?.query ?? {}),
|
|
733
|
+
};
|
|
734
|
+
if (payload?.checkoutSessionId) {
|
|
735
|
+
query.checkoutSessionId = payload.checkoutSessionId;
|
|
736
|
+
}
|
|
737
|
+
if (payload?.paymentIntentId) {
|
|
738
|
+
query.paymentIntentId = payload.paymentIntentId;
|
|
739
|
+
}
|
|
740
|
+
if (payload?.setupIntentId) {
|
|
741
|
+
query.setupIntentId = payload.setupIntentId;
|
|
742
|
+
}
|
|
743
|
+
return this.getV2('payment_status', {
|
|
744
|
+
...(options ?? {}),
|
|
745
|
+
query,
|
|
746
|
+
});
|
|
747
|
+
}
|
|
692
748
|
async createV2LoginToken(options) {
|
|
693
749
|
const body = options?.redirect ? { redirect: options.redirect } : {};
|
|
694
750
|
return this.postV2('create_login_token', body, options);
|
|
@@ -828,6 +884,22 @@ export class SamsarClient {
|
|
|
828
884
|
webhookUrl: options?.webhookUrl,
|
|
829
885
|
}, options);
|
|
830
886
|
}
|
|
887
|
+
async joinV2Videos(input, options) {
|
|
888
|
+
const rawIds = input.session_ids ?? input.sessionIds ?? input.video_session_ids ?? input.videoSessionIds;
|
|
889
|
+
const sessionIds = Array.isArray(rawIds)
|
|
890
|
+
? rawIds.map((value) => (typeof value === 'string' ? value.trim() : '')).filter(Boolean)
|
|
891
|
+
: [];
|
|
892
|
+
if (sessionIds.length < 2) {
|
|
893
|
+
throw new Error('at least two session IDs are required for joinV2Videos');
|
|
894
|
+
}
|
|
895
|
+
return this.postV2('join_videos', {
|
|
896
|
+
input: {
|
|
897
|
+
...input,
|
|
898
|
+
session_ids: sessionIds,
|
|
899
|
+
},
|
|
900
|
+
webhookUrl: options?.webhookUrl,
|
|
901
|
+
}, options);
|
|
902
|
+
}
|
|
831
903
|
async getV2Status(requestId, options) {
|
|
832
904
|
const queryParams = {
|
|
833
905
|
...(options?.externalUser
|
|
@@ -857,6 +929,48 @@ export class SamsarClient {
|
|
|
857
929
|
async getV2DetailedStatus(requestId, options) {
|
|
858
930
|
return this.getV2StatusDetailed(requestId, options);
|
|
859
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Cancel an in-progress v2 render for an existing video session.
|
|
934
|
+
*/
|
|
935
|
+
async cancelV2Render(input, options) {
|
|
936
|
+
const raw = input;
|
|
937
|
+
const videoSessionId = raw.videoSessionId ??
|
|
938
|
+
raw.video_session_id ??
|
|
939
|
+
raw.videoSessionID ??
|
|
940
|
+
raw.session_id ??
|
|
941
|
+
raw.sessionId ??
|
|
942
|
+
raw.sessionID ??
|
|
943
|
+
raw.request_id ??
|
|
944
|
+
raw.requestId;
|
|
945
|
+
if (!videoSessionId) {
|
|
946
|
+
throw new Error('videoSessionId is required for cancelV2Render');
|
|
947
|
+
}
|
|
948
|
+
const response = await this.postV2('cancel_render', {
|
|
949
|
+
input: {
|
|
950
|
+
...input,
|
|
951
|
+
videoSessionId: String(videoSessionId),
|
|
952
|
+
},
|
|
953
|
+
}, options);
|
|
954
|
+
const data = response.data;
|
|
955
|
+
if (data && typeof data === 'object') {
|
|
956
|
+
const sessionId = typeof data.sessionID === 'string'
|
|
957
|
+
? data.sessionID
|
|
958
|
+
: typeof data.session_id === 'string'
|
|
959
|
+
? data.session_id
|
|
960
|
+
: typeof data.request_id === 'string'
|
|
961
|
+
? data.request_id
|
|
962
|
+
: undefined;
|
|
963
|
+
const normalizedSessionId = sessionId ? String(sessionId) : undefined;
|
|
964
|
+
const normalizedData = {
|
|
965
|
+
...data,
|
|
966
|
+
sessionID: data.sessionID ?? normalizedSessionId ?? '',
|
|
967
|
+
session_id: data.session_id ?? normalizedSessionId,
|
|
968
|
+
request_id: data.request_id ?? normalizedSessionId,
|
|
969
|
+
};
|
|
970
|
+
return { ...response, data: normalizedData };
|
|
971
|
+
}
|
|
972
|
+
return response;
|
|
973
|
+
}
|
|
860
974
|
/**
|
|
861
975
|
* Create a new video generation job from text.
|
|
862
976
|
*/
|
|
@@ -1757,17 +1871,11 @@ export class SamsarClient {
|
|
|
1757
1871
|
});
|
|
1758
1872
|
}
|
|
1759
1873
|
/**
|
|
1760
|
-
* Remove
|
|
1874
|
+
* Remove visible text from an image by URL.
|
|
1761
1875
|
*/
|
|
1762
1876
|
async removeBrandingFromImage(payload, options) {
|
|
1763
1877
|
return this.post('image/remove_branding', payload, options);
|
|
1764
1878
|
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Replace branding/watermark on an image by providing the original and replacement image URLs.
|
|
1767
|
-
*/
|
|
1768
|
-
async replaceBrandingFromImage(payload, options) {
|
|
1769
|
-
return this.post('image/replace_branding', payload, options);
|
|
1770
|
-
}
|
|
1771
1879
|
/**
|
|
1772
1880
|
* Enhance an image by upscaling it with the specified resolution.
|
|
1773
1881
|
*/
|