@runapi.ai/imagen-4 0.2.3 → 0.2.5
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/README.md +1 -1
- package/dist/index.d.mts +30 -14
- package/dist/index.d.ts +30 -14
- package/dist/index.js +47 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Imagen API JavaScript SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The imagen api JavaScript SDK is the language-specific package for Imagen 4 on RunAPI. Use this imagen api package for text-to-image, image
|
|
3
|
+
The imagen api JavaScript SDK is the language-specific package for Imagen 4 on RunAPI. Use this imagen api package for text-to-image, image editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
|
|
4
4
|
|
|
5
5
|
This imagen api README is the JavaScript package guide inside the public `imagen4-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/imagen-4; for API reference, use https://runapi.ai/docs#imagen-4; for SDK docs, use https://runapi.ai/docs#sdk-imagen-4.
|
|
6
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,19 +2,20 @@ import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOpti
|
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
4
|
type Imagen4TextModel = 'imagen-4' | 'imagen-4-fast' | 'imagen-4-ultra';
|
|
5
|
-
type
|
|
5
|
+
type Imagen4RemixModel = 'imagen-4-pro-remix-image';
|
|
6
|
+
type Imagen4Model = Imagen4TextModel | Imagen4RemixModel;
|
|
6
7
|
type TextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
|
|
7
8
|
type ProAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
|
|
8
|
-
type
|
|
9
|
+
type OutputResolution = '1k' | '2k' | '4k';
|
|
9
10
|
type OutputFormat = 'png' | 'jpg';
|
|
10
|
-
type
|
|
11
|
+
type OutputCount = 1 | 2 | 3 | 4;
|
|
11
12
|
interface BaseTextTextToImageParams {
|
|
12
13
|
model: 'imagen-4' | 'imagen-4-ultra';
|
|
13
14
|
prompt: string;
|
|
14
15
|
callback_url?: string;
|
|
15
16
|
negative_prompt?: string;
|
|
16
17
|
aspect_ratio?: TextAspectRatio;
|
|
17
|
-
seed?:
|
|
18
|
+
seed?: number;
|
|
18
19
|
}
|
|
19
20
|
interface FastTextTextToImageParams {
|
|
20
21
|
model: 'imagen-4-fast';
|
|
@@ -22,34 +23,40 @@ interface FastTextTextToImageParams {
|
|
|
22
23
|
callback_url?: string;
|
|
23
24
|
negative_prompt?: string;
|
|
24
25
|
aspect_ratio?: TextAspectRatio;
|
|
25
|
-
seed?:
|
|
26
|
-
|
|
26
|
+
seed?: number;
|
|
27
|
+
output_count?: OutputCount;
|
|
27
28
|
}
|
|
28
|
-
interface
|
|
29
|
-
model:
|
|
29
|
+
interface RemixImageParams {
|
|
30
|
+
model: Imagen4RemixModel;
|
|
30
31
|
prompt: string;
|
|
31
32
|
callback_url?: string;
|
|
32
|
-
|
|
33
|
+
source_image_urls: string[];
|
|
33
34
|
aspect_ratio?: ProAspectRatio;
|
|
34
|
-
|
|
35
|
+
output_resolution?: OutputResolution;
|
|
35
36
|
output_format?: OutputFormat;
|
|
36
37
|
}
|
|
37
|
-
type TextToImageParams = BaseTextTextToImageParams | FastTextTextToImageParams
|
|
38
|
+
type TextToImageParams = BaseTextTextToImageParams | FastTextTextToImageParams;
|
|
38
39
|
interface TaskCreateResponse {
|
|
39
40
|
id: string;
|
|
40
41
|
status: AsyncTaskStatus;
|
|
41
42
|
}
|
|
43
|
+
interface Image {
|
|
44
|
+
url: string;
|
|
45
|
+
origin_url?: string;
|
|
46
|
+
}
|
|
42
47
|
interface TextToImageResponse {
|
|
43
48
|
id: string;
|
|
44
49
|
status: AsyncTaskStatus;
|
|
45
|
-
|
|
50
|
+
images?: Image[];
|
|
46
51
|
error?: string;
|
|
47
52
|
[key: string]: unknown;
|
|
48
53
|
}
|
|
49
54
|
type CompletedTextToImageResponse = TextToImageResponse & {
|
|
50
55
|
status: 'completed';
|
|
51
|
-
|
|
56
|
+
images: Image[];
|
|
52
57
|
};
|
|
58
|
+
type RemixImageResponse = TextToImageResponse;
|
|
59
|
+
type CompletedRemixImageResponse = CompletedTextToImageResponse;
|
|
53
60
|
|
|
54
61
|
declare class TextToImage {
|
|
55
62
|
private readonly http;
|
|
@@ -59,9 +66,18 @@ declare class TextToImage {
|
|
|
59
66
|
get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
|
|
60
67
|
}
|
|
61
68
|
|
|
69
|
+
declare class RemixImage {
|
|
70
|
+
private readonly http;
|
|
71
|
+
constructor(http: HttpClient);
|
|
72
|
+
run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse>;
|
|
73
|
+
create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
74
|
+
get(id: string, options?: RequestOptions): Promise<RemixImageResponse>;
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
declare class Imagen4Client {
|
|
63
78
|
readonly textToImage: TextToImage;
|
|
79
|
+
readonly remixImage: RemixImage;
|
|
64
80
|
constructor(options?: ClientOptions);
|
|
65
81
|
}
|
|
66
82
|
|
|
67
|
-
export { type BaseTextTextToImageParams, type CompletedTextToImageResponse, type FastTextTextToImageParams, Imagen4Client, type Imagen4Model, type Imagen4TextModel, type
|
|
83
|
+
export { type BaseTextTextToImageParams, type CompletedRemixImageResponse, type CompletedTextToImageResponse, type FastTextTextToImageParams, type Image, Imagen4Client, type Imagen4Model, type Imagen4RemixModel, type Imagen4TextModel, type OutputCount, type OutputFormat, type OutputResolution, type ProAspectRatio, RemixImage, type RemixImageParams, type RemixImageResponse, type TaskCreateResponse, type TextAspectRatio, TextToImage, type TextToImageParams, type TextToImageResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,19 +2,20 @@ import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOpti
|
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
4
|
type Imagen4TextModel = 'imagen-4' | 'imagen-4-fast' | 'imagen-4-ultra';
|
|
5
|
-
type
|
|
5
|
+
type Imagen4RemixModel = 'imagen-4-pro-remix-image';
|
|
6
|
+
type Imagen4Model = Imagen4TextModel | Imagen4RemixModel;
|
|
6
7
|
type TextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
|
|
7
8
|
type ProAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
|
|
8
|
-
type
|
|
9
|
+
type OutputResolution = '1k' | '2k' | '4k';
|
|
9
10
|
type OutputFormat = 'png' | 'jpg';
|
|
10
|
-
type
|
|
11
|
+
type OutputCount = 1 | 2 | 3 | 4;
|
|
11
12
|
interface BaseTextTextToImageParams {
|
|
12
13
|
model: 'imagen-4' | 'imagen-4-ultra';
|
|
13
14
|
prompt: string;
|
|
14
15
|
callback_url?: string;
|
|
15
16
|
negative_prompt?: string;
|
|
16
17
|
aspect_ratio?: TextAspectRatio;
|
|
17
|
-
seed?:
|
|
18
|
+
seed?: number;
|
|
18
19
|
}
|
|
19
20
|
interface FastTextTextToImageParams {
|
|
20
21
|
model: 'imagen-4-fast';
|
|
@@ -22,34 +23,40 @@ interface FastTextTextToImageParams {
|
|
|
22
23
|
callback_url?: string;
|
|
23
24
|
negative_prompt?: string;
|
|
24
25
|
aspect_ratio?: TextAspectRatio;
|
|
25
|
-
seed?:
|
|
26
|
-
|
|
26
|
+
seed?: number;
|
|
27
|
+
output_count?: OutputCount;
|
|
27
28
|
}
|
|
28
|
-
interface
|
|
29
|
-
model:
|
|
29
|
+
interface RemixImageParams {
|
|
30
|
+
model: Imagen4RemixModel;
|
|
30
31
|
prompt: string;
|
|
31
32
|
callback_url?: string;
|
|
32
|
-
|
|
33
|
+
source_image_urls: string[];
|
|
33
34
|
aspect_ratio?: ProAspectRatio;
|
|
34
|
-
|
|
35
|
+
output_resolution?: OutputResolution;
|
|
35
36
|
output_format?: OutputFormat;
|
|
36
37
|
}
|
|
37
|
-
type TextToImageParams = BaseTextTextToImageParams | FastTextTextToImageParams
|
|
38
|
+
type TextToImageParams = BaseTextTextToImageParams | FastTextTextToImageParams;
|
|
38
39
|
interface TaskCreateResponse {
|
|
39
40
|
id: string;
|
|
40
41
|
status: AsyncTaskStatus;
|
|
41
42
|
}
|
|
43
|
+
interface Image {
|
|
44
|
+
url: string;
|
|
45
|
+
origin_url?: string;
|
|
46
|
+
}
|
|
42
47
|
interface TextToImageResponse {
|
|
43
48
|
id: string;
|
|
44
49
|
status: AsyncTaskStatus;
|
|
45
|
-
|
|
50
|
+
images?: Image[];
|
|
46
51
|
error?: string;
|
|
47
52
|
[key: string]: unknown;
|
|
48
53
|
}
|
|
49
54
|
type CompletedTextToImageResponse = TextToImageResponse & {
|
|
50
55
|
status: 'completed';
|
|
51
|
-
|
|
56
|
+
images: Image[];
|
|
52
57
|
};
|
|
58
|
+
type RemixImageResponse = TextToImageResponse;
|
|
59
|
+
type CompletedRemixImageResponse = CompletedTextToImageResponse;
|
|
53
60
|
|
|
54
61
|
declare class TextToImage {
|
|
55
62
|
private readonly http;
|
|
@@ -59,9 +66,18 @@ declare class TextToImage {
|
|
|
59
66
|
get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
|
|
60
67
|
}
|
|
61
68
|
|
|
69
|
+
declare class RemixImage {
|
|
70
|
+
private readonly http;
|
|
71
|
+
constructor(http: HttpClient);
|
|
72
|
+
run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse>;
|
|
73
|
+
create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
74
|
+
get(id: string, options?: RequestOptions): Promise<RemixImageResponse>;
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
declare class Imagen4Client {
|
|
63
78
|
readonly textToImage: TextToImage;
|
|
79
|
+
readonly remixImage: RemixImage;
|
|
64
80
|
constructor(options?: ClientOptions);
|
|
65
81
|
}
|
|
66
82
|
|
|
67
|
-
export { type BaseTextTextToImageParams, type CompletedTextToImageResponse, type FastTextTextToImageParams, Imagen4Client, type Imagen4Model, type Imagen4TextModel, type
|
|
83
|
+
export { type BaseTextTextToImageParams, type CompletedRemixImageResponse, type CompletedTextToImageResponse, type FastTextTextToImageParams, type Image, Imagen4Client, type Imagen4Model, type Imagen4RemixModel, type Imagen4TextModel, type OutputCount, type OutputFormat, type OutputResolution, type ProAspectRatio, RemixImage, type RemixImageParams, type RemixImageResponse, type TaskCreateResponse, type TextAspectRatio, TextToImage, type TextToImageParams, type TextToImageResponse };
|
package/dist/index.js
CHANGED
|
@@ -20,24 +20,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
AuthenticationError: () =>
|
|
23
|
+
AuthenticationError: () => import_core4.AuthenticationError,
|
|
24
24
|
Imagen4Client: () => Imagen4Client,
|
|
25
|
-
InsufficientCreditsError: () =>
|
|
26
|
-
NetworkError: () =>
|
|
27
|
-
NotFoundError: () =>
|
|
28
|
-
RateLimitError: () =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
InsufficientCreditsError: () => import_core4.InsufficientCreditsError,
|
|
26
|
+
NetworkError: () => import_core4.NetworkError,
|
|
27
|
+
NotFoundError: () => import_core4.NotFoundError,
|
|
28
|
+
RateLimitError: () => import_core4.RateLimitError,
|
|
29
|
+
RemixImage: () => RemixImage,
|
|
30
|
+
RunApiError: () => import_core4.RunApiError,
|
|
31
|
+
ServiceUnavailableError: () => import_core4.ServiceUnavailableError,
|
|
32
|
+
TaskFailedError: () => import_core4.TaskFailedError,
|
|
33
|
+
TaskTimeoutError: () => import_core4.TaskTimeoutError,
|
|
33
34
|
TextToImage: () => TextToImage,
|
|
34
|
-
TimeoutError: () =>
|
|
35
|
-
ValidationError: () =>
|
|
35
|
+
TimeoutError: () => import_core4.TimeoutError,
|
|
36
|
+
ValidationError: () => import_core4.ValidationError
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
|
|
39
40
|
// src/client.ts
|
|
40
|
-
var
|
|
41
|
+
var import_core3 = require("@runapi.ai/core");
|
|
41
42
|
|
|
42
43
|
// src/resources/text-to-image.ts
|
|
43
44
|
var import_core = require("@runapi.ai/core");
|
|
@@ -68,17 +69,48 @@ var TextToImage = class {
|
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
|
|
72
|
+
// src/resources/remix-image.ts
|
|
73
|
+
var import_core2 = require("@runapi.ai/core");
|
|
74
|
+
var import_internal2 = require("@runapi.ai/core/internal");
|
|
75
|
+
var ENDPOINT2 = "/api/v1/imagen_4/remix_image";
|
|
76
|
+
var RemixImage = class {
|
|
77
|
+
constructor(http) {
|
|
78
|
+
this.http = http;
|
|
79
|
+
}
|
|
80
|
+
http;
|
|
81
|
+
async run(params, options) {
|
|
82
|
+
const { id } = await this.create(params, options);
|
|
83
|
+
return (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
|
|
84
|
+
maxWaitMs: options?.maxWaitMs,
|
|
85
|
+
pollIntervalMs: options?.pollIntervalMs
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async create(params, options) {
|
|
89
|
+
return this.http.request("POST", ENDPOINT2, {
|
|
90
|
+
body: (0, import_core2.compactParams)(params),
|
|
91
|
+
...options
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async get(id, options) {
|
|
95
|
+
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
96
|
+
...options
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
71
101
|
// src/client.ts
|
|
72
102
|
var Imagen4Client = class {
|
|
73
103
|
textToImage;
|
|
104
|
+
remixImage;
|
|
74
105
|
constructor(options = {}) {
|
|
75
|
-
const http = (0,
|
|
106
|
+
const http = (0, import_core3.createHttpClient)(options);
|
|
76
107
|
this.textToImage = new TextToImage(http);
|
|
108
|
+
this.remixImage = new RemixImage(http);
|
|
77
109
|
}
|
|
78
110
|
};
|
|
79
111
|
|
|
80
112
|
// src/index.ts
|
|
81
|
-
var
|
|
113
|
+
var import_core4 = require("@runapi.ai/core");
|
|
82
114
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
115
|
0 && (module.exports = {
|
|
84
116
|
AuthenticationError,
|
|
@@ -87,6 +119,7 @@ var import_core3 = require("@runapi.ai/core");
|
|
|
87
119
|
NetworkError,
|
|
88
120
|
NotFoundError,
|
|
89
121
|
RateLimitError,
|
|
122
|
+
RemixImage,
|
|
90
123
|
RunApiError,
|
|
91
124
|
ServiceUnavailableError,
|
|
92
125
|
TaskFailedError,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts"],"sourcesContent":["export { Imagen4Client } from './client';\nexport { TextToImage } from './resources/text-to-image';\nexport type * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\n\nexport class Imagen4Client {\n public readonly textToImage: TextToImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAqD;;;ACCrD,kBAA8B;AAC9B,sBAAkC;AAGlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAyE;AAC5G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,eAAO,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,UAAM,2BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts","../src/resources/remix-image.ts"],"sourcesContent":["export { Imagen4Client } from './client';\nexport { TextToImage } from './resources/text-to-image';\nexport { RemixImage } from './resources/remix-image';\nexport type * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\nexport class Imagen4Client {\n public readonly textToImage: TextToImage;\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.remixImage = new RemixImage(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { RemixImageParams, RemixImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/remix_image';\n\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAqD;;;ACCrD,kBAA8B;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EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACvE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AF1BO,IAAM,gBAAN,MAAoB;AAAA,EACT;AAAA,EACA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,WAAO,+BAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,aAAa,IAAI,WAAW,IAAI;AAAA,EACvC;AACF;;;ADRA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -30,12 +30,43 @@ var TextToImage = class {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
// src/resources/remix-image.ts
|
|
34
|
+
import { compactParams as compactParams2 } from "@runapi.ai/core";
|
|
35
|
+
import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
|
|
36
|
+
var ENDPOINT2 = "/api/v1/imagen_4/remix_image";
|
|
37
|
+
var RemixImage = class {
|
|
38
|
+
constructor(http) {
|
|
39
|
+
this.http = http;
|
|
40
|
+
}
|
|
41
|
+
http;
|
|
42
|
+
async run(params, options) {
|
|
43
|
+
const { id } = await this.create(params, options);
|
|
44
|
+
return pollUntilComplete2(() => this.get(id, options), {
|
|
45
|
+
maxWaitMs: options?.maxWaitMs,
|
|
46
|
+
pollIntervalMs: options?.pollIntervalMs
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async create(params, options) {
|
|
50
|
+
return this.http.request("POST", ENDPOINT2, {
|
|
51
|
+
body: compactParams2(params),
|
|
52
|
+
...options
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async get(id, options) {
|
|
56
|
+
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
57
|
+
...options
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
33
62
|
// src/client.ts
|
|
34
63
|
var Imagen4Client = class {
|
|
35
64
|
textToImage;
|
|
65
|
+
remixImage;
|
|
36
66
|
constructor(options = {}) {
|
|
37
67
|
const http = createHttpClient(options);
|
|
38
68
|
this.textToImage = new TextToImage(http);
|
|
69
|
+
this.remixImage = new RemixImage(http);
|
|
39
70
|
}
|
|
40
71
|
};
|
|
41
72
|
|
|
@@ -60,6 +91,7 @@ export {
|
|
|
60
91
|
NetworkError,
|
|
61
92
|
NotFoundError,
|
|
62
93
|
RateLimitError,
|
|
94
|
+
RemixImage,
|
|
63
95
|
RunApiError,
|
|
64
96
|
ServiceUnavailableError,
|
|
65
97
|
TaskFailedError,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/index.ts"],"sourcesContent":["import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\n\nexport class Imagen4Client {\n public readonly textToImage: TextToImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { Imagen4Client } from './client';\nexport { TextToImage } from './resources/text-to-image';\nexport type * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,wBAA4C;;;ACCrD,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAGlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAyE;AAC5G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,WAAO,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/resources/remix-image.ts","../src/index.ts"],"sourcesContent":["import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\nexport class Imagen4Client {\n public readonly textToImage: TextToImage;\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.remixImage = new RemixImage(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { RemixImageParams, RemixImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/remix_image';\n\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { Imagen4Client } from './client';\nexport { TextToImage } from './resources/text-to-image';\nexport { RemixImage } from './resources/remix-image';\nexport type * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,wBAA4C;;;ACCrD,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAGlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAyE;AAC5G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,WAAO,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,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"0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "RunAPI Imagen 4 SDK for JavaScript, Ruby, and Go",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"clean": "rm -rf dist"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@runapi.ai/core": "^0.2.
|
|
30
|
+
"@runapi.ai/core": "^0.2.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^20.0.0",
|