@runpod/ai-sdk-provider 1.2.0 → 1.3.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/CHANGELOG.md +6 -0
- package/README.md +110 -10
- package/dist/index.d.mts +46 -3
- package/dist/index.d.ts +46 -3
- package/dist/index.js +318 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +322 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "@ai-sdk/openai-compatible";
|
|
6
6
|
import {
|
|
7
7
|
loadApiKey,
|
|
8
|
-
withoutTrailingSlash as
|
|
8
|
+
withoutTrailingSlash as withoutTrailingSlash4
|
|
9
9
|
} from "@ai-sdk/provider-utils";
|
|
10
10
|
|
|
11
11
|
// src/runpod-image-model.ts
|
|
@@ -54,6 +54,10 @@ var runpodTranscriptionFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
54
54
|
errorSchema: runpodImageErrorSchema,
|
|
55
55
|
errorToMessage: extractErrorMessage
|
|
56
56
|
});
|
|
57
|
+
var runpodVideoFailedResponseHandler = createJsonErrorResponseHandler({
|
|
58
|
+
errorSchema: runpodImageErrorSchema,
|
|
59
|
+
errorToMessage: extractErrorMessage
|
|
60
|
+
});
|
|
57
61
|
|
|
58
62
|
// src/runpod-image-model.ts
|
|
59
63
|
var SUPPORTED_ASPECT_RATIOS = {
|
|
@@ -86,6 +90,50 @@ var SUPPORTED_SIZES = /* @__PURE__ */ new Set([
|
|
|
86
90
|
"1024*768",
|
|
87
91
|
"768*1024"
|
|
88
92
|
]);
|
|
93
|
+
var Z_IMAGE_TURBO_SUPPORTED_SIZES = /* @__PURE__ */ new Set([
|
|
94
|
+
"1328*1328",
|
|
95
|
+
// 1:1
|
|
96
|
+
"1472*1140",
|
|
97
|
+
// 4:3
|
|
98
|
+
"1140*1472",
|
|
99
|
+
// 3:4
|
|
100
|
+
"512*512",
|
|
101
|
+
"768*768",
|
|
102
|
+
"1024*1024",
|
|
103
|
+
"1280*1280",
|
|
104
|
+
"1536*1536",
|
|
105
|
+
"512*768",
|
|
106
|
+
"768*512",
|
|
107
|
+
"1024*768",
|
|
108
|
+
"768*1024",
|
|
109
|
+
"768*432",
|
|
110
|
+
"1024*576",
|
|
111
|
+
"1280*720",
|
|
112
|
+
"1536*864",
|
|
113
|
+
"432*768",
|
|
114
|
+
"576*1024",
|
|
115
|
+
"720*1280",
|
|
116
|
+
"864*1536"
|
|
117
|
+
]);
|
|
118
|
+
var Z_IMAGE_TURBO_ASPECT_RATIOS = {
|
|
119
|
+
"1:1": "1328*1328",
|
|
120
|
+
"4:3": "1472*1140",
|
|
121
|
+
"3:4": "1140*1472",
|
|
122
|
+
"3:2": "768*512",
|
|
123
|
+
"2:3": "512*768",
|
|
124
|
+
"16:9": "1280*720",
|
|
125
|
+
"9:16": "720*1280"
|
|
126
|
+
};
|
|
127
|
+
var MODEL_SUPPORTED_SIZES = {
|
|
128
|
+
"tongyi-mai/z-image-turbo": Z_IMAGE_TURBO_SUPPORTED_SIZES,
|
|
129
|
+
"z-image-turbo": Z_IMAGE_TURBO_SUPPORTED_SIZES
|
|
130
|
+
// alias, not advertised
|
|
131
|
+
};
|
|
132
|
+
var MODEL_SUPPORTED_ASPECT_RATIOS = {
|
|
133
|
+
"tongyi-mai/z-image-turbo": Z_IMAGE_TURBO_ASPECT_RATIOS,
|
|
134
|
+
"z-image-turbo": Z_IMAGE_TURBO_ASPECT_RATIOS
|
|
135
|
+
// alias, not advertised
|
|
136
|
+
};
|
|
89
137
|
var WAN_ASPECT_RATIOS = {
|
|
90
138
|
"1:1": "1280*1280",
|
|
91
139
|
// 1,638,400 pixels
|
|
@@ -191,23 +239,27 @@ var RunpodImageModel = class {
|
|
|
191
239
|
}
|
|
192
240
|
} else if (size) {
|
|
193
241
|
const runpodSizeCandidate = size.replace("x", "*");
|
|
194
|
-
|
|
242
|
+
const supportedSizes = MODEL_SUPPORTED_SIZES[this.modelId] ?? SUPPORTED_SIZES;
|
|
243
|
+
if (!supportedSizes.has(runpodSizeCandidate)) {
|
|
195
244
|
throw new InvalidArgumentError({
|
|
196
245
|
argument: "size",
|
|
197
246
|
message: `Size ${size} is not supported by Runpod. Supported sizes: ${Array.from(
|
|
198
|
-
|
|
247
|
+
supportedSizes
|
|
199
248
|
).map((s) => s.replace("*", "x")).join(", ")}`
|
|
200
249
|
});
|
|
201
250
|
}
|
|
202
251
|
runpodSize = runpodSizeCandidate;
|
|
203
252
|
} else if (aspectRatio) {
|
|
204
|
-
|
|
253
|
+
const supportedAspectRatios = MODEL_SUPPORTED_ASPECT_RATIOS[this.modelId] ?? SUPPORTED_ASPECT_RATIOS;
|
|
254
|
+
if (!supportedAspectRatios[aspectRatio]) {
|
|
205
255
|
throw new InvalidArgumentError({
|
|
206
256
|
argument: "aspectRatio",
|
|
207
|
-
message: `Aspect ratio ${aspectRatio} is not supported by Runpod. Supported aspect ratios: ${Object.keys(
|
|
257
|
+
message: `Aspect ratio ${aspectRatio} is not supported by Runpod. Supported aspect ratios: ${Object.keys(
|
|
258
|
+
supportedAspectRatios
|
|
259
|
+
).join(", ")}`
|
|
208
260
|
});
|
|
209
261
|
}
|
|
210
|
-
runpodSize =
|
|
262
|
+
runpodSize = supportedAspectRatios[aspectRatio];
|
|
211
263
|
} else {
|
|
212
264
|
runpodSize = "1328*1328";
|
|
213
265
|
}
|
|
@@ -510,6 +562,25 @@ var RunpodImageModel = class {
|
|
|
510
562
|
}
|
|
511
563
|
return qwenEdit2511Payload;
|
|
512
564
|
}
|
|
565
|
+
const isZImageTurbo = this.modelId === "tongyi-mai/z-image-turbo" || this.modelId === "z-image-turbo";
|
|
566
|
+
if (isZImageTurbo) {
|
|
567
|
+
const zImageTurboPayload = {
|
|
568
|
+
prompt,
|
|
569
|
+
size: runpodSize,
|
|
570
|
+
seed: seed ?? -1,
|
|
571
|
+
output_format: runpodOptions?.output_format ?? "png",
|
|
572
|
+
enable_safety_checker: runpodOptions?.enable_safety_checker ?? true,
|
|
573
|
+
...runpodOptions
|
|
574
|
+
};
|
|
575
|
+
if (standardizedImages && standardizedImages.length > 0) {
|
|
576
|
+
if (standardizedImages.length === 1) {
|
|
577
|
+
zImageTurboPayload.image = standardizedImages[0];
|
|
578
|
+
} else {
|
|
579
|
+
zImageTurboPayload.images = standardizedImages;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return zImageTurboPayload;
|
|
583
|
+
}
|
|
513
584
|
const isWanModel = this.modelId.includes("wan-2");
|
|
514
585
|
if (isWanModel) {
|
|
515
586
|
return {
|
|
@@ -928,6 +999,215 @@ var RunpodTranscriptionModel = class {
|
|
|
928
999
|
}
|
|
929
1000
|
};
|
|
930
1001
|
|
|
1002
|
+
// src/runpod-video-model.ts
|
|
1003
|
+
import {
|
|
1004
|
+
withoutTrailingSlash as withoutTrailingSlash3,
|
|
1005
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1006
|
+
getFromApi as getFromApi3,
|
|
1007
|
+
postJsonToApi as postJsonToApi3
|
|
1008
|
+
} from "@ai-sdk/provider-utils";
|
|
1009
|
+
import { z as z4 } from "zod";
|
|
1010
|
+
function isRecord3(value) {
|
|
1011
|
+
return typeof value === "object" && value !== null;
|
|
1012
|
+
}
|
|
1013
|
+
var runpodVideoJobResponseSchema = z4.object({
|
|
1014
|
+
id: z4.string(),
|
|
1015
|
+
status: z4.string().optional()
|
|
1016
|
+
});
|
|
1017
|
+
var runpodVideoStatusSchema = z4.object({
|
|
1018
|
+
id: z4.string().optional(),
|
|
1019
|
+
status: z4.string(),
|
|
1020
|
+
output: z4.unknown().optional(),
|
|
1021
|
+
error: z4.string().optional()
|
|
1022
|
+
});
|
|
1023
|
+
var RunpodVideoModel = class {
|
|
1024
|
+
constructor(modelId, config) {
|
|
1025
|
+
this.modelId = modelId;
|
|
1026
|
+
this.config = config;
|
|
1027
|
+
this.specificationVersion = "v3";
|
|
1028
|
+
this.maxVideosPerCall = 1;
|
|
1029
|
+
}
|
|
1030
|
+
get provider() {
|
|
1031
|
+
return this.config.provider;
|
|
1032
|
+
}
|
|
1033
|
+
getRunpodRunUrl() {
|
|
1034
|
+
const baseURL = withoutTrailingSlash3(this.config.baseURL) ?? this.config.baseURL;
|
|
1035
|
+
if (baseURL.endsWith("/run") || baseURL.endsWith("/runsync")) {
|
|
1036
|
+
return baseURL;
|
|
1037
|
+
}
|
|
1038
|
+
return `${baseURL}/run`;
|
|
1039
|
+
}
|
|
1040
|
+
async doGenerate(options) {
|
|
1041
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
1042
|
+
const warnings = [];
|
|
1043
|
+
if (options.n > 1) {
|
|
1044
|
+
warnings.push({
|
|
1045
|
+
type: "unsupported",
|
|
1046
|
+
feature: "n > 1",
|
|
1047
|
+
details: "Runpod video models only support generating 1 video per call. Only 1 video will be generated."
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
const { providerOptions, abortSignal, headers } = options;
|
|
1051
|
+
const runpodOptions = this.extractRunpodOptions(providerOptions);
|
|
1052
|
+
const input = this.buildInputPayload(options, runpodOptions);
|
|
1053
|
+
const requestBody = { input };
|
|
1054
|
+
const url = this.getRunpodRunUrl();
|
|
1055
|
+
const effectiveBaseURL = withoutTrailingSlash3(this.config.baseURL) ?? this.config.baseURL;
|
|
1056
|
+
const { value: response, responseHeaders } = await postJsonToApi3({
|
|
1057
|
+
url,
|
|
1058
|
+
headers: {
|
|
1059
|
+
...this.config.headers(),
|
|
1060
|
+
...headers
|
|
1061
|
+
},
|
|
1062
|
+
body: requestBody,
|
|
1063
|
+
failedResponseHandler: runpodVideoFailedResponseHandler,
|
|
1064
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
1065
|
+
runpodVideoJobResponseSchema
|
|
1066
|
+
),
|
|
1067
|
+
abortSignal,
|
|
1068
|
+
fetch: this.config.fetch
|
|
1069
|
+
});
|
|
1070
|
+
const typedResponse = response;
|
|
1071
|
+
const jobId = typedResponse.id;
|
|
1072
|
+
if (!jobId) {
|
|
1073
|
+
throw new Error("Runpod video response did not include a job id.");
|
|
1074
|
+
}
|
|
1075
|
+
const pollOptions = {
|
|
1076
|
+
maxAttempts: runpodOptions.maxPollAttempts ?? 120,
|
|
1077
|
+
pollIntervalMillis: runpodOptions.pollIntervalMillis ?? 5e3
|
|
1078
|
+
};
|
|
1079
|
+
const result = await this.pollForCompletion(
|
|
1080
|
+
jobId,
|
|
1081
|
+
abortSignal,
|
|
1082
|
+
pollOptions,
|
|
1083
|
+
effectiveBaseURL
|
|
1084
|
+
);
|
|
1085
|
+
const videoUrl = this.extractVideoUrl(result.output);
|
|
1086
|
+
const providerMetadata = {
|
|
1087
|
+
runpod: {
|
|
1088
|
+
jobId
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
return {
|
|
1092
|
+
videos: [{ type: "url", url: videoUrl, mediaType: "video/mp4" }],
|
|
1093
|
+
warnings,
|
|
1094
|
+
response: {
|
|
1095
|
+
timestamp: currentDate,
|
|
1096
|
+
modelId: this.modelId,
|
|
1097
|
+
headers: responseHeaders
|
|
1098
|
+
},
|
|
1099
|
+
providerMetadata
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
buildInputPayload(options, runpodOptions) {
|
|
1103
|
+
const apiOptions = Object.fromEntries(
|
|
1104
|
+
Object.entries(runpodOptions).filter(
|
|
1105
|
+
([key]) => key !== "maxPollAttempts" && key !== "pollIntervalMillis"
|
|
1106
|
+
)
|
|
1107
|
+
);
|
|
1108
|
+
const input = {
|
|
1109
|
+
...apiOptions
|
|
1110
|
+
};
|
|
1111
|
+
if (options.prompt) {
|
|
1112
|
+
input.prompt = options.prompt;
|
|
1113
|
+
}
|
|
1114
|
+
if (options.duration !== void 0) {
|
|
1115
|
+
input.duration = options.duration;
|
|
1116
|
+
}
|
|
1117
|
+
if (options.fps !== void 0) {
|
|
1118
|
+
input.fps = options.fps;
|
|
1119
|
+
}
|
|
1120
|
+
if (options.seed !== void 0) {
|
|
1121
|
+
input.seed = options.seed;
|
|
1122
|
+
}
|
|
1123
|
+
if (options.resolution) {
|
|
1124
|
+
input.size = options.resolution.replace("x", "*");
|
|
1125
|
+
} else if (options.aspectRatio) {
|
|
1126
|
+
input.aspect_ratio = options.aspectRatio;
|
|
1127
|
+
}
|
|
1128
|
+
if (options.image) {
|
|
1129
|
+
input.image = this.convertFileToRunpodFormat(options.image);
|
|
1130
|
+
}
|
|
1131
|
+
return input;
|
|
1132
|
+
}
|
|
1133
|
+
convertFileToRunpodFormat(file) {
|
|
1134
|
+
if (file.type === "url") {
|
|
1135
|
+
return file.url;
|
|
1136
|
+
}
|
|
1137
|
+
const mediaType = file.mediaType;
|
|
1138
|
+
const data = file.data;
|
|
1139
|
+
if (typeof data === "string") {
|
|
1140
|
+
return `data:${mediaType};base64,${data}`;
|
|
1141
|
+
}
|
|
1142
|
+
const base64 = this.uint8ArrayToBase64(data);
|
|
1143
|
+
return `data:${mediaType};base64,${base64}`;
|
|
1144
|
+
}
|
|
1145
|
+
uint8ArrayToBase64(data) {
|
|
1146
|
+
if (typeof Buffer !== "undefined") {
|
|
1147
|
+
return Buffer.from(data).toString("base64");
|
|
1148
|
+
}
|
|
1149
|
+
let binary = "";
|
|
1150
|
+
for (let i = 0; i < data.length; i++) {
|
|
1151
|
+
binary += String.fromCharCode(data[i]);
|
|
1152
|
+
}
|
|
1153
|
+
return btoa(binary);
|
|
1154
|
+
}
|
|
1155
|
+
extractRunpodOptions(providerOptions) {
|
|
1156
|
+
if (!providerOptions) return {};
|
|
1157
|
+
const runpod2 = providerOptions.runpod;
|
|
1158
|
+
if (isRecord3(runpod2)) {
|
|
1159
|
+
return runpod2;
|
|
1160
|
+
}
|
|
1161
|
+
return {};
|
|
1162
|
+
}
|
|
1163
|
+
extractVideoUrl(output) {
|
|
1164
|
+
if (isRecord3(output)) {
|
|
1165
|
+
if (typeof output.video_url === "string") return output.video_url;
|
|
1166
|
+
if (typeof output.result === "string") return output.result;
|
|
1167
|
+
if (typeof output.url === "string") return output.url;
|
|
1168
|
+
}
|
|
1169
|
+
if (typeof output === "string") {
|
|
1170
|
+
return output;
|
|
1171
|
+
}
|
|
1172
|
+
throw new Error(
|
|
1173
|
+
`Runpod video generation completed but no video URL was found in the output: ${JSON.stringify(output)}`
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
async pollForCompletion(jobId, abortSignal, pollOptions, effectiveBaseURL) {
|
|
1177
|
+
const maxAttempts = pollOptions?.maxAttempts ?? 120;
|
|
1178
|
+
const pollInterval = pollOptions?.pollIntervalMillis ?? 5e3;
|
|
1179
|
+
const baseURL = effectiveBaseURL ?? this.config.baseURL;
|
|
1180
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1181
|
+
if (abortSignal?.aborted) {
|
|
1182
|
+
throw new Error("Video generation was aborted");
|
|
1183
|
+
}
|
|
1184
|
+
const { value: statusResponse } = await getFromApi3({
|
|
1185
|
+
url: `${baseURL}/status/${jobId}`,
|
|
1186
|
+
headers: this.config.headers(),
|
|
1187
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
1188
|
+
runpodVideoStatusSchema
|
|
1189
|
+
),
|
|
1190
|
+
failedResponseHandler: runpodVideoFailedResponseHandler,
|
|
1191
|
+
abortSignal,
|
|
1192
|
+
fetch: this.config.fetch
|
|
1193
|
+
});
|
|
1194
|
+
const typedStatusResponse = statusResponse;
|
|
1195
|
+
if (typedStatusResponse.status === "COMPLETED") {
|
|
1196
|
+
return typedStatusResponse;
|
|
1197
|
+
}
|
|
1198
|
+
if (typedStatusResponse.status === "FAILED") {
|
|
1199
|
+
throw new Error(
|
|
1200
|
+
`Video generation failed: ${typedStatusResponse.error || "Unknown error"}`
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1203
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
1204
|
+
}
|
|
1205
|
+
throw new Error(
|
|
1206
|
+
`Video generation timed out after ${maxAttempts} attempts (${maxAttempts * pollInterval / 1e3}s)`
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
|
|
931
1211
|
// src/runpod-provider.ts
|
|
932
1212
|
var MODEL_ID_TO_ENDPOINT_URL = {
|
|
933
1213
|
"qwen/qwen3-32b-awq": "https://api.runpod.ai/v2/qwen3-32b-awq/openai/v1",
|
|
@@ -951,6 +1231,10 @@ var IMAGE_MODEL_ID_TO_ENDPOINT_URL = {
|
|
|
951
1231
|
"black-forest-labs/flux-1-dev": "https://api.runpod.ai/v2/black-forest-labs-flux-1-dev",
|
|
952
1232
|
// Alibaba Wan 2.6 (t2i)
|
|
953
1233
|
"alibaba/wan-2.6": "https://api.runpod.ai/v2/wan-2-6-t2i",
|
|
1234
|
+
// Tongyi Z-Image Turbo (t2i)
|
|
1235
|
+
"tongyi-mai/z-image-turbo": "https://api.runpod.ai/v2/z-image-turbo",
|
|
1236
|
+
"z-image-turbo": "https://api.runpod.ai/v2/z-image-turbo",
|
|
1237
|
+
// alias, not advertised
|
|
954
1238
|
// Nano Banana (edit only)
|
|
955
1239
|
"google/nano-banana-edit": "https://api.runpod.ai/v2/nano-banana-edit",
|
|
956
1240
|
"nano-banana-edit": "https://api.runpod.ai/v2/nano-banana-edit",
|
|
@@ -967,6 +1251,23 @@ var SPEECH_MODEL_ID_TO_ENDPOINT_URL = {
|
|
|
967
1251
|
var TRANSCRIPTION_MODEL_ID_TO_ENDPOINT_URL = {
|
|
968
1252
|
"pruna/whisper-v3-large": "https://api.runpod.ai/v2/whisper-v3-large"
|
|
969
1253
|
};
|
|
1254
|
+
var VIDEO_MODEL_ID_TO_ENDPOINT_URL = {
|
|
1255
|
+
"pruna/p-video": "https://api.runpod.ai/v2/p-video",
|
|
1256
|
+
"vidu/q3-t2v": "https://api.runpod.ai/v2/vidu-q3-t2v",
|
|
1257
|
+
"vidu/q3-i2v": "https://api.runpod.ai/v2/vidu-q3-i2v",
|
|
1258
|
+
"kwaivgi/kling-v2.6-std-motion-control": "https://api.runpod.ai/v2/kling-v2-6-std-motion-control",
|
|
1259
|
+
"kwaivgi/kling-video-o1-r2v": "https://api.runpod.ai/v2/kling-video-o1-r2v",
|
|
1260
|
+
"kwaivgi/kling-v2.1-i2v-pro": "https://api.runpod.ai/v2/kling-v2-1-i2v-pro",
|
|
1261
|
+
"alibaba/wan-2.6-t2v": "https://api.runpod.ai/v2/wan-2-6-t2v",
|
|
1262
|
+
"alibaba/wan-2.6-i2v": "https://api.runpod.ai/v2/wan-2-6-i2v",
|
|
1263
|
+
"alibaba/wan-2.5": "https://api.runpod.ai/v2/wan-2-5",
|
|
1264
|
+
"alibaba/wan-2.2-t2v-720-lora": "https://api.runpod.ai/v2/wan-2-2-t2v-720-lora",
|
|
1265
|
+
"alibaba/wan-2.2-i2v-720": "https://api.runpod.ai/v2/wan-2-2-i2v-720",
|
|
1266
|
+
"alibaba/wan-2.1-i2v-720": "https://api.runpod.ai/v2/wan-2-1-i2v-720",
|
|
1267
|
+
"bytedance/seedance-v1.5-pro-i2v": "https://api.runpod.ai/v2/seedance-v1-5-pro-i2v",
|
|
1268
|
+
"openai/sora-2-pro-i2v": "https://api.runpod.ai/v2/sora-2-pro-i2v",
|
|
1269
|
+
"openai/sora-2-i2v": "https://api.runpod.ai/v2/sora-2-i2v"
|
|
1270
|
+
};
|
|
970
1271
|
var MODEL_ID_TO_OPENAI_NAME = {
|
|
971
1272
|
"qwen/qwen3-32b-awq": "Qwen/Qwen3-32B-AWQ",
|
|
972
1273
|
"deepcogito/cogito-671b-v2.1-fp8": "deepcogito/cogito-671b-v2.1-FP8",
|
|
@@ -1025,7 +1326,7 @@ function createRunpod(options = {}) {
|
|
|
1025
1326
|
}
|
|
1026
1327
|
return {
|
|
1027
1328
|
provider: `runpod.${modelType}`,
|
|
1028
|
-
url: ({ path }) => `${
|
|
1329
|
+
url: ({ path }) => `${withoutTrailingSlash4(baseURL)}${path}`,
|
|
1029
1330
|
headers: getHeaders,
|
|
1030
1331
|
fetch: runpodFetch
|
|
1031
1332
|
};
|
|
@@ -1082,6 +1383,18 @@ function createRunpod(options = {}) {
|
|
|
1082
1383
|
fetch: runpodFetch
|
|
1083
1384
|
});
|
|
1084
1385
|
};
|
|
1386
|
+
const createVideoModel = (modelId) => {
|
|
1387
|
+
const endpointIdFromConsole = parseRunpodConsoleEndpointId(modelId);
|
|
1388
|
+
const normalizedModelId = endpointIdFromConsole ?? modelId;
|
|
1389
|
+
const mappedBaseURL = VIDEO_MODEL_ID_TO_ENDPOINT_URL[normalizedModelId];
|
|
1390
|
+
const baseURL = mappedBaseURL ?? (normalizedModelId.startsWith("http") ? normalizedModelId : `https://api.runpod.ai/v2/${normalizedModelId}`);
|
|
1391
|
+
return new RunpodVideoModel(normalizedModelId, {
|
|
1392
|
+
provider: "runpod.video",
|
|
1393
|
+
baseURL,
|
|
1394
|
+
headers: getHeaders,
|
|
1395
|
+
fetch: options.fetch
|
|
1396
|
+
});
|
|
1397
|
+
};
|
|
1085
1398
|
const provider = (modelId) => createChatModel(modelId);
|
|
1086
1399
|
provider.completionModel = createCompletionModel;
|
|
1087
1400
|
provider.languageModel = createChatModel;
|
|
@@ -1092,6 +1405,8 @@ function createRunpod(options = {}) {
|
|
|
1092
1405
|
provider.speech = createSpeechModel;
|
|
1093
1406
|
provider.transcriptionModel = createTranscriptionModel;
|
|
1094
1407
|
provider.transcription = createTranscriptionModel;
|
|
1408
|
+
provider.videoModel = createVideoModel;
|
|
1409
|
+
provider.video = createVideoModel;
|
|
1095
1410
|
return provider;
|
|
1096
1411
|
}
|
|
1097
1412
|
var runpod = createRunpod();
|