@ai-sdk/replicate 3.0.0-beta.20 → 3.0.0-beta.21

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/dist/index.d.mts DELETED
@@ -1,117 +0,0 @@
1
- import { ImageModelV4, ProviderV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
2
- import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
- import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
4
-
5
- type ReplicateImageModelId = 'black-forest-labs/flux-1.1-pro' | 'black-forest-labs/flux-1.1-pro-ultra' | 'black-forest-labs/flux-dev' | 'black-forest-labs/flux-pro' | 'black-forest-labs/flux-schnell' | 'bytedance/sdxl-lightning-4step' | 'fofr/aura-flow' | 'fofr/latent-consistency-model' | 'fofr/realvisxl-v3-multi-controlnet-lora' | 'fofr/sdxl-emoji' | 'fofr/sdxl-multi-controlnet-lora' | 'ideogram-ai/ideogram-v2' | 'ideogram-ai/ideogram-v2-turbo' | 'lucataco/dreamshaper-xl-turbo' | 'lucataco/open-dalle-v1.1' | 'lucataco/realvisxl-v2.0' | 'lucataco/realvisxl2-lcm' | 'luma/photon' | 'luma/photon-flash' | 'nvidia/sana' | 'playgroundai/playground-v2.5-1024px-aesthetic' | 'recraft-ai/recraft-v3' | 'recraft-ai/recraft-v3-svg' | 'stability-ai/stable-diffusion-3.5-large' | 'stability-ai/stable-diffusion-3.5-large-turbo' | 'stability-ai/stable-diffusion-3.5-medium' | 'tstramer/material-diffusion' | 'black-forest-labs/flux-fill-pro' | 'black-forest-labs/flux-fill-dev' | 'black-forest-labs/flux-2-pro' | 'black-forest-labs/flux-2-dev' | (string & {});
6
-
7
- interface ReplicateImageModelConfig {
8
- provider: string;
9
- baseURL: string;
10
- headers?: Resolvable<Record<string, string | undefined>>;
11
- fetch?: FetchFunction;
12
- _internal?: {
13
- currentDate?: () => Date;
14
- };
15
- }
16
- declare class ReplicateImageModel implements ImageModelV4 {
17
- readonly modelId: ReplicateImageModelId;
18
- private readonly config;
19
- readonly specificationVersion = "v4";
20
- get maxImagesPerCall(): number;
21
- get provider(): string;
22
- private get isFlux2Model();
23
- constructor(modelId: ReplicateImageModelId, config: ReplicateImageModelConfig);
24
- doGenerate({ prompt, n, aspectRatio, size, seed, providerOptions, headers, abortSignal, files, mask, }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
25
- }
26
- /**
27
- * Provider options schema for Replicate image generation.
28
- *
29
- * Note: Different Replicate models support different parameters.
30
- * This schema includes common parameters, but you can pass any
31
- * model-specific parameters through the passthrough.
32
- */
33
- declare const replicateImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
34
- [x: string]: unknown;
35
- maxWaitTimeInSeconds?: number | null | undefined;
36
- guidance_scale?: number | null | undefined;
37
- num_inference_steps?: number | null | undefined;
38
- negative_prompt?: string | null | undefined;
39
- output_format?: "png" | "jpg" | "webp" | null | undefined;
40
- output_quality?: number | null | undefined;
41
- strength?: number | null | undefined;
42
- }>;
43
- type ReplicateImageModelOptions = InferSchema<typeof replicateImageModelOptionsSchema>;
44
-
45
- type ReplicateVideoModelId = 'minimax/video-01' | 'minimax/video-01:6c1e4171-288a-4ca2-a738-894f0e87699d' | 'stability-ai/stable-video-diffusion:3f0457e4619daac51203dedb472816fd4af51f3149fa7a9e0b5ffcf1b8172438' | (string & {});
46
-
47
- interface ReplicateProviderSettings {
48
- /**
49
- * API token that is being send using the `Authorization` header.
50
- * It defaults to the `REPLICATE_API_TOKEN` environment variable.
51
- */
52
- apiToken?: string;
53
- /**
54
- * Use a different URL prefix for API calls, e.g. to use proxy servers.
55
- * The default prefix is `https://api.replicate.com/v1`.
56
- */
57
- baseURL?: string;
58
- /**
59
- * Custom headers to include in the requests.
60
- */
61
- headers?: Record<string, string>;
62
- /**
63
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
64
- * or to provide a custom fetch implementation for e.g. testing.
65
- */
66
- fetch?: FetchFunction;
67
- }
68
- interface ReplicateProvider extends ProviderV4 {
69
- /**
70
- * Creates a Replicate image generation model.
71
- */
72
- image(modelId: ReplicateImageModelId): ReplicateImageModel;
73
- /**
74
- * Creates a Replicate image generation model.
75
- */
76
- imageModel(modelId: ReplicateImageModelId): ReplicateImageModel;
77
- /**
78
- * @deprecated Use `embeddingModel` instead.
79
- */
80
- textEmbeddingModel(modelId: string): never;
81
- /**
82
- * Creates a Replicate video generation model.
83
- */
84
- video(modelId: ReplicateVideoModelId): Experimental_VideoModelV4;
85
- /**
86
- * Creates a Replicate video generation model.
87
- */
88
- videoModel(modelId: ReplicateVideoModelId): Experimental_VideoModelV4;
89
- }
90
- /**
91
- * Create a Replicate provider instance.
92
- */
93
- declare function createReplicate(options?: ReplicateProviderSettings): ReplicateProvider;
94
- /**
95
- * Default Replicate provider instance.
96
- */
97
- declare const replicate: ReplicateProvider;
98
-
99
- type ReplicateVideoModelOptions = {
100
- pollIntervalMs?: number | null;
101
- pollTimeoutMs?: number | null;
102
- maxWaitTimeInSeconds?: number | null;
103
- guidance_scale?: number | null;
104
- num_inference_steps?: number | null;
105
- motion_bucket_id?: number | null;
106
- cond_aug?: number | null;
107
- decoding_t?: number | null;
108
- video_length?: string | null;
109
- sizing_strategy?: string | null;
110
- frames_per_second?: number | null;
111
- prompt_optimizer?: boolean | null;
112
- [key: string]: unknown;
113
- };
114
-
115
- declare const VERSION: string;
116
-
117
- export { type ReplicateImageModelOptions, type ReplicateImageModelOptions as ReplicateImageProviderOptions, type ReplicateProvider, type ReplicateProviderSettings, type ReplicateVideoModelId, type ReplicateVideoModelOptions, type ReplicateVideoModelOptions as ReplicateVideoProviderOptions, VERSION, createReplicate, replicate };
package/dist/index.mjs DELETED
@@ -1,519 +0,0 @@
1
- // src/replicate-provider.ts
2
- import {
3
- NoSuchModelError
4
- } from "@ai-sdk/provider";
5
- import { loadApiKey, withUserAgentSuffix } from "@ai-sdk/provider-utils";
6
-
7
- // src/replicate-image-model.ts
8
- import {
9
- combineHeaders,
10
- convertImageModelFileToDataUri,
11
- createBinaryResponseHandler,
12
- createJsonResponseHandler,
13
- getFromApi,
14
- lazySchema,
15
- parseProviderOptions,
16
- postJsonToApi,
17
- resolve,
18
- zodSchema
19
- } from "@ai-sdk/provider-utils";
20
- import { z as z2 } from "zod/v4";
21
-
22
- // src/replicate-error.ts
23
- import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
24
- import { z } from "zod/v4";
25
- var replicateErrorSchema = z.object({
26
- detail: z.string().optional(),
27
- error: z.string().optional()
28
- });
29
- var replicateFailedResponseHandler = createJsonErrorResponseHandler({
30
- errorSchema: replicateErrorSchema,
31
- errorToMessage: (error) => {
32
- var _a, _b;
33
- return (_b = (_a = error.detail) != null ? _a : error.error) != null ? _b : "Unknown Replicate error";
34
- }
35
- });
36
-
37
- // src/replicate-image-model.ts
38
- var FLUX_2_MODEL_PATTERN = /^black-forest-labs\/flux-2-/;
39
- var MAX_FLUX_2_INPUT_IMAGES = 8;
40
- var ReplicateImageModel = class {
41
- constructor(modelId, config) {
42
- this.modelId = modelId;
43
- this.config = config;
44
- this.specificationVersion = "v4";
45
- }
46
- get maxImagesPerCall() {
47
- return this.isFlux2Model ? MAX_FLUX_2_INPUT_IMAGES : 1;
48
- }
49
- get provider() {
50
- return this.config.provider;
51
- }
52
- get isFlux2Model() {
53
- return FLUX_2_MODEL_PATTERN.test(this.modelId);
54
- }
55
- async doGenerate({
56
- prompt,
57
- n,
58
- aspectRatio,
59
- size,
60
- seed,
61
- providerOptions,
62
- headers,
63
- abortSignal,
64
- files,
65
- mask
66
- }) {
67
- var _a, _b, _c;
68
- const warnings = [];
69
- const [modelId, version] = this.modelId.split(":");
70
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
71
- const replicateOptions = await parseProviderOptions({
72
- provider: "replicate",
73
- providerOptions,
74
- schema: replicateImageModelOptionsSchema
75
- });
76
- let imageInputs = {};
77
- if (files != null && files.length > 0) {
78
- if (this.isFlux2Model) {
79
- for (let i = 0; i < Math.min(files.length, MAX_FLUX_2_INPUT_IMAGES); i++) {
80
- const key = i === 0 ? "input_image" : `input_image_${i + 1}`;
81
- imageInputs[key] = convertImageModelFileToDataUri(files[i]);
82
- }
83
- if (files.length > MAX_FLUX_2_INPUT_IMAGES) {
84
- warnings.push({
85
- type: "other",
86
- message: `Flux-2 models support up to ${MAX_FLUX_2_INPUT_IMAGES} input images. Additional images are ignored.`
87
- });
88
- }
89
- } else {
90
- imageInputs = { image: convertImageModelFileToDataUri(files[0]) };
91
- if (files.length > 1) {
92
- warnings.push({
93
- type: "other",
94
- message: "This Replicate model only supports a single input image. Additional images are ignored."
95
- });
96
- }
97
- }
98
- }
99
- let maskInput;
100
- if (mask != null) {
101
- if (this.isFlux2Model) {
102
- warnings.push({
103
- type: "other",
104
- message: "Flux-2 models do not support mask input. The mask will be ignored."
105
- });
106
- } else {
107
- maskInput = convertImageModelFileToDataUri(mask);
108
- }
109
- }
110
- const { maxWaitTimeInSeconds, ...inputOptions } = replicateOptions != null ? replicateOptions : {};
111
- const preferHeader = maxWaitTimeInSeconds != null ? { prefer: `wait=${maxWaitTimeInSeconds}` } : { prefer: "wait" };
112
- const {
113
- value: { output },
114
- responseHeaders
115
- } = await postJsonToApi({
116
- url: (
117
- // different endpoints for versioned vs unversioned models:
118
- version != null ? `${this.config.baseURL}/predictions` : `${this.config.baseURL}/models/${modelId}/predictions`
119
- ),
120
- headers: combineHeaders(
121
- await resolve(this.config.headers),
122
- headers,
123
- preferHeader
124
- ),
125
- body: {
126
- input: {
127
- prompt,
128
- aspect_ratio: aspectRatio,
129
- size,
130
- seed,
131
- num_outputs: n,
132
- ...imageInputs,
133
- ...maskInput != null ? { mask: maskInput } : {},
134
- ...inputOptions
135
- },
136
- // for versioned models, include the version in the body:
137
- ...version != null ? { version } : {}
138
- },
139
- successfulResponseHandler: createJsonResponseHandler(
140
- replicateImageResponseSchema
141
- ),
142
- failedResponseHandler: replicateFailedResponseHandler,
143
- abortSignal,
144
- fetch: this.config.fetch
145
- });
146
- const outputArray = Array.isArray(output) ? output : [output];
147
- const images = await Promise.all(
148
- outputArray.map(async (url) => {
149
- const { value: image } = await getFromApi({
150
- url,
151
- successfulResponseHandler: createBinaryResponseHandler(),
152
- failedResponseHandler: replicateFailedResponseHandler,
153
- abortSignal,
154
- fetch: this.config.fetch
155
- });
156
- return image;
157
- })
158
- );
159
- return {
160
- images,
161
- warnings,
162
- response: {
163
- timestamp: currentDate,
164
- modelId: this.modelId,
165
- headers: responseHeaders
166
- }
167
- };
168
- }
169
- };
170
- var replicateImageResponseSchema = z2.object({
171
- output: z2.union([z2.array(z2.string()), z2.string()])
172
- });
173
- var replicateImageModelOptionsSchema = lazySchema(
174
- () => zodSchema(
175
- z2.object({
176
- /**
177
- * Maximum time in seconds to wait for the prediction to complete in sync mode.
178
- * By default, Replicate uses sync mode with a 60-second timeout.
179
- *
180
- * - When not specified: Uses default 60-second sync wait (`prefer: wait`)
181
- * - When set to a positive number: Uses that duration (`prefer: wait=N`)
182
- */
183
- maxWaitTimeInSeconds: z2.number().positive().nullish(),
184
- /**
185
- * Guidance scale for classifier-free guidance.
186
- * Higher values make the output more closely match the prompt.
187
- */
188
- guidance_scale: z2.number().nullish(),
189
- /**
190
- * Number of denoising steps. More steps = higher quality but slower.
191
- */
192
- num_inference_steps: z2.number().nullish(),
193
- /**
194
- * Negative prompt to guide what to avoid in the generation.
195
- */
196
- negative_prompt: z2.string().nullish(),
197
- /**
198
- * Output image format.
199
- */
200
- output_format: z2.enum(["png", "jpg", "webp"]).nullish(),
201
- /**
202
- * Output image quality (1-100). Only applies to jpg and webp.
203
- */
204
- output_quality: z2.number().min(1).max(100).nullish(),
205
- /**
206
- * Strength of the transformation for img2img (0-1).
207
- * Lower values keep more of the original image.
208
- */
209
- strength: z2.number().min(0).max(1).nullish()
210
- }).passthrough()
211
- )
212
- );
213
-
214
- // src/replicate-video-model.ts
215
- import {
216
- AISDKError
217
- } from "@ai-sdk/provider";
218
- import {
219
- combineHeaders as combineHeaders2,
220
- convertImageModelFileToDataUri as convertImageModelFileToDataUri2,
221
- createJsonResponseHandler as createJsonResponseHandler2,
222
- delay,
223
- getFromApi as getFromApi2,
224
- lazySchema as lazySchema2,
225
- parseProviderOptions as parseProviderOptions2,
226
- postJsonToApi as postJsonToApi2,
227
- resolve as resolve2,
228
- zodSchema as zodSchema2
229
- } from "@ai-sdk/provider-utils";
230
- import { z as z3 } from "zod/v4";
231
- var ReplicateVideoModel = class {
232
- constructor(modelId, config) {
233
- this.modelId = modelId;
234
- this.config = config;
235
- this.specificationVersion = "v4";
236
- this.maxVideosPerCall = 1;
237
- }
238
- // Replicate video models support 1 video at a time
239
- get provider() {
240
- return this.config.provider;
241
- }
242
- async doGenerate(options) {
243
- var _a, _b, _c, _d, _e, _f, _g;
244
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
245
- const warnings = [];
246
- const replicateOptions = await parseProviderOptions2({
247
- provider: "replicate",
248
- providerOptions: options.providerOptions,
249
- schema: replicateVideoModelOptionsSchema
250
- });
251
- const [modelId, version] = this.modelId.split(":");
252
- const input = {};
253
- if (options.prompt != null) {
254
- input.prompt = options.prompt;
255
- }
256
- if (options.image != null) {
257
- if (options.image.type === "url") {
258
- input.image = options.image.url;
259
- } else {
260
- input.image = convertImageModelFileToDataUri2(options.image);
261
- }
262
- }
263
- if (options.aspectRatio) {
264
- input.aspect_ratio = options.aspectRatio;
265
- }
266
- if (options.resolution) {
267
- input.size = options.resolution;
268
- }
269
- if (options.duration) {
270
- input.duration = options.duration;
271
- }
272
- if (options.fps) {
273
- input.fps = options.fps;
274
- }
275
- if (options.seed) {
276
- input.seed = options.seed;
277
- }
278
- if (replicateOptions != null) {
279
- const opts = replicateOptions;
280
- if (opts.guidance_scale !== void 0 && opts.guidance_scale !== null) {
281
- input.guidance_scale = opts.guidance_scale;
282
- }
283
- if (opts.num_inference_steps !== void 0 && opts.num_inference_steps !== null) {
284
- input.num_inference_steps = opts.num_inference_steps;
285
- }
286
- if (opts.motion_bucket_id !== void 0 && opts.motion_bucket_id !== null) {
287
- input.motion_bucket_id = opts.motion_bucket_id;
288
- }
289
- if (opts.cond_aug !== void 0 && opts.cond_aug !== null) {
290
- input.cond_aug = opts.cond_aug;
291
- }
292
- if (opts.decoding_t !== void 0 && opts.decoding_t !== null) {
293
- input.decoding_t = opts.decoding_t;
294
- }
295
- if (opts.video_length !== void 0 && opts.video_length !== null) {
296
- input.video_length = opts.video_length;
297
- }
298
- if (opts.sizing_strategy !== void 0 && opts.sizing_strategy !== null) {
299
- input.sizing_strategy = opts.sizing_strategy;
300
- }
301
- if (opts.frames_per_second !== void 0 && opts.frames_per_second !== null) {
302
- input.frames_per_second = opts.frames_per_second;
303
- }
304
- if (opts.prompt_optimizer !== void 0 && opts.prompt_optimizer !== null) {
305
- input.prompt_optimizer = opts.prompt_optimizer;
306
- }
307
- for (const [key, value] of Object.entries(opts)) {
308
- if (![
309
- "pollIntervalMs",
310
- "pollTimeoutMs",
311
- "maxWaitTimeInSeconds",
312
- "guidance_scale",
313
- "num_inference_steps",
314
- "motion_bucket_id",
315
- "cond_aug",
316
- "decoding_t",
317
- "video_length",
318
- "sizing_strategy",
319
- "frames_per_second",
320
- "prompt_optimizer"
321
- ].includes(key)) {
322
- input[key] = value;
323
- }
324
- }
325
- }
326
- const maxWaitTimeInSeconds = replicateOptions == null ? void 0 : replicateOptions.maxWaitTimeInSeconds;
327
- const preferHeader = maxWaitTimeInSeconds != null ? { prefer: `wait=${maxWaitTimeInSeconds}` } : { prefer: "wait" };
328
- const predictionUrl = version != null ? `${this.config.baseURL}/predictions` : `${this.config.baseURL}/models/${modelId}/predictions`;
329
- const { value: prediction, responseHeaders } = await postJsonToApi2({
330
- url: predictionUrl,
331
- headers: combineHeaders2(
332
- await resolve2(this.config.headers),
333
- options.headers,
334
- preferHeader
335
- ),
336
- body: {
337
- input,
338
- ...version != null ? { version } : {}
339
- },
340
- successfulResponseHandler: createJsonResponseHandler2(
341
- replicatePredictionSchema
342
- ),
343
- failedResponseHandler: replicateFailedResponseHandler,
344
- abortSignal: options.abortSignal,
345
- fetch: this.config.fetch
346
- });
347
- let finalPrediction = prediction;
348
- if (prediction.status === "starting" || prediction.status === "processing") {
349
- const pollIntervalMs = (_d = replicateOptions == null ? void 0 : replicateOptions.pollIntervalMs) != null ? _d : 2e3;
350
- const pollTimeoutMs = (_e = replicateOptions == null ? void 0 : replicateOptions.pollTimeoutMs) != null ? _e : 3e5;
351
- const startTime = Date.now();
352
- while (finalPrediction.status === "starting" || finalPrediction.status === "processing") {
353
- if (Date.now() - startTime > pollTimeoutMs) {
354
- throw new AISDKError({
355
- name: "REPLICATE_VIDEO_GENERATION_TIMEOUT",
356
- message: `Video generation timed out after ${pollTimeoutMs}ms`
357
- });
358
- }
359
- await delay(pollIntervalMs);
360
- if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
361
- throw new AISDKError({
362
- name: "REPLICATE_VIDEO_GENERATION_ABORTED",
363
- message: "Video generation request was aborted"
364
- });
365
- }
366
- const { value: statusPrediction } = await getFromApi2({
367
- url: finalPrediction.urls.get,
368
- headers: await resolve2(this.config.headers),
369
- successfulResponseHandler: createJsonResponseHandler2(
370
- replicatePredictionSchema
371
- ),
372
- failedResponseHandler: replicateFailedResponseHandler,
373
- abortSignal: options.abortSignal,
374
- fetch: this.config.fetch
375
- });
376
- finalPrediction = statusPrediction;
377
- }
378
- }
379
- if (finalPrediction.status === "failed") {
380
- throw new AISDKError({
381
- name: "REPLICATE_VIDEO_GENERATION_FAILED",
382
- message: `Video generation failed: ${(_g = finalPrediction.error) != null ? _g : "Unknown error"}`
383
- });
384
- }
385
- if (finalPrediction.status === "canceled") {
386
- throw new AISDKError({
387
- name: "REPLICATE_VIDEO_GENERATION_CANCELED",
388
- message: "Video generation was canceled"
389
- });
390
- }
391
- const videoUrl = finalPrediction.output;
392
- if (!videoUrl) {
393
- throw new AISDKError({
394
- name: "REPLICATE_VIDEO_GENERATION_ERROR",
395
- message: "No video URL in response"
396
- });
397
- }
398
- return {
399
- videos: [
400
- {
401
- type: "url",
402
- url: videoUrl,
403
- mediaType: "video/mp4"
404
- }
405
- ],
406
- warnings,
407
- response: {
408
- timestamp: currentDate,
409
- modelId: this.modelId,
410
- headers: responseHeaders
411
- },
412
- providerMetadata: {
413
- replicate: {
414
- videos: [
415
- {
416
- url: videoUrl
417
- }
418
- ],
419
- predictionId: finalPrediction.id,
420
- metrics: finalPrediction.metrics
421
- }
422
- }
423
- };
424
- }
425
- };
426
- var replicatePredictionSchema = z3.object({
427
- id: z3.string(),
428
- status: z3.enum(["starting", "processing", "succeeded", "failed", "canceled"]),
429
- output: z3.string().nullish(),
430
- error: z3.string().nullish(),
431
- urls: z3.object({
432
- get: z3.string()
433
- }),
434
- metrics: z3.object({
435
- predict_time: z3.number().nullish()
436
- }).nullish()
437
- });
438
- var replicateVideoModelOptionsSchema = lazySchema2(
439
- () => zodSchema2(
440
- z3.object({
441
- pollIntervalMs: z3.number().positive().nullish(),
442
- pollTimeoutMs: z3.number().positive().nullish(),
443
- maxWaitTimeInSeconds: z3.number().positive().nullish(),
444
- guidance_scale: z3.number().nullish(),
445
- num_inference_steps: z3.number().nullish(),
446
- motion_bucket_id: z3.number().nullish(),
447
- cond_aug: z3.number().nullish(),
448
- decoding_t: z3.number().nullish(),
449
- video_length: z3.string().nullish(),
450
- sizing_strategy: z3.string().nullish(),
451
- frames_per_second: z3.number().nullish(),
452
- prompt_optimizer: z3.boolean().nullish()
453
- }).loose()
454
- )
455
- );
456
-
457
- // src/version.ts
458
- var VERSION = true ? "3.0.0-beta.20" : "0.0.0-test";
459
-
460
- // src/replicate-provider.ts
461
- function createReplicate(options = {}) {
462
- const getHeaders = () => withUserAgentSuffix(
463
- {
464
- Authorization: `Bearer ${loadApiKey({
465
- apiKey: options.apiToken,
466
- environmentVariableName: "REPLICATE_API_TOKEN",
467
- description: "Replicate"
468
- })}`,
469
- ...options.headers
470
- },
471
- `ai-sdk/replicate/${VERSION}`
472
- );
473
- const createImageModel = (modelId) => {
474
- var _a;
475
- return new ReplicateImageModel(modelId, {
476
- provider: "replicate",
477
- baseURL: (_a = options.baseURL) != null ? _a : "https://api.replicate.com/v1",
478
- headers: getHeaders(),
479
- fetch: options.fetch
480
- });
481
- };
482
- const createVideoModel = (modelId) => {
483
- var _a;
484
- return new ReplicateVideoModel(modelId, {
485
- provider: "replicate.video",
486
- baseURL: (_a = options.baseURL) != null ? _a : "https://api.replicate.com/v1",
487
- headers: getHeaders,
488
- fetch: options.fetch
489
- });
490
- };
491
- const embeddingModel = (modelId) => {
492
- throw new NoSuchModelError({
493
- modelId,
494
- modelType: "embeddingModel"
495
- });
496
- };
497
- return {
498
- specificationVersion: "v4",
499
- image: createImageModel,
500
- imageModel: createImageModel,
501
- languageModel: (modelId) => {
502
- throw new NoSuchModelError({
503
- modelId,
504
- modelType: "languageModel"
505
- });
506
- },
507
- embeddingModel,
508
- textEmbeddingModel: embeddingModel,
509
- video: createVideoModel,
510
- videoModel: createVideoModel
511
- };
512
- }
513
- var replicate = createReplicate();
514
- export {
515
- VERSION,
516
- createReplicate,
517
- replicate
518
- };
519
- //# sourceMappingURL=index.mjs.map