@ai-sdk/replicate 3.0.0-beta.3 → 3.0.0-beta.30
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 +230 -8
- package/README.md +2 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +120 -111
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/replicate-image-model.ts +18 -1
- package/dist/index.d.mts +0 -117
- package/dist/index.mjs +0 -519
- package/dist/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/replicate",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.30",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
"./package.json": "./package.json",
|
|
25
25
|
".": {
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
|
-
"import": "./dist/index.
|
|
28
|
-
"
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/provider": "4.0.0-beta.
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.0-beta.
|
|
32
|
+
"@ai-sdk/provider": "4.0.0-beta.13",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.28"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "20.17.24",
|
|
37
37
|
"tsup": "^8",
|
|
38
38
|
"typescript": "5.8.3",
|
|
39
39
|
"zod": "3.25.76",
|
|
40
|
-
"@ai-sdk/test-server": "2.0.0-beta.
|
|
40
|
+
"@ai-sdk/test-server": "2.0.0-beta.2",
|
|
41
41
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -47,12 +47,14 @@
|
|
|
47
47
|
"node": ">=18"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
|
-
"access": "public"
|
|
50
|
+
"access": "public",
|
|
51
|
+
"provenance": true
|
|
51
52
|
},
|
|
52
53
|
"homepage": "https://ai-sdk.dev/docs",
|
|
53
54
|
"repository": {
|
|
54
55
|
"type": "git",
|
|
55
|
-
"url": "
|
|
56
|
+
"url": "https://github.com/vercel/ai",
|
|
57
|
+
"directory": "packages/replicate"
|
|
56
58
|
},
|
|
57
59
|
"bugs": {
|
|
58
60
|
"url": "https://github.com/vercel/ai/issues"
|
|
@@ -64,9 +66,7 @@
|
|
|
64
66
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
65
67
|
"build:watch": "pnpm clean && tsup --watch",
|
|
66
68
|
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
67
|
-
"lint": "eslint \"./**/*.ts*\"",
|
|
68
69
|
"type-check": "tsc --build",
|
|
69
|
-
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
70
70
|
"test": "pnpm test:node && pnpm test:edge",
|
|
71
71
|
"test:update": "pnpm test:node -u",
|
|
72
72
|
"test:watch": "vitest --config vitest.node.config.js",
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
parseProviderOptions,
|
|
13
13
|
postJsonToApi,
|
|
14
14
|
resolve,
|
|
15
|
+
serializeModelOptions,
|
|
16
|
+
WORKFLOW_SERIALIZE,
|
|
17
|
+
WORKFLOW_DESERIALIZE,
|
|
15
18
|
zodSchema,
|
|
16
19
|
} from '@ai-sdk/provider-utils';
|
|
17
20
|
import { z } from 'zod/v4';
|
|
@@ -48,6 +51,20 @@ export class ReplicateImageModel implements ImageModelV4 {
|
|
|
48
51
|
return FLUX_2_MODEL_PATTERN.test(this.modelId);
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
static [WORKFLOW_SERIALIZE](model: ReplicateImageModel) {
|
|
55
|
+
return serializeModelOptions({
|
|
56
|
+
modelId: model.modelId,
|
|
57
|
+
config: model.config,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
62
|
+
modelId: ReplicateImageModelId;
|
|
63
|
+
config: ReplicateImageModelConfig;
|
|
64
|
+
}) {
|
|
65
|
+
return new ReplicateImageModel(options.modelId, options.config);
|
|
66
|
+
}
|
|
67
|
+
|
|
51
68
|
constructor(
|
|
52
69
|
readonly modelId: ReplicateImageModelId,
|
|
53
70
|
private readonly config: ReplicateImageModelConfig,
|
|
@@ -148,7 +165,7 @@ export class ReplicateImageModel implements ImageModelV4 {
|
|
|
148
165
|
: `${this.config.baseURL}/models/${modelId}/predictions`,
|
|
149
166
|
|
|
150
167
|
headers: combineHeaders(
|
|
151
|
-
await resolve(this.config.headers),
|
|
168
|
+
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
152
169
|
headers,
|
|
153
170
|
preferHeader,
|
|
154
171
|
),
|
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 };
|