@decartai/sdk 0.0.34 → 0.0.36
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.ts +19 -11
- package/dist/index.js +29 -15
- package/dist/process/request.js +5 -1
- package/dist/process/types.d.ts +12 -2
- package/dist/queue/request.js +15 -3
- package/dist/realtime/client.d.ts +1 -1
- package/dist/shared/model.d.ts +57 -13
- package/dist/shared/model.js +15 -1
- package/dist/shared/request.js +15 -5
- package/dist/tokens/client.js +5 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageModelDefinition, ImageModels, Model, ModelDefinition, RealTimeModels, VideoModelDefinition, VideoModels, isImageModel, isRealtimeModel, isVideoModel, models } from "./shared/model.js";
|
|
2
|
-
import { FileInput, ProcessOptions } from "./process/types.js";
|
|
2
|
+
import { FileInput, ProcessOptions, ReactNativeFile } from "./process/types.js";
|
|
3
3
|
import { ProcessClient } from "./process/client.js";
|
|
4
4
|
import { JobStatus, JobStatusResponse, JobSubmitResponse, QueueJobResult, QueueSubmitAndPollOptions, QueueSubmitOptions } from "./queue/types.js";
|
|
5
5
|
import { QueueClient } from "./queue/client.js";
|
|
@@ -7,30 +7,38 @@ import { DecartSDKError, ERROR_CODES } from "./utils/errors.js";
|
|
|
7
7
|
import { AvatarOptions, RealTimeClient, RealTimeClientConnectOptions, RealTimeClientInitialState } from "./realtime/client.js";
|
|
8
8
|
import { ModelState } from "./shared/types.js";
|
|
9
9
|
import { CreateTokenResponse, TokensClient } from "./tokens/client.js";
|
|
10
|
-
import { z } from "zod";
|
|
11
10
|
|
|
12
11
|
//#region src/index.d.ts
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
type DecartClientOptions = {
|
|
13
|
+
proxy: string;
|
|
14
|
+
apiKey?: never;
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
integration?: string;
|
|
17
|
+
} | {
|
|
18
|
+
proxy?: never;
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
integration?: string;
|
|
22
|
+
};
|
|
19
23
|
/**
|
|
20
24
|
* Create a Decart API client.
|
|
21
25
|
*
|
|
22
26
|
* @param options - Configuration options
|
|
23
|
-
* @param options.
|
|
27
|
+
* @param options.proxy - URL of the proxy server. When set, the client will use the proxy instead of direct API access and apiKey is not required.
|
|
28
|
+
* @param options.apiKey - API key for authentication.
|
|
24
29
|
* @param options.baseUrl - Override the default API base URL.
|
|
25
30
|
* @param options.integration - Optional integration identifier.
|
|
26
31
|
*
|
|
27
32
|
* @example
|
|
28
33
|
* ```ts
|
|
29
|
-
* // Option 1: Explicit API key
|
|
34
|
+
* // (direct API access)Option 1: Explicit API key
|
|
30
35
|
* const client = createDecartClient({ apiKey: "your-api-key" });
|
|
31
36
|
*
|
|
32
37
|
* // Option 2: Using DECART_API_KEY environment variable
|
|
33
38
|
* const client = createDecartClient();
|
|
39
|
+
*
|
|
40
|
+
* // Option 3: Using proxy (client-side, no API key needed)
|
|
41
|
+
* const client = createDecartClient({ proxy: "https://your-server.com/api/decart" });
|
|
34
42
|
* ```
|
|
35
43
|
*/
|
|
36
44
|
declare const createDecartClient: (options?: DecartClientOptions) => {
|
|
@@ -109,4 +117,4 @@ declare const createDecartClient: (options?: DecartClientOptions) => {
|
|
|
109
117
|
tokens: TokensClient;
|
|
110
118
|
};
|
|
111
119
|
//#endregion
|
|
112
|
-
export { type AvatarOptions, type CreateTokenResponse, DecartClientOptions, type DecartSDKError, ERROR_CODES, type FileInput, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type Model, type ModelDefinition, type ModelState, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type RealTimeModels, type TokensClient, type VideoModelDefinition, type VideoModels, createDecartClient, isImageModel, isRealtimeModel, isVideoModel, models };
|
|
120
|
+
export { type AvatarOptions, type CreateTokenResponse, DecartClientOptions, type DecartSDKError, ERROR_CODES, type FileInput, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type Model, type ModelDefinition, type ModelState, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type ReactNativeFile, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type RealTimeModels, type TokensClient, type VideoModelDefinition, type VideoModels, createDecartClient, isImageModel, isRealtimeModel, isVideoModel, models };
|
package/dist/index.js
CHANGED
|
@@ -8,59 +8,73 @@ import { readEnv } from "./utils/env.js";
|
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
|
|
10
10
|
//#region src/index.ts
|
|
11
|
+
const proxySchema = z.union([z.string().url(), z.string().startsWith("/")]);
|
|
11
12
|
const decartClientOptionsSchema = z.object({
|
|
12
13
|
apiKey: z.string().min(1).optional(),
|
|
13
14
|
baseUrl: z.url().optional(),
|
|
15
|
+
proxy: proxySchema.optional(),
|
|
14
16
|
integration: z.string().optional()
|
|
15
|
-
})
|
|
17
|
+
}).refine((data) => {
|
|
18
|
+
const hasProxy = !!data.proxy;
|
|
19
|
+
const hasApiKey = !!data.apiKey;
|
|
20
|
+
return !(hasProxy && hasApiKey);
|
|
21
|
+
}, { message: "Cannot provide both 'proxy' and 'apiKey'. Use 'proxy' for proxy mode or 'apiKey' for direct API access." });
|
|
16
22
|
/**
|
|
17
23
|
* Create a Decart API client.
|
|
18
24
|
*
|
|
19
25
|
* @param options - Configuration options
|
|
20
|
-
* @param options.
|
|
26
|
+
* @param options.proxy - URL of the proxy server. When set, the client will use the proxy instead of direct API access and apiKey is not required.
|
|
27
|
+
* @param options.apiKey - API key for authentication.
|
|
21
28
|
* @param options.baseUrl - Override the default API base URL.
|
|
22
29
|
* @param options.integration - Optional integration identifier.
|
|
23
30
|
*
|
|
24
31
|
* @example
|
|
25
32
|
* ```ts
|
|
26
|
-
* // Option 1: Explicit API key
|
|
33
|
+
* // (direct API access)Option 1: Explicit API key
|
|
27
34
|
* const client = createDecartClient({ apiKey: "your-api-key" });
|
|
28
35
|
*
|
|
29
36
|
* // Option 2: Using DECART_API_KEY environment variable
|
|
30
37
|
* const client = createDecartClient();
|
|
38
|
+
*
|
|
39
|
+
* // Option 3: Using proxy (client-side, no API key needed)
|
|
40
|
+
* const client = createDecartClient({ proxy: "https://your-server.com/api/decart" });
|
|
31
41
|
* ```
|
|
32
42
|
*/
|
|
33
43
|
const createDecartClient = (options = {}) => {
|
|
34
|
-
const
|
|
35
|
-
if (!apiKey) throw createInvalidApiKeyError();
|
|
36
|
-
const parsedOptions = decartClientOptionsSchema.safeParse({
|
|
37
|
-
...options,
|
|
38
|
-
apiKey
|
|
39
|
-
});
|
|
44
|
+
const parsedOptions = decartClientOptionsSchema.safeParse(options);
|
|
40
45
|
if (!parsedOptions.success) {
|
|
41
|
-
|
|
46
|
+
const issue = parsedOptions.error.issues[0];
|
|
47
|
+
if (issue.path.includes("apiKey")) throw createInvalidApiKeyError();
|
|
48
|
+
if (issue.path.includes("baseUrl")) throw createInvalidBaseUrlError(issue.path.includes("baseUrl") ? options.baseUrl : void 0);
|
|
49
|
+
if (issue.path.includes("proxy")) throw createInvalidBaseUrlError(issue.path.includes("proxy") ? options.proxy : void 0);
|
|
42
50
|
throw parsedOptions.error;
|
|
43
51
|
}
|
|
44
|
-
const
|
|
52
|
+
const isProxyMode = "proxy" in parsedOptions.data && !!parsedOptions.data.proxy;
|
|
53
|
+
const apiKey = isProxyMode ? void 0 : ("apiKey" in parsedOptions.data ? parsedOptions.data.apiKey : void 0) ?? readEnv("DECART_API_KEY");
|
|
54
|
+
if (!isProxyMode && !apiKey) throw createInvalidApiKeyError();
|
|
55
|
+
let baseUrl;
|
|
56
|
+
if (isProxyMode && "proxy" in parsedOptions.data && parsedOptions.data.proxy) baseUrl = parsedOptions.data.proxy;
|
|
57
|
+
else baseUrl = parsedOptions.data.baseUrl || "https://api.decart.ai";
|
|
58
|
+
const { integration } = parsedOptions.data;
|
|
45
59
|
return {
|
|
46
60
|
realtime: createRealTimeClient({
|
|
47
61
|
baseUrl: "wss://api3.decart.ai",
|
|
48
|
-
apiKey,
|
|
62
|
+
apiKey: apiKey || "",
|
|
49
63
|
integration
|
|
50
64
|
}),
|
|
51
65
|
process: createProcessClient({
|
|
52
66
|
baseUrl,
|
|
53
|
-
apiKey,
|
|
67
|
+
apiKey: apiKey || "",
|
|
54
68
|
integration
|
|
55
69
|
}),
|
|
56
70
|
queue: createQueueClient({
|
|
57
71
|
baseUrl,
|
|
58
|
-
apiKey,
|
|
72
|
+
apiKey: apiKey || "",
|
|
59
73
|
integration
|
|
60
74
|
}),
|
|
61
75
|
tokens: createTokensClient({
|
|
62
76
|
baseUrl,
|
|
63
|
-
apiKey,
|
|
77
|
+
apiKey: apiKey || "",
|
|
64
78
|
integration
|
|
65
79
|
})
|
|
66
80
|
};
|
package/dist/process/request.js
CHANGED
|
@@ -5,9 +5,13 @@ import { buildAuthHeaders, buildFormData } from "../shared/request.js";
|
|
|
5
5
|
async function sendRequest({ baseUrl, apiKey, model, inputs, signal, integration }) {
|
|
6
6
|
const formData = buildFormData(inputs);
|
|
7
7
|
const endpoint = `${baseUrl}${model.urlPath}`;
|
|
8
|
+
const headers = buildAuthHeaders({
|
|
9
|
+
apiKey,
|
|
10
|
+
integration
|
|
11
|
+
});
|
|
8
12
|
const response = await fetch(endpoint, {
|
|
9
13
|
method: "POST",
|
|
10
|
-
headers
|
|
14
|
+
headers,
|
|
11
15
|
body: formData,
|
|
12
16
|
signal
|
|
13
17
|
});
|
package/dist/process/types.d.ts
CHANGED
|
@@ -2,7 +2,17 @@ import { ImageModelDefinition, ImageModels, ModelDefinition, ModelInputSchemas,
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/process/types.d.ts
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* React Native file object format for file uploads.
|
|
8
|
+
* This format is used by React Native's FormData to properly handle file uploads with MIME types.
|
|
9
|
+
*/
|
|
10
|
+
interface ReactNativeFile {
|
|
11
|
+
uri: string;
|
|
12
|
+
type: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
type FileInput = File | Blob | ReadableStream | URL | string | ReactNativeFile;
|
|
6
16
|
type InferModelInputs<T extends ModelDefinition> = T["name"] extends keyof ModelInputSchemas ? z.input<ModelInputSchemas[T["name"]]> : Record<string, never>;
|
|
7
17
|
/**
|
|
8
18
|
* Model-specific input documentation for image generation models.
|
|
@@ -193,4 +203,4 @@ type ProcessOptions<T extends ImageModelDefinition = ImageModelDefinition> = {
|
|
|
193
203
|
signal?: AbortSignal;
|
|
194
204
|
} & MergeDocumentedInputs<T>;
|
|
195
205
|
//#endregion
|
|
196
|
-
export { FileInput, InferModelInputs, ModelSpecificInputs, ProcessInputs, ProcessOptions };
|
|
206
|
+
export { FileInput, InferModelInputs, ModelSpecificInputs, ProcessInputs, ProcessOptions, ReactNativeFile };
|
package/dist/queue/request.js
CHANGED
|
@@ -10,9 +10,13 @@ async function submitJob({ baseUrl, apiKey, model, inputs, signal, integration }
|
|
|
10
10
|
const formData = buildFormData(inputs);
|
|
11
11
|
if (!model.queueUrlPath) throw createQueueSubmitError(`Model ${model.name} does not support queue processing`, 400);
|
|
12
12
|
const endpoint = `${baseUrl}${model.queueUrlPath}`;
|
|
13
|
+
const headers = buildAuthHeaders({
|
|
14
|
+
apiKey,
|
|
15
|
+
integration
|
|
16
|
+
});
|
|
13
17
|
const response = await fetch(endpoint, {
|
|
14
18
|
method: "POST",
|
|
15
|
-
headers
|
|
19
|
+
headers,
|
|
16
20
|
body: formData,
|
|
17
21
|
signal
|
|
18
22
|
});
|
|
@@ -28,9 +32,13 @@ async function submitJob({ baseUrl, apiKey, model, inputs, signal, integration }
|
|
|
28
32
|
*/
|
|
29
33
|
async function getJobStatus({ baseUrl, apiKey, jobId, signal, integration }) {
|
|
30
34
|
const endpoint = `${baseUrl}/v1/jobs/${jobId}`;
|
|
35
|
+
const headers = buildAuthHeaders({
|
|
36
|
+
apiKey,
|
|
37
|
+
integration
|
|
38
|
+
});
|
|
31
39
|
const response = await fetch(endpoint, {
|
|
32
40
|
method: "GET",
|
|
33
|
-
headers
|
|
41
|
+
headers,
|
|
34
42
|
signal
|
|
35
43
|
});
|
|
36
44
|
if (!response.ok) {
|
|
@@ -45,9 +53,13 @@ async function getJobStatus({ baseUrl, apiKey, jobId, signal, integration }) {
|
|
|
45
53
|
*/
|
|
46
54
|
async function getJobContent({ baseUrl, apiKey, jobId, signal, integration }) {
|
|
47
55
|
const endpoint = `${baseUrl}/v1/jobs/${jobId}/content`;
|
|
56
|
+
const headers = buildAuthHeaders({
|
|
57
|
+
apiKey,
|
|
58
|
+
integration
|
|
59
|
+
});
|
|
48
60
|
const response = await fetch(endpoint, {
|
|
49
61
|
method: "GET",
|
|
50
|
-
headers
|
|
62
|
+
headers,
|
|
51
63
|
signal
|
|
52
64
|
});
|
|
53
65
|
if (!response.ok) {
|
|
@@ -17,7 +17,7 @@ declare const avatarOptionsSchema: z.ZodObject<{
|
|
|
17
17
|
type AvatarOptions = z.infer<typeof avatarOptionsSchema>;
|
|
18
18
|
declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
|
|
19
19
|
model: z.ZodObject<{
|
|
20
|
-
name: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"live_avatar">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-dev-i2v">, z.ZodLiteral<"lucy-fast-v2v">, z.ZodLiteral<"lucy-pro-t2v">, z.ZodLiteral<"lucy-pro-i2v">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-pro-flf2v">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-restyle-v2v">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-pro-t2i">, z.ZodLiteral<"lucy-pro-i2i">]>]>;
|
|
20
|
+
name: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"lucy_v2v_14b_rt">, z.ZodLiteral<"live_avatar">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-dev-i2v">, z.ZodLiteral<"lucy-fast-v2v">, z.ZodLiteral<"lucy-pro-t2v">, z.ZodLiteral<"lucy-pro-i2v">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-pro-flf2v">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-restyle-v2v">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-pro-t2i">, z.ZodLiteral<"lucy-pro-i2i">]>]>;
|
|
21
21
|
urlPath: z.ZodString;
|
|
22
22
|
queueUrlPath: z.ZodOptional<z.ZodString>;
|
|
23
23
|
fps: z.ZodNumber;
|
package/dist/shared/model.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
//#region src/shared/model.d.ts
|
|
4
|
-
declare const realtimeModels: z.ZodUnion<readonly [z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"live_avatar">]>;
|
|
4
|
+
declare const realtimeModels: z.ZodUnion<readonly [z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"lucy_v2v_14b_rt">, z.ZodLiteral<"live_avatar">]>;
|
|
5
5
|
declare const videoModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-dev-i2v">, z.ZodLiteral<"lucy-fast-v2v">, z.ZodLiteral<"lucy-pro-t2v">, z.ZodLiteral<"lucy-pro-i2v">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-pro-flf2v">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-restyle-v2v">]>;
|
|
6
6
|
declare const imageModels: z.ZodUnion<readonly [z.ZodLiteral<"lucy-pro-t2i">, z.ZodLiteral<"lucy-pro-i2i">]>;
|
|
7
|
-
declare const modelSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"live_avatar">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-dev-i2v">, z.ZodLiteral<"lucy-fast-v2v">, z.ZodLiteral<"lucy-pro-t2v">, z.ZodLiteral<"lucy-pro-i2v">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-pro-flf2v">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-restyle-v2v">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-pro-t2i">, z.ZodLiteral<"lucy-pro-i2i">]>]>;
|
|
7
|
+
declare const modelSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"mirage">, z.ZodLiteral<"mirage_v2">, z.ZodLiteral<"lucy_v2v_720p_rt">, z.ZodLiteral<"lucy_v2v_14b_rt">, z.ZodLiteral<"live_avatar">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-dev-i2v">, z.ZodLiteral<"lucy-fast-v2v">, z.ZodLiteral<"lucy-pro-t2v">, z.ZodLiteral<"lucy-pro-i2v">, z.ZodLiteral<"lucy-pro-v2v">, z.ZodLiteral<"lucy-pro-flf2v">, z.ZodLiteral<"lucy-motion">, z.ZodLiteral<"lucy-restyle-v2v">]>, z.ZodUnion<readonly [z.ZodLiteral<"lucy-pro-t2i">, z.ZodLiteral<"lucy-pro-i2i">]>]>;
|
|
8
8
|
type Model = z.infer<typeof modelSchema>;
|
|
9
9
|
type RealTimeModels = z.infer<typeof realtimeModels>;
|
|
10
10
|
type VideoModels = z.infer<typeof videoModels>;
|
|
@@ -33,7 +33,11 @@ declare const modelInputSchemas: {
|
|
|
33
33
|
}, z.core.$strip>;
|
|
34
34
|
readonly "lucy-pro-i2v": z.ZodObject<{
|
|
35
35
|
prompt: z.ZodString;
|
|
36
|
-
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
36
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
37
|
+
uri: z.ZodString;
|
|
38
|
+
type: z.ZodString;
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
}, z.core.$strip>]>;
|
|
37
41
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
38
42
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
39
43
|
"720p": "720p";
|
|
@@ -42,14 +46,26 @@ declare const modelInputSchemas: {
|
|
|
42
46
|
}, z.core.$strip>;
|
|
43
47
|
readonly "lucy-dev-i2v": z.ZodObject<{
|
|
44
48
|
prompt: z.ZodString;
|
|
45
|
-
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
49
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
50
|
+
uri: z.ZodString;
|
|
51
|
+
type: z.ZodString;
|
|
52
|
+
name: z.ZodString;
|
|
53
|
+
}, z.core.$strip>]>;
|
|
46
54
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
47
55
|
resolution: z.ZodOptional<z.ZodDefault<z.ZodLiteral<"720p">>>;
|
|
48
56
|
}, z.core.$strip>;
|
|
49
57
|
readonly "lucy-pro-v2v": z.ZodObject<{
|
|
50
58
|
prompt: z.ZodString;
|
|
51
|
-
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
52
|
-
|
|
59
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
60
|
+
uri: z.ZodString;
|
|
61
|
+
type: z.ZodString;
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
}, z.core.$strip>]>;
|
|
64
|
+
reference_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
65
|
+
uri: z.ZodString;
|
|
66
|
+
type: z.ZodString;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
}, z.core.$strip>]>>;
|
|
53
69
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
54
70
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
55
71
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -57,15 +73,27 @@ declare const modelInputSchemas: {
|
|
|
57
73
|
}, z.core.$strip>;
|
|
58
74
|
readonly "lucy-fast-v2v": z.ZodObject<{
|
|
59
75
|
prompt: z.ZodString;
|
|
60
|
-
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
76
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
77
|
+
uri: z.ZodString;
|
|
78
|
+
type: z.ZodString;
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
}, z.core.$strip>]>;
|
|
61
81
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
62
82
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
63
83
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
64
84
|
}, z.core.$strip>;
|
|
65
85
|
readonly "lucy-pro-flf2v": z.ZodObject<{
|
|
66
86
|
prompt: z.ZodString;
|
|
67
|
-
start: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
68
|
-
|
|
87
|
+
start: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
88
|
+
uri: z.ZodString;
|
|
89
|
+
type: z.ZodString;
|
|
90
|
+
name: z.ZodString;
|
|
91
|
+
}, z.core.$strip>]>;
|
|
92
|
+
end: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
93
|
+
uri: z.ZodString;
|
|
94
|
+
type: z.ZodString;
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
}, z.core.$strip>]>;
|
|
69
97
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
70
98
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
71
99
|
"720p": "720p";
|
|
@@ -74,7 +102,11 @@ declare const modelInputSchemas: {
|
|
|
74
102
|
}, z.core.$strip>;
|
|
75
103
|
readonly "lucy-pro-i2i": z.ZodObject<{
|
|
76
104
|
prompt: z.ZodString;
|
|
77
|
-
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
105
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
106
|
+
uri: z.ZodString;
|
|
107
|
+
type: z.ZodString;
|
|
108
|
+
name: z.ZodString;
|
|
109
|
+
}, z.core.$strip>]>;
|
|
78
110
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
79
111
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
80
112
|
"720p": "720p";
|
|
@@ -83,7 +115,11 @@ declare const modelInputSchemas: {
|
|
|
83
115
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
|
84
116
|
}, z.core.$strip>;
|
|
85
117
|
readonly "lucy-motion": z.ZodObject<{
|
|
86
|
-
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
118
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
119
|
+
uri: z.ZodString;
|
|
120
|
+
type: z.ZodString;
|
|
121
|
+
name: z.ZodString;
|
|
122
|
+
}, z.core.$strip>]>;
|
|
87
123
|
trajectory: z.ZodArray<z.ZodObject<{
|
|
88
124
|
frame: z.ZodNumber;
|
|
89
125
|
x: z.ZodNumber;
|
|
@@ -94,8 +130,16 @@ declare const modelInputSchemas: {
|
|
|
94
130
|
}, z.core.$strip>;
|
|
95
131
|
readonly "lucy-restyle-v2v": z.ZodObject<{
|
|
96
132
|
prompt: z.ZodOptional<z.ZodString>;
|
|
97
|
-
reference_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL
|
|
98
|
-
|
|
133
|
+
reference_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
134
|
+
uri: z.ZodString;
|
|
135
|
+
type: z.ZodString;
|
|
136
|
+
name: z.ZodString;
|
|
137
|
+
}, z.core.$strip>]>>;
|
|
138
|
+
data: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>, z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>, z.ZodCustom<URL, URL>, z.ZodURL, z.ZodObject<{
|
|
139
|
+
uri: z.ZodString;
|
|
140
|
+
type: z.ZodString;
|
|
141
|
+
name: z.ZodString;
|
|
142
|
+
}, z.core.$strip>]>;
|
|
99
143
|
seed: z.ZodOptional<z.ZodNumber>;
|
|
100
144
|
resolution: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"720p">>>;
|
|
101
145
|
enhance_prompt: z.ZodOptional<z.ZodBoolean>;
|
package/dist/shared/model.js
CHANGED
|
@@ -6,6 +6,7 @@ const realtimeModels = z.union([
|
|
|
6
6
|
z.literal("mirage"),
|
|
7
7
|
z.literal("mirage_v2"),
|
|
8
8
|
z.literal("lucy_v2v_720p_rt"),
|
|
9
|
+
z.literal("lucy_v2v_14b_rt"),
|
|
9
10
|
z.literal("live_avatar")
|
|
10
11
|
]);
|
|
11
12
|
const videoModels = z.union([
|
|
@@ -38,7 +39,12 @@ const fileInputSchema = z.union([
|
|
|
38
39
|
z.instanceof(Blob),
|
|
39
40
|
z.instanceof(ReadableStream),
|
|
40
41
|
z.instanceof(URL),
|
|
41
|
-
z.url()
|
|
42
|
+
z.url(),
|
|
43
|
+
z.object({
|
|
44
|
+
uri: z.string(),
|
|
45
|
+
type: z.string(),
|
|
46
|
+
name: z.string()
|
|
47
|
+
})
|
|
42
48
|
]);
|
|
43
49
|
/**
|
|
44
50
|
* Resolution schema for dev models. Supports only 720p.
|
|
@@ -168,6 +174,14 @@ const _models = {
|
|
|
168
174
|
height: 704,
|
|
169
175
|
inputSchema: z.object({})
|
|
170
176
|
},
|
|
177
|
+
lucy_v2v_14b_rt: {
|
|
178
|
+
urlPath: "/v1/stream",
|
|
179
|
+
name: "lucy_v2v_14b_rt",
|
|
180
|
+
fps: 15,
|
|
181
|
+
width: 1280,
|
|
182
|
+
height: 704,
|
|
183
|
+
inputSchema: z.object({})
|
|
184
|
+
},
|
|
171
185
|
live_avatar: {
|
|
172
186
|
urlPath: "/v1/stream",
|
|
173
187
|
name: "live_avatar",
|
package/dist/shared/request.js
CHANGED
|
@@ -3,9 +3,17 @@ import { buildUserAgent } from "../utils/user-agent.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/shared/request.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Type guard to check if a value is a React Native file object.
|
|
7
|
+
*/
|
|
8
|
+
function isReactNativeFile(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && typeof value.uri === "string" && typeof value.type === "string" && typeof value.name === "string";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Convert various file input types to a Blob or React Native file object.
|
|
13
|
+
* React Native file objects are passed through as-is for proper FormData handling.
|
|
7
14
|
*/
|
|
8
15
|
async function fileInputToBlob(input) {
|
|
16
|
+
if (isReactNativeFile(input)) return input;
|
|
9
17
|
if (input instanceof Blob || input instanceof File) return input;
|
|
10
18
|
if (input instanceof ReadableStream) return new Response(input).blob();
|
|
11
19
|
if (typeof input === "string" || input instanceof URL) {
|
|
@@ -20,10 +28,11 @@ async function fileInputToBlob(input) {
|
|
|
20
28
|
/**
|
|
21
29
|
* Build common headers for API requests.
|
|
22
30
|
*/
|
|
23
|
-
function buildAuthHeaders(
|
|
31
|
+
function buildAuthHeaders(options = {}) {
|
|
32
|
+
const { apiKey, integration } = options;
|
|
24
33
|
return {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
34
|
+
"User-Agent": buildUserAgent(integration),
|
|
35
|
+
...apiKey ? { "X-API-KEY": apiKey } : {}
|
|
27
36
|
};
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
@@ -31,7 +40,8 @@ function buildAuthHeaders(apiKey, integration) {
|
|
|
31
40
|
*/
|
|
32
41
|
function buildFormData(inputs) {
|
|
33
42
|
const formData = new FormData();
|
|
34
|
-
for (const [key, value] of Object.entries(inputs)) if (value !== void 0 && value !== null) if (value
|
|
43
|
+
for (const [key, value] of Object.entries(inputs)) if (value !== void 0 && value !== null) if (isReactNativeFile(value)) formData.append(key, value);
|
|
44
|
+
else if (value instanceof Blob) formData.append(key, value);
|
|
35
45
|
else if (typeof value === "object" && value !== null) formData.append(key, JSON.stringify(value));
|
|
36
46
|
else formData.append(key, String(value));
|
|
37
47
|
return formData;
|
package/dist/tokens/client.js
CHANGED
|
@@ -5,9 +5,13 @@ import { buildAuthHeaders } from "../shared/request.js";
|
|
|
5
5
|
const createTokensClient = (opts) => {
|
|
6
6
|
const { baseUrl, apiKey, integration } = opts;
|
|
7
7
|
const create = async () => {
|
|
8
|
+
const headers = buildAuthHeaders({
|
|
9
|
+
apiKey,
|
|
10
|
+
integration
|
|
11
|
+
});
|
|
8
12
|
const response = await fetch(`${baseUrl}/v1/client/tokens`, {
|
|
9
13
|
method: "POST",
|
|
10
|
-
headers
|
|
14
|
+
headers
|
|
11
15
|
});
|
|
12
16
|
if (!response.ok) {
|
|
13
17
|
const errorText = await response.text().catch(() => "Unknown error");
|