@runpod/ai-sdk-provider 1.2.0 → 1.4.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 +18 -0
- package/README.md +111 -10
- package/dist/index.d.mts +46 -3
- package/dist/index.d.ts +46 -3
- package/dist/index.js +343 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -15
- 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
|
|
@@ -169,9 +217,10 @@ var RunpodImageModel = class {
|
|
|
169
217
|
}
|
|
170
218
|
const isPrunaModel = this.modelId.includes("pruna") || this.modelId.includes("p-image");
|
|
171
219
|
const isNanoBananaProModel = this.modelId.includes("nano-banana-pro");
|
|
220
|
+
const isNanoBanana2Model = this.modelId.includes("nano-banana-2");
|
|
172
221
|
const isWanModel = this.modelId.includes("wan-2");
|
|
173
222
|
let runpodSize;
|
|
174
|
-
if (isPrunaModel || isNanoBananaProModel) {
|
|
223
|
+
if (isPrunaModel || isNanoBananaProModel || isNanoBanana2Model) {
|
|
175
224
|
runpodSize = aspectRatio || "1:1";
|
|
176
225
|
} else if (isWanModel) {
|
|
177
226
|
if (size) {
|
|
@@ -191,23 +240,27 @@ var RunpodImageModel = class {
|
|
|
191
240
|
}
|
|
192
241
|
} else if (size) {
|
|
193
242
|
const runpodSizeCandidate = size.replace("x", "*");
|
|
194
|
-
|
|
243
|
+
const supportedSizes = MODEL_SUPPORTED_SIZES[this.modelId] ?? SUPPORTED_SIZES;
|
|
244
|
+
if (!supportedSizes.has(runpodSizeCandidate)) {
|
|
195
245
|
throw new InvalidArgumentError({
|
|
196
246
|
argument: "size",
|
|
197
247
|
message: `Size ${size} is not supported by Runpod. Supported sizes: ${Array.from(
|
|
198
|
-
|
|
248
|
+
supportedSizes
|
|
199
249
|
).map((s) => s.replace("*", "x")).join(", ")}`
|
|
200
250
|
});
|
|
201
251
|
}
|
|
202
252
|
runpodSize = runpodSizeCandidate;
|
|
203
253
|
} else if (aspectRatio) {
|
|
204
|
-
|
|
254
|
+
const supportedAspectRatios = MODEL_SUPPORTED_ASPECT_RATIOS[this.modelId] ?? SUPPORTED_ASPECT_RATIOS;
|
|
255
|
+
if (!supportedAspectRatios[aspectRatio]) {
|
|
205
256
|
throw new InvalidArgumentError({
|
|
206
257
|
argument: "aspectRatio",
|
|
207
|
-
message: `Aspect ratio ${aspectRatio} is not supported by Runpod. Supported aspect ratios: ${Object.keys(
|
|
258
|
+
message: `Aspect ratio ${aspectRatio} is not supported by Runpod. Supported aspect ratios: ${Object.keys(
|
|
259
|
+
supportedAspectRatios
|
|
260
|
+
).join(", ")}`
|
|
208
261
|
});
|
|
209
262
|
}
|
|
210
|
-
runpodSize =
|
|
263
|
+
runpodSize = supportedAspectRatios[aspectRatio];
|
|
211
264
|
} else {
|
|
212
265
|
runpodSize = "1328*1328";
|
|
213
266
|
}
|
|
@@ -462,6 +515,22 @@ var RunpodImageModel = class {
|
|
|
462
515
|
return t2iPayload;
|
|
463
516
|
}
|
|
464
517
|
}
|
|
518
|
+
const isNanoBanana2Model = this.modelId.includes("nano-banana-2");
|
|
519
|
+
if (isNanoBanana2Model) {
|
|
520
|
+
const nanoBanana2Payload = {
|
|
521
|
+
prompt,
|
|
522
|
+
aspect_ratio: runpodOptions?.aspect_ratio ?? aspectRatio ?? "1:1",
|
|
523
|
+
resolution: runpodOptions?.resolution ?? "1k",
|
|
524
|
+
output_format: runpodOptions?.output_format ?? "jpeg",
|
|
525
|
+
enable_safety_checker: runpodOptions?.enable_safety_checker ?? true
|
|
526
|
+
};
|
|
527
|
+
if (standardizedImages && standardizedImages.length > 0) {
|
|
528
|
+
nanoBanana2Payload.images = standardizedImages;
|
|
529
|
+
} else if (runpodOptions?.images) {
|
|
530
|
+
nanoBanana2Payload.images = runpodOptions.images;
|
|
531
|
+
}
|
|
532
|
+
return nanoBanana2Payload;
|
|
533
|
+
}
|
|
465
534
|
const isNanaBananaProModel = this.modelId.includes("nano-banana-pro");
|
|
466
535
|
if (isNanaBananaProModel) {
|
|
467
536
|
const nanoBananaPayload = {
|
|
@@ -510,6 +579,25 @@ var RunpodImageModel = class {
|
|
|
510
579
|
}
|
|
511
580
|
return qwenEdit2511Payload;
|
|
512
581
|
}
|
|
582
|
+
const isZImageTurbo = this.modelId === "tongyi-mai/z-image-turbo" || this.modelId === "z-image-turbo";
|
|
583
|
+
if (isZImageTurbo) {
|
|
584
|
+
const zImageTurboPayload = {
|
|
585
|
+
prompt,
|
|
586
|
+
size: runpodSize,
|
|
587
|
+
seed: seed ?? -1,
|
|
588
|
+
output_format: runpodOptions?.output_format ?? "png",
|
|
589
|
+
enable_safety_checker: runpodOptions?.enable_safety_checker ?? true,
|
|
590
|
+
...runpodOptions
|
|
591
|
+
};
|
|
592
|
+
if (standardizedImages && standardizedImages.length > 0) {
|
|
593
|
+
if (standardizedImages.length === 1) {
|
|
594
|
+
zImageTurboPayload.image = standardizedImages[0];
|
|
595
|
+
} else {
|
|
596
|
+
zImageTurboPayload.images = standardizedImages;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return zImageTurboPayload;
|
|
600
|
+
}
|
|
513
601
|
const isWanModel = this.modelId.includes("wan-2");
|
|
514
602
|
if (isWanModel) {
|
|
515
603
|
return {
|
|
@@ -928,6 +1016,215 @@ var RunpodTranscriptionModel = class {
|
|
|
928
1016
|
}
|
|
929
1017
|
};
|
|
930
1018
|
|
|
1019
|
+
// src/runpod-video-model.ts
|
|
1020
|
+
import {
|
|
1021
|
+
withoutTrailingSlash as withoutTrailingSlash3,
|
|
1022
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1023
|
+
getFromApi as getFromApi3,
|
|
1024
|
+
postJsonToApi as postJsonToApi3
|
|
1025
|
+
} from "@ai-sdk/provider-utils";
|
|
1026
|
+
import { z as z4 } from "zod";
|
|
1027
|
+
function isRecord3(value) {
|
|
1028
|
+
return typeof value === "object" && value !== null;
|
|
1029
|
+
}
|
|
1030
|
+
var runpodVideoJobResponseSchema = z4.object({
|
|
1031
|
+
id: z4.string(),
|
|
1032
|
+
status: z4.string().optional()
|
|
1033
|
+
});
|
|
1034
|
+
var runpodVideoStatusSchema = z4.object({
|
|
1035
|
+
id: z4.string().optional(),
|
|
1036
|
+
status: z4.string(),
|
|
1037
|
+
output: z4.unknown().optional(),
|
|
1038
|
+
error: z4.string().optional()
|
|
1039
|
+
});
|
|
1040
|
+
var RunpodVideoModel = class {
|
|
1041
|
+
constructor(modelId, config) {
|
|
1042
|
+
this.modelId = modelId;
|
|
1043
|
+
this.config = config;
|
|
1044
|
+
this.specificationVersion = "v3";
|
|
1045
|
+
this.maxVideosPerCall = 1;
|
|
1046
|
+
}
|
|
1047
|
+
get provider() {
|
|
1048
|
+
return this.config.provider;
|
|
1049
|
+
}
|
|
1050
|
+
getRunpodRunUrl() {
|
|
1051
|
+
const baseURL = withoutTrailingSlash3(this.config.baseURL) ?? this.config.baseURL;
|
|
1052
|
+
if (baseURL.endsWith("/run") || baseURL.endsWith("/runsync")) {
|
|
1053
|
+
return baseURL;
|
|
1054
|
+
}
|
|
1055
|
+
return `${baseURL}/run`;
|
|
1056
|
+
}
|
|
1057
|
+
async doGenerate(options) {
|
|
1058
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
1059
|
+
const warnings = [];
|
|
1060
|
+
if (options.n > 1) {
|
|
1061
|
+
warnings.push({
|
|
1062
|
+
type: "unsupported",
|
|
1063
|
+
feature: "n > 1",
|
|
1064
|
+
details: "Runpod video models only support generating 1 video per call. Only 1 video will be generated."
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
const { providerOptions, abortSignal, headers } = options;
|
|
1068
|
+
const runpodOptions = this.extractRunpodOptions(providerOptions);
|
|
1069
|
+
const input = this.buildInputPayload(options, runpodOptions);
|
|
1070
|
+
const requestBody = { input };
|
|
1071
|
+
const url = this.getRunpodRunUrl();
|
|
1072
|
+
const effectiveBaseURL = withoutTrailingSlash3(this.config.baseURL) ?? this.config.baseURL;
|
|
1073
|
+
const { value: response, responseHeaders } = await postJsonToApi3({
|
|
1074
|
+
url,
|
|
1075
|
+
headers: {
|
|
1076
|
+
...this.config.headers(),
|
|
1077
|
+
...headers
|
|
1078
|
+
},
|
|
1079
|
+
body: requestBody,
|
|
1080
|
+
failedResponseHandler: runpodVideoFailedResponseHandler,
|
|
1081
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
1082
|
+
runpodVideoJobResponseSchema
|
|
1083
|
+
),
|
|
1084
|
+
abortSignal,
|
|
1085
|
+
fetch: this.config.fetch
|
|
1086
|
+
});
|
|
1087
|
+
const typedResponse = response;
|
|
1088
|
+
const jobId = typedResponse.id;
|
|
1089
|
+
if (!jobId) {
|
|
1090
|
+
throw new Error("Runpod video response did not include a job id.");
|
|
1091
|
+
}
|
|
1092
|
+
const pollOptions = {
|
|
1093
|
+
maxAttempts: runpodOptions.maxPollAttempts ?? 120,
|
|
1094
|
+
pollIntervalMillis: runpodOptions.pollIntervalMillis ?? 5e3
|
|
1095
|
+
};
|
|
1096
|
+
const result = await this.pollForCompletion(
|
|
1097
|
+
jobId,
|
|
1098
|
+
abortSignal,
|
|
1099
|
+
pollOptions,
|
|
1100
|
+
effectiveBaseURL
|
|
1101
|
+
);
|
|
1102
|
+
const videoUrl = this.extractVideoUrl(result.output);
|
|
1103
|
+
const providerMetadata = {
|
|
1104
|
+
runpod: {
|
|
1105
|
+
jobId
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
return {
|
|
1109
|
+
videos: [{ type: "url", url: videoUrl, mediaType: "video/mp4" }],
|
|
1110
|
+
warnings,
|
|
1111
|
+
response: {
|
|
1112
|
+
timestamp: currentDate,
|
|
1113
|
+
modelId: this.modelId,
|
|
1114
|
+
headers: responseHeaders
|
|
1115
|
+
},
|
|
1116
|
+
providerMetadata
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
buildInputPayload(options, runpodOptions) {
|
|
1120
|
+
const apiOptions = Object.fromEntries(
|
|
1121
|
+
Object.entries(runpodOptions).filter(
|
|
1122
|
+
([key]) => key !== "maxPollAttempts" && key !== "pollIntervalMillis"
|
|
1123
|
+
)
|
|
1124
|
+
);
|
|
1125
|
+
const input = {
|
|
1126
|
+
...apiOptions
|
|
1127
|
+
};
|
|
1128
|
+
if (options.prompt) {
|
|
1129
|
+
input.prompt = options.prompt;
|
|
1130
|
+
}
|
|
1131
|
+
if (options.duration !== void 0) {
|
|
1132
|
+
input.duration = options.duration;
|
|
1133
|
+
}
|
|
1134
|
+
if (options.fps !== void 0) {
|
|
1135
|
+
input.fps = options.fps;
|
|
1136
|
+
}
|
|
1137
|
+
if (options.seed !== void 0) {
|
|
1138
|
+
input.seed = options.seed;
|
|
1139
|
+
}
|
|
1140
|
+
if (options.resolution) {
|
|
1141
|
+
input.size = options.resolution.replace("x", "*");
|
|
1142
|
+
} else if (options.aspectRatio) {
|
|
1143
|
+
input.aspect_ratio = options.aspectRatio;
|
|
1144
|
+
}
|
|
1145
|
+
if (options.image) {
|
|
1146
|
+
input.image = this.convertFileToRunpodFormat(options.image);
|
|
1147
|
+
}
|
|
1148
|
+
return input;
|
|
1149
|
+
}
|
|
1150
|
+
convertFileToRunpodFormat(file) {
|
|
1151
|
+
if (file.type === "url") {
|
|
1152
|
+
return file.url;
|
|
1153
|
+
}
|
|
1154
|
+
const mediaType = file.mediaType;
|
|
1155
|
+
const data = file.data;
|
|
1156
|
+
if (typeof data === "string") {
|
|
1157
|
+
return `data:${mediaType};base64,${data}`;
|
|
1158
|
+
}
|
|
1159
|
+
const base64 = this.uint8ArrayToBase64(data);
|
|
1160
|
+
return `data:${mediaType};base64,${base64}`;
|
|
1161
|
+
}
|
|
1162
|
+
uint8ArrayToBase64(data) {
|
|
1163
|
+
if (typeof Buffer !== "undefined") {
|
|
1164
|
+
return Buffer.from(data).toString("base64");
|
|
1165
|
+
}
|
|
1166
|
+
let binary = "";
|
|
1167
|
+
for (let i = 0; i < data.length; i++) {
|
|
1168
|
+
binary += String.fromCharCode(data[i]);
|
|
1169
|
+
}
|
|
1170
|
+
return btoa(binary);
|
|
1171
|
+
}
|
|
1172
|
+
extractRunpodOptions(providerOptions) {
|
|
1173
|
+
if (!providerOptions) return {};
|
|
1174
|
+
const runpod2 = providerOptions.runpod;
|
|
1175
|
+
if (isRecord3(runpod2)) {
|
|
1176
|
+
return runpod2;
|
|
1177
|
+
}
|
|
1178
|
+
return {};
|
|
1179
|
+
}
|
|
1180
|
+
extractVideoUrl(output) {
|
|
1181
|
+
if (isRecord3(output)) {
|
|
1182
|
+
if (typeof output.video_url === "string") return output.video_url;
|
|
1183
|
+
if (typeof output.result === "string") return output.result;
|
|
1184
|
+
if (typeof output.url === "string") return output.url;
|
|
1185
|
+
}
|
|
1186
|
+
if (typeof output === "string") {
|
|
1187
|
+
return output;
|
|
1188
|
+
}
|
|
1189
|
+
throw new Error(
|
|
1190
|
+
`Runpod video generation completed but no video URL was found in the output: ${JSON.stringify(output)}`
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
async pollForCompletion(jobId, abortSignal, pollOptions, effectiveBaseURL) {
|
|
1194
|
+
const maxAttempts = pollOptions?.maxAttempts ?? 120;
|
|
1195
|
+
const pollInterval = pollOptions?.pollIntervalMillis ?? 5e3;
|
|
1196
|
+
const baseURL = effectiveBaseURL ?? this.config.baseURL;
|
|
1197
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1198
|
+
if (abortSignal?.aborted) {
|
|
1199
|
+
throw new Error("Video generation was aborted");
|
|
1200
|
+
}
|
|
1201
|
+
const { value: statusResponse } = await getFromApi3({
|
|
1202
|
+
url: `${baseURL}/status/${jobId}`,
|
|
1203
|
+
headers: this.config.headers(),
|
|
1204
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
1205
|
+
runpodVideoStatusSchema
|
|
1206
|
+
),
|
|
1207
|
+
failedResponseHandler: runpodVideoFailedResponseHandler,
|
|
1208
|
+
abortSignal,
|
|
1209
|
+
fetch: this.config.fetch
|
|
1210
|
+
});
|
|
1211
|
+
const typedStatusResponse = statusResponse;
|
|
1212
|
+
if (typedStatusResponse.status === "COMPLETED") {
|
|
1213
|
+
return typedStatusResponse;
|
|
1214
|
+
}
|
|
1215
|
+
if (typedStatusResponse.status === "FAILED") {
|
|
1216
|
+
throw new Error(
|
|
1217
|
+
`Video generation failed: ${typedStatusResponse.error || "Unknown error"}`
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
1221
|
+
}
|
|
1222
|
+
throw new Error(
|
|
1223
|
+
`Video generation timed out after ${maxAttempts} attempts (${maxAttempts * pollInterval / 1e3}s)`
|
|
1224
|
+
);
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
|
|
931
1228
|
// src/runpod-provider.ts
|
|
932
1229
|
var MODEL_ID_TO_ENDPOINT_URL = {
|
|
933
1230
|
"qwen/qwen3-32b-awq": "https://api.runpod.ai/v2/qwen3-32b-awq/openai/v1",
|
|
@@ -951,10 +1248,16 @@ var IMAGE_MODEL_ID_TO_ENDPOINT_URL = {
|
|
|
951
1248
|
"black-forest-labs/flux-1-dev": "https://api.runpod.ai/v2/black-forest-labs-flux-1-dev",
|
|
952
1249
|
// Alibaba Wan 2.6 (t2i)
|
|
953
1250
|
"alibaba/wan-2.6": "https://api.runpod.ai/v2/wan-2-6-t2i",
|
|
1251
|
+
// Tongyi Z-Image Turbo (t2i)
|
|
1252
|
+
"tongyi-mai/z-image-turbo": "https://api.runpod.ai/v2/z-image-turbo",
|
|
1253
|
+
"z-image-turbo": "https://api.runpod.ai/v2/z-image-turbo",
|
|
1254
|
+
// alias, not advertised
|
|
954
1255
|
// Nano Banana (edit only)
|
|
955
1256
|
"google/nano-banana-edit": "https://api.runpod.ai/v2/nano-banana-edit",
|
|
956
1257
|
"nano-banana-edit": "https://api.runpod.ai/v2/nano-banana-edit",
|
|
957
1258
|
// backwards compatibility
|
|
1259
|
+
// Nano Banana 2 (edit only)
|
|
1260
|
+
"google/nano-banana-2-edit": "https://api.runpod.ai/v2/google-nano-banana-2-edit",
|
|
958
1261
|
// Nano Banana Pro (edit only)
|
|
959
1262
|
"google/nano-banana-pro-edit": "https://api.runpod.ai/v2/nano-banana-pro-edit",
|
|
960
1263
|
// Pruna (t2i and edit)
|
|
@@ -967,6 +1270,23 @@ var SPEECH_MODEL_ID_TO_ENDPOINT_URL = {
|
|
|
967
1270
|
var TRANSCRIPTION_MODEL_ID_TO_ENDPOINT_URL = {
|
|
968
1271
|
"pruna/whisper-v3-large": "https://api.runpod.ai/v2/whisper-v3-large"
|
|
969
1272
|
};
|
|
1273
|
+
var VIDEO_MODEL_ID_TO_ENDPOINT_URL = {
|
|
1274
|
+
"pruna/p-video": "https://api.runpod.ai/v2/p-video",
|
|
1275
|
+
"vidu/q3-t2v": "https://api.runpod.ai/v2/vidu-q3-t2v",
|
|
1276
|
+
"vidu/q3-i2v": "https://api.runpod.ai/v2/vidu-q3-i2v",
|
|
1277
|
+
"kwaivgi/kling-v2.6-std-motion-control": "https://api.runpod.ai/v2/kling-v2-6-std-motion-control",
|
|
1278
|
+
"kwaivgi/kling-video-o1-r2v": "https://api.runpod.ai/v2/kling-video-o1-r2v",
|
|
1279
|
+
"kwaivgi/kling-v2.1-i2v-pro": "https://api.runpod.ai/v2/kling-v2-1-i2v-pro",
|
|
1280
|
+
"alibaba/wan-2.6-t2v": "https://api.runpod.ai/v2/wan-2-6-t2v",
|
|
1281
|
+
"alibaba/wan-2.6-i2v": "https://api.runpod.ai/v2/wan-2-6-i2v",
|
|
1282
|
+
"alibaba/wan-2.5": "https://api.runpod.ai/v2/wan-2-5",
|
|
1283
|
+
"alibaba/wan-2.2-t2v-720-lora": "https://api.runpod.ai/v2/wan-2-2-t2v-720-lora",
|
|
1284
|
+
"alibaba/wan-2.2-i2v-720": "https://api.runpod.ai/v2/wan-2-2-i2v-720",
|
|
1285
|
+
"alibaba/wan-2.1-i2v-720": "https://api.runpod.ai/v2/wan-2-1-i2v-720",
|
|
1286
|
+
"bytedance/seedance-v1.5-pro-i2v": "https://api.runpod.ai/v2/seedance-v1-5-pro-i2v",
|
|
1287
|
+
"openai/sora-2-pro-i2v": "https://api.runpod.ai/v2/sora-2-pro-i2v",
|
|
1288
|
+
"openai/sora-2-i2v": "https://api.runpod.ai/v2/sora-2-i2v"
|
|
1289
|
+
};
|
|
970
1290
|
var MODEL_ID_TO_OPENAI_NAME = {
|
|
971
1291
|
"qwen/qwen3-32b-awq": "Qwen/Qwen3-32B-AWQ",
|
|
972
1292
|
"deepcogito/cogito-671b-v2.1-fp8": "deepcogito/cogito-671b-v2.1-FP8",
|
|
@@ -1025,7 +1345,7 @@ function createRunpod(options = {}) {
|
|
|
1025
1345
|
}
|
|
1026
1346
|
return {
|
|
1027
1347
|
provider: `runpod.${modelType}`,
|
|
1028
|
-
url: ({ path }) => `${
|
|
1348
|
+
url: ({ path }) => `${withoutTrailingSlash4(baseURL)}${path}`,
|
|
1029
1349
|
headers: getHeaders,
|
|
1030
1350
|
fetch: runpodFetch
|
|
1031
1351
|
};
|
|
@@ -1045,13 +1365,11 @@ function createRunpod(options = {}) {
|
|
|
1045
1365
|
});
|
|
1046
1366
|
};
|
|
1047
1367
|
const createImageModel = (modelId) => {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
return new RunpodImageModel(modelId, {
|
|
1368
|
+
const endpointIdFromConsole = parseRunpodConsoleEndpointId(modelId);
|
|
1369
|
+
const normalizedModelId = endpointIdFromConsole ?? modelId;
|
|
1370
|
+
const mappedBaseURL = IMAGE_MODEL_ID_TO_ENDPOINT_URL[normalizedModelId];
|
|
1371
|
+
const baseURL = options.baseURL ?? mappedBaseURL ?? (normalizedModelId.startsWith("http") ? normalizedModelId : `https://api.runpod.ai/v2/${normalizedModelId}`);
|
|
1372
|
+
return new RunpodImageModel(normalizedModelId, {
|
|
1055
1373
|
provider: "runpod.image",
|
|
1056
1374
|
baseURL,
|
|
1057
1375
|
headers: getHeaders,
|
|
@@ -1082,6 +1400,18 @@ function createRunpod(options = {}) {
|
|
|
1082
1400
|
fetch: runpodFetch
|
|
1083
1401
|
});
|
|
1084
1402
|
};
|
|
1403
|
+
const createVideoModel = (modelId) => {
|
|
1404
|
+
const endpointIdFromConsole = parseRunpodConsoleEndpointId(modelId);
|
|
1405
|
+
const normalizedModelId = endpointIdFromConsole ?? modelId;
|
|
1406
|
+
const mappedBaseURL = VIDEO_MODEL_ID_TO_ENDPOINT_URL[normalizedModelId];
|
|
1407
|
+
const baseURL = mappedBaseURL ?? (normalizedModelId.startsWith("http") ? normalizedModelId : `https://api.runpod.ai/v2/${normalizedModelId}`);
|
|
1408
|
+
return new RunpodVideoModel(normalizedModelId, {
|
|
1409
|
+
provider: "runpod.video",
|
|
1410
|
+
baseURL,
|
|
1411
|
+
headers: getHeaders,
|
|
1412
|
+
fetch: options.fetch
|
|
1413
|
+
});
|
|
1414
|
+
};
|
|
1085
1415
|
const provider = (modelId) => createChatModel(modelId);
|
|
1086
1416
|
provider.completionModel = createCompletionModel;
|
|
1087
1417
|
provider.languageModel = createChatModel;
|
|
@@ -1092,6 +1422,8 @@ function createRunpod(options = {}) {
|
|
|
1092
1422
|
provider.speech = createSpeechModel;
|
|
1093
1423
|
provider.transcriptionModel = createTranscriptionModel;
|
|
1094
1424
|
provider.transcription = createTranscriptionModel;
|
|
1425
|
+
provider.videoModel = createVideoModel;
|
|
1426
|
+
provider.video = createVideoModel;
|
|
1095
1427
|
return provider;
|
|
1096
1428
|
}
|
|
1097
1429
|
var runpod = createRunpod();
|