@runapi.ai/imagen-4 0.2.5 → 0.2.7
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 +10 -8
- package/dist/index.d.mts +97 -2
- package/dist/index.d.ts +97 -2
- package/dist/index.js +160 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -4
package/README.md
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
# Imagen API JavaScript SDK for RunAPI
|
|
1
|
+
# Imagen 4 API JavaScript SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Imagen 4 JavaScript SDK is the language-specific package for Imagen 4 on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
|
|
4
4
|
|
|
5
|
-
This
|
|
5
|
+
This README is the JavaScript package guide inside the public `imagen-4-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
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @runapi.ai/
|
|
10
|
+
npm install @runapi.ai/imagen-4
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { Imagen4Client } from '@runapi.ai/
|
|
16
|
+
import { Imagen4Client } from '@runapi.ai/imagen-4';
|
|
17
17
|
|
|
18
18
|
const client = new Imagen4Client();
|
|
19
|
-
const task = await client.
|
|
19
|
+
const task = await client.textToImage.create({
|
|
20
20
|
// Pass the Imagen 4 JSON request body from https://runapi.ai/docs#imagen-4.
|
|
21
21
|
});
|
|
22
|
-
const status = await client.
|
|
22
|
+
const status = await client.textToImage.get(task.id);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
|
|
26
26
|
|
|
27
|
+
RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
|
|
28
|
+
|
|
27
29
|
## Language notes
|
|
28
30
|
|
|
29
|
-
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources
|
|
31
|
+
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources are `textToImage` and `remixImage`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
30
32
|
|
|
31
33
|
## Links
|
|
32
34
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,35 +1,61 @@
|
|
|
1
|
-
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
1
|
+
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, ClientOptions } from '@runapi.ai/core';
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
|
+
/** Text-to-image model variants differing by quality and latency. */
|
|
4
5
|
type Imagen4TextModel = 'imagen-4' | 'imagen-4-fast' | 'imagen-4-ultra';
|
|
6
|
+
/** The remix model that accepts source images for guided generation. */
|
|
5
7
|
type Imagen4RemixModel = 'imagen-4-pro-remix-image';
|
|
8
|
+
/** Union of all Imagen 4 model identifiers. */
|
|
6
9
|
type Imagen4Model = Imagen4TextModel | Imagen4RemixModel;
|
|
10
|
+
/** Aspect ratios for text-to-image generation. */
|
|
7
11
|
type TextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
|
|
12
|
+
/** Extended aspect ratios for remix, including "auto" which infers from source images. */
|
|
8
13
|
type ProAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
|
|
14
|
+
/** Pixel resolution tier for remix output. */
|
|
9
15
|
type OutputResolution = '1k' | '2k' | '4k';
|
|
16
|
+
/** Image encoding format for remix output. */
|
|
10
17
|
type OutputFormat = 'png' | 'jpg';
|
|
18
|
+
/** Batch size for imagen-4-fast (the only model supporting multi-image output). */
|
|
11
19
|
type OutputCount = 1 | 2 | 3 | 4;
|
|
20
|
+
/**
|
|
21
|
+
* Parameters for imagen-4 (standard) and imagen-4-ultra (highest quality).
|
|
22
|
+
* These models produce a single image per request.
|
|
23
|
+
*/
|
|
12
24
|
interface BaseTextTextToImageParams {
|
|
13
25
|
model: 'imagen-4' | 'imagen-4-ultra';
|
|
14
26
|
prompt: string;
|
|
15
27
|
callback_url?: string;
|
|
28
|
+
/** Content to steer the model away from in the output. */
|
|
16
29
|
negative_prompt?: string;
|
|
17
30
|
aspect_ratio?: TextAspectRatio;
|
|
31
|
+
/** Fixed seed for reproducible generation. */
|
|
18
32
|
seed?: number;
|
|
19
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Parameters for imagen-4-fast, which supports batch output (1-4 images)
|
|
36
|
+
* at lower latency than the standard tier.
|
|
37
|
+
*/
|
|
20
38
|
interface FastTextTextToImageParams {
|
|
21
39
|
model: 'imagen-4-fast';
|
|
22
40
|
prompt: string;
|
|
23
41
|
callback_url?: string;
|
|
42
|
+
/** Content to steer the model away from in the output. */
|
|
24
43
|
negative_prompt?: string;
|
|
25
44
|
aspect_ratio?: TextAspectRatio;
|
|
45
|
+
/** Fixed seed for reproducible generation. */
|
|
26
46
|
seed?: number;
|
|
47
|
+
/** Number of images to generate (only supported by imagen-4-fast). */
|
|
27
48
|
output_count?: OutputCount;
|
|
28
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Parameters for image remix -- guided generation from 1-8 source images
|
|
52
|
+
* combined with a text prompt. Supports resolution and format control.
|
|
53
|
+
*/
|
|
29
54
|
interface RemixImageParams {
|
|
30
55
|
model: Imagen4RemixModel;
|
|
31
56
|
prompt: string;
|
|
32
57
|
callback_url?: string;
|
|
58
|
+
/** 1-8 publicly accessible source image URLs. */
|
|
33
59
|
source_image_urls: string[];
|
|
34
60
|
aspect_ratio?: ProAspectRatio;
|
|
35
61
|
output_resolution?: OutputResolution;
|
|
@@ -40,8 +66,10 @@ interface TaskCreateResponse {
|
|
|
40
66
|
id: string;
|
|
41
67
|
status: AsyncTaskStatus;
|
|
42
68
|
}
|
|
69
|
+
/** A generated image with its CDN URL and optional unprocessed origin URL. */
|
|
43
70
|
interface Image {
|
|
44
71
|
url: string;
|
|
72
|
+
/** Unprocessed source URL when available (before CDN optimization). */
|
|
45
73
|
origin_url?: string;
|
|
46
74
|
}
|
|
47
75
|
interface TextToImageResponse {
|
|
@@ -51,6 +79,10 @@ interface TextToImageResponse {
|
|
|
51
79
|
error?: string;
|
|
52
80
|
[key: string]: unknown;
|
|
53
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolved response returned by `run()` after polling sees `status: 'completed'`.
|
|
84
|
+
* Narrows the base response so `images` is guaranteed non-optional.
|
|
85
|
+
*/
|
|
54
86
|
type CompletedTextToImageResponse = TextToImageResponse & {
|
|
55
87
|
status: 'completed';
|
|
56
88
|
images: Image[];
|
|
@@ -58,24 +90,87 @@ type CompletedTextToImageResponse = TextToImageResponse & {
|
|
|
58
90
|
type RemixImageResponse = TextToImageResponse;
|
|
59
91
|
type CompletedRemixImageResponse = CompletedTextToImageResponse;
|
|
60
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Generates images from a text prompt.
|
|
95
|
+
* Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency,
|
|
96
|
+
* batch output up to 4 images), and imagen-4-ultra (highest quality).
|
|
97
|
+
*/
|
|
61
98
|
declare class TextToImage {
|
|
62
99
|
private readonly http;
|
|
63
100
|
constructor(http: HttpClient);
|
|
101
|
+
/**
|
|
102
|
+
* Generate images from a text prompt and wait until complete.
|
|
103
|
+
* @param params Text-to-image parameters.
|
|
104
|
+
* @param options Per-request and polling overrides.
|
|
105
|
+
* @returns The completed task with images.
|
|
106
|
+
*/
|
|
64
107
|
run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Generate images from a text prompt; returns immediately with a task id.
|
|
110
|
+
* @param params Text-to-image parameters.
|
|
111
|
+
* @param options Per-request overrides.
|
|
112
|
+
* @returns The task creation result with id.
|
|
113
|
+
*/
|
|
65
114
|
create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Fetch the current status of a text-to-image task.
|
|
117
|
+
* @param id The task id.
|
|
118
|
+
* @param options Per-request overrides.
|
|
119
|
+
* @returns The current text-to-image task status.
|
|
120
|
+
*/
|
|
66
121
|
get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
|
|
67
122
|
}
|
|
68
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Generates new images guided by 1-8 source images combined with a text prompt.
|
|
126
|
+
* Supports output resolution control (1k/2k/4k) and format selection (png/jpg).
|
|
127
|
+
*/
|
|
69
128
|
declare class RemixImage {
|
|
70
129
|
private readonly http;
|
|
71
130
|
constructor(http: HttpClient);
|
|
131
|
+
/**
|
|
132
|
+
* Transform source images guided by a text prompt and wait until complete.
|
|
133
|
+
* @param params Remix-image parameters.
|
|
134
|
+
* @param options Per-request and polling overrides.
|
|
135
|
+
* @returns The completed task with images.
|
|
136
|
+
*/
|
|
72
137
|
run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Transform source images guided by a text prompt; returns immediately with a task id.
|
|
140
|
+
* @param params Remix-image parameters.
|
|
141
|
+
* @param options Per-request overrides.
|
|
142
|
+
* @returns The task creation result with id.
|
|
143
|
+
*/
|
|
73
144
|
create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Fetch the current status of a remix-image task.
|
|
147
|
+
* @param id The task id.
|
|
148
|
+
* @param options Per-request overrides.
|
|
149
|
+
* @returns The current remix-image task status.
|
|
150
|
+
*/
|
|
74
151
|
get(id: string, options?: RequestOptions): Promise<RemixImageResponse>;
|
|
75
152
|
}
|
|
76
153
|
|
|
77
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Imagen 4 image generation API client.
|
|
156
|
+
*
|
|
157
|
+
* Three text-to-image quality tiers (imagen-4, imagen-4-fast, imagen-4-ultra)
|
|
158
|
+
* and a dedicated remix model for guided image transformation from source images.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const client = new Imagen4Client({ apiKey: 'your-api-key' });
|
|
163
|
+
*
|
|
164
|
+
* const result = await client.textToImage.run({
|
|
165
|
+
* model: 'imagen-4',
|
|
166
|
+
* prompt: 'A cat in a spacesuit on the moon',
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare class Imagen4Client extends BaseClient {
|
|
171
|
+
/** Text-to-image generation across three quality tiers. */
|
|
78
172
|
readonly textToImage: TextToImage;
|
|
173
|
+
/** Generate new images guided by one or more source images combined with a text prompt. */
|
|
79
174
|
readonly remixImage: RemixImage;
|
|
80
175
|
constructor(options?: ClientOptions);
|
|
81
176
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,61 @@
|
|
|
1
|
-
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
1
|
+
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, ClientOptions } from '@runapi.ai/core';
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
|
+
/** Text-to-image model variants differing by quality and latency. */
|
|
4
5
|
type Imagen4TextModel = 'imagen-4' | 'imagen-4-fast' | 'imagen-4-ultra';
|
|
6
|
+
/** The remix model that accepts source images for guided generation. */
|
|
5
7
|
type Imagen4RemixModel = 'imagen-4-pro-remix-image';
|
|
8
|
+
/** Union of all Imagen 4 model identifiers. */
|
|
6
9
|
type Imagen4Model = Imagen4TextModel | Imagen4RemixModel;
|
|
10
|
+
/** Aspect ratios for text-to-image generation. */
|
|
7
11
|
type TextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
|
|
12
|
+
/** Extended aspect ratios for remix, including "auto" which infers from source images. */
|
|
8
13
|
type ProAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
|
|
14
|
+
/** Pixel resolution tier for remix output. */
|
|
9
15
|
type OutputResolution = '1k' | '2k' | '4k';
|
|
16
|
+
/** Image encoding format for remix output. */
|
|
10
17
|
type OutputFormat = 'png' | 'jpg';
|
|
18
|
+
/** Batch size for imagen-4-fast (the only model supporting multi-image output). */
|
|
11
19
|
type OutputCount = 1 | 2 | 3 | 4;
|
|
20
|
+
/**
|
|
21
|
+
* Parameters for imagen-4 (standard) and imagen-4-ultra (highest quality).
|
|
22
|
+
* These models produce a single image per request.
|
|
23
|
+
*/
|
|
12
24
|
interface BaseTextTextToImageParams {
|
|
13
25
|
model: 'imagen-4' | 'imagen-4-ultra';
|
|
14
26
|
prompt: string;
|
|
15
27
|
callback_url?: string;
|
|
28
|
+
/** Content to steer the model away from in the output. */
|
|
16
29
|
negative_prompt?: string;
|
|
17
30
|
aspect_ratio?: TextAspectRatio;
|
|
31
|
+
/** Fixed seed for reproducible generation. */
|
|
18
32
|
seed?: number;
|
|
19
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Parameters for imagen-4-fast, which supports batch output (1-4 images)
|
|
36
|
+
* at lower latency than the standard tier.
|
|
37
|
+
*/
|
|
20
38
|
interface FastTextTextToImageParams {
|
|
21
39
|
model: 'imagen-4-fast';
|
|
22
40
|
prompt: string;
|
|
23
41
|
callback_url?: string;
|
|
42
|
+
/** Content to steer the model away from in the output. */
|
|
24
43
|
negative_prompt?: string;
|
|
25
44
|
aspect_ratio?: TextAspectRatio;
|
|
45
|
+
/** Fixed seed for reproducible generation. */
|
|
26
46
|
seed?: number;
|
|
47
|
+
/** Number of images to generate (only supported by imagen-4-fast). */
|
|
27
48
|
output_count?: OutputCount;
|
|
28
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Parameters for image remix -- guided generation from 1-8 source images
|
|
52
|
+
* combined with a text prompt. Supports resolution and format control.
|
|
53
|
+
*/
|
|
29
54
|
interface RemixImageParams {
|
|
30
55
|
model: Imagen4RemixModel;
|
|
31
56
|
prompt: string;
|
|
32
57
|
callback_url?: string;
|
|
58
|
+
/** 1-8 publicly accessible source image URLs. */
|
|
33
59
|
source_image_urls: string[];
|
|
34
60
|
aspect_ratio?: ProAspectRatio;
|
|
35
61
|
output_resolution?: OutputResolution;
|
|
@@ -40,8 +66,10 @@ interface TaskCreateResponse {
|
|
|
40
66
|
id: string;
|
|
41
67
|
status: AsyncTaskStatus;
|
|
42
68
|
}
|
|
69
|
+
/** A generated image with its CDN URL and optional unprocessed origin URL. */
|
|
43
70
|
interface Image {
|
|
44
71
|
url: string;
|
|
72
|
+
/** Unprocessed source URL when available (before CDN optimization). */
|
|
45
73
|
origin_url?: string;
|
|
46
74
|
}
|
|
47
75
|
interface TextToImageResponse {
|
|
@@ -51,6 +79,10 @@ interface TextToImageResponse {
|
|
|
51
79
|
error?: string;
|
|
52
80
|
[key: string]: unknown;
|
|
53
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolved response returned by `run()` after polling sees `status: 'completed'`.
|
|
84
|
+
* Narrows the base response so `images` is guaranteed non-optional.
|
|
85
|
+
*/
|
|
54
86
|
type CompletedTextToImageResponse = TextToImageResponse & {
|
|
55
87
|
status: 'completed';
|
|
56
88
|
images: Image[];
|
|
@@ -58,24 +90,87 @@ type CompletedTextToImageResponse = TextToImageResponse & {
|
|
|
58
90
|
type RemixImageResponse = TextToImageResponse;
|
|
59
91
|
type CompletedRemixImageResponse = CompletedTextToImageResponse;
|
|
60
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Generates images from a text prompt.
|
|
95
|
+
* Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency,
|
|
96
|
+
* batch output up to 4 images), and imagen-4-ultra (highest quality).
|
|
97
|
+
*/
|
|
61
98
|
declare class TextToImage {
|
|
62
99
|
private readonly http;
|
|
63
100
|
constructor(http: HttpClient);
|
|
101
|
+
/**
|
|
102
|
+
* Generate images from a text prompt and wait until complete.
|
|
103
|
+
* @param params Text-to-image parameters.
|
|
104
|
+
* @param options Per-request and polling overrides.
|
|
105
|
+
* @returns The completed task with images.
|
|
106
|
+
*/
|
|
64
107
|
run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Generate images from a text prompt; returns immediately with a task id.
|
|
110
|
+
* @param params Text-to-image parameters.
|
|
111
|
+
* @param options Per-request overrides.
|
|
112
|
+
* @returns The task creation result with id.
|
|
113
|
+
*/
|
|
65
114
|
create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Fetch the current status of a text-to-image task.
|
|
117
|
+
* @param id The task id.
|
|
118
|
+
* @param options Per-request overrides.
|
|
119
|
+
* @returns The current text-to-image task status.
|
|
120
|
+
*/
|
|
66
121
|
get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
|
|
67
122
|
}
|
|
68
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Generates new images guided by 1-8 source images combined with a text prompt.
|
|
126
|
+
* Supports output resolution control (1k/2k/4k) and format selection (png/jpg).
|
|
127
|
+
*/
|
|
69
128
|
declare class RemixImage {
|
|
70
129
|
private readonly http;
|
|
71
130
|
constructor(http: HttpClient);
|
|
131
|
+
/**
|
|
132
|
+
* Transform source images guided by a text prompt and wait until complete.
|
|
133
|
+
* @param params Remix-image parameters.
|
|
134
|
+
* @param options Per-request and polling overrides.
|
|
135
|
+
* @returns The completed task with images.
|
|
136
|
+
*/
|
|
72
137
|
run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Transform source images guided by a text prompt; returns immediately with a task id.
|
|
140
|
+
* @param params Remix-image parameters.
|
|
141
|
+
* @param options Per-request overrides.
|
|
142
|
+
* @returns The task creation result with id.
|
|
143
|
+
*/
|
|
73
144
|
create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Fetch the current status of a remix-image task.
|
|
147
|
+
* @param id The task id.
|
|
148
|
+
* @param options Per-request overrides.
|
|
149
|
+
* @returns The current remix-image task status.
|
|
150
|
+
*/
|
|
74
151
|
get(id: string, options?: RequestOptions): Promise<RemixImageResponse>;
|
|
75
152
|
}
|
|
76
153
|
|
|
77
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Imagen 4 image generation API client.
|
|
156
|
+
*
|
|
157
|
+
* Three text-to-image quality tiers (imagen-4, imagen-4-fast, imagen-4-ultra)
|
|
158
|
+
* and a dedicated remix model for guided image transformation from source images.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const client = new Imagen4Client({ apiKey: 'your-api-key' });
|
|
163
|
+
*
|
|
164
|
+
* const result = await client.textToImage.run({
|
|
165
|
+
* model: 'imagen-4',
|
|
166
|
+
* prompt: 'A cat in a spacesuit on the moon',
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
declare class Imagen4Client extends BaseClient {
|
|
171
|
+
/** Text-to-image generation across three quality tiers. */
|
|
78
172
|
readonly textToImage: TextToImage;
|
|
173
|
+
/** Generate new images guided by one or more source images combined with a text prompt. */
|
|
79
174
|
readonly remixImage: RemixImage;
|
|
80
175
|
constructor(options?: ClientOptions);
|
|
81
176
|
}
|
package/dist/index.js
CHANGED
|
@@ -43,12 +43,130 @@ var import_core3 = require("@runapi.ai/core");
|
|
|
43
43
|
// src/resources/text-to-image.ts
|
|
44
44
|
var import_core = require("@runapi.ai/core");
|
|
45
45
|
var import_internal = require("@runapi.ai/core/internal");
|
|
46
|
+
|
|
47
|
+
// src/contract_gen.ts
|
|
48
|
+
var contract = {
|
|
49
|
+
"remix-image": {
|
|
50
|
+
"models": [
|
|
51
|
+
"imagen-4-pro-remix-image"
|
|
52
|
+
],
|
|
53
|
+
"fields_by_model": {
|
|
54
|
+
"imagen-4-pro-remix-image": {
|
|
55
|
+
"aspect_ratio": {
|
|
56
|
+
"enum": [
|
|
57
|
+
"1:1",
|
|
58
|
+
"2:3",
|
|
59
|
+
"3:2",
|
|
60
|
+
"3:4",
|
|
61
|
+
"4:3",
|
|
62
|
+
"4:5",
|
|
63
|
+
"5:4",
|
|
64
|
+
"9:16",
|
|
65
|
+
"16:9",
|
|
66
|
+
"21:9",
|
|
67
|
+
"auto"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"output_format": {
|
|
71
|
+
"enum": [
|
|
72
|
+
"png",
|
|
73
|
+
"jpg"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"output_resolution": {
|
|
77
|
+
"enum": [
|
|
78
|
+
"1k",
|
|
79
|
+
"2k",
|
|
80
|
+
"4k"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"source_image_urls": {
|
|
84
|
+
"required": true
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"text-to-image": {
|
|
90
|
+
"models": [
|
|
91
|
+
"imagen-4",
|
|
92
|
+
"imagen-4-fast",
|
|
93
|
+
"imagen-4-ultra"
|
|
94
|
+
],
|
|
95
|
+
"fields_by_model": {
|
|
96
|
+
"imagen-4": {
|
|
97
|
+
"aspect_ratio": {
|
|
98
|
+
"enum": [
|
|
99
|
+
"1:1",
|
|
100
|
+
"16:9",
|
|
101
|
+
"9:16",
|
|
102
|
+
"3:4",
|
|
103
|
+
"4:3"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"output_count": {
|
|
107
|
+
"type": "integer"
|
|
108
|
+
},
|
|
109
|
+
"seed": {
|
|
110
|
+
"type": "integer"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"imagen-4-fast": {
|
|
114
|
+
"aspect_ratio": {
|
|
115
|
+
"enum": [
|
|
116
|
+
"1:1",
|
|
117
|
+
"16:9",
|
|
118
|
+
"9:16",
|
|
119
|
+
"3:4",
|
|
120
|
+
"4:3"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"output_count": {
|
|
124
|
+
"enum": [
|
|
125
|
+
1,
|
|
126
|
+
2,
|
|
127
|
+
3,
|
|
128
|
+
4
|
|
129
|
+
],
|
|
130
|
+
"type": "integer"
|
|
131
|
+
},
|
|
132
|
+
"seed": {
|
|
133
|
+
"type": "integer"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"imagen-4-ultra": {
|
|
137
|
+
"aspect_ratio": {
|
|
138
|
+
"enum": [
|
|
139
|
+
"1:1",
|
|
140
|
+
"16:9",
|
|
141
|
+
"9:16",
|
|
142
|
+
"3:4",
|
|
143
|
+
"4:3"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
"output_count": {
|
|
147
|
+
"type": "integer"
|
|
148
|
+
},
|
|
149
|
+
"seed": {
|
|
150
|
+
"type": "integer"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/resources/text-to-image.ts
|
|
46
158
|
var ENDPOINT = "/api/v1/imagen_4/text_to_image";
|
|
47
159
|
var TextToImage = class {
|
|
48
160
|
constructor(http) {
|
|
49
161
|
this.http = http;
|
|
50
162
|
}
|
|
51
163
|
http;
|
|
164
|
+
/**
|
|
165
|
+
* Generate images from a text prompt and wait until complete.
|
|
166
|
+
* @param params Text-to-image parameters.
|
|
167
|
+
* @param options Per-request and polling overrides.
|
|
168
|
+
* @returns The completed task with images.
|
|
169
|
+
*/
|
|
52
170
|
async run(params, options) {
|
|
53
171
|
const { id } = await this.create(params, options);
|
|
54
172
|
return (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -56,12 +174,26 @@ var TextToImage = class {
|
|
|
56
174
|
pollIntervalMs: options?.pollIntervalMs
|
|
57
175
|
});
|
|
58
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Generate images from a text prompt; returns immediately with a task id.
|
|
179
|
+
* @param params Text-to-image parameters.
|
|
180
|
+
* @param options Per-request overrides.
|
|
181
|
+
* @returns The task creation result with id.
|
|
182
|
+
*/
|
|
59
183
|
async create(params, options) {
|
|
184
|
+
const body = (0, import_core.compactParams)(params);
|
|
185
|
+
(0, import_core.validateParams)(contract["text-to-image"], body);
|
|
60
186
|
return this.http.request("POST", ENDPOINT, {
|
|
61
|
-
body
|
|
187
|
+
body,
|
|
62
188
|
...options
|
|
63
189
|
});
|
|
64
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Fetch the current status of a text-to-image task.
|
|
193
|
+
* @param id The task id.
|
|
194
|
+
* @param options Per-request overrides.
|
|
195
|
+
* @returns The current text-to-image task status.
|
|
196
|
+
*/
|
|
65
197
|
async get(id, options) {
|
|
66
198
|
return this.http.request("GET", `${ENDPOINT}/${id}`, {
|
|
67
199
|
...options
|
|
@@ -78,6 +210,12 @@ var RemixImage = class {
|
|
|
78
210
|
this.http = http;
|
|
79
211
|
}
|
|
80
212
|
http;
|
|
213
|
+
/**
|
|
214
|
+
* Transform source images guided by a text prompt and wait until complete.
|
|
215
|
+
* @param params Remix-image parameters.
|
|
216
|
+
* @param options Per-request and polling overrides.
|
|
217
|
+
* @returns The completed task with images.
|
|
218
|
+
*/
|
|
81
219
|
async run(params, options) {
|
|
82
220
|
const { id } = await this.create(params, options);
|
|
83
221
|
return (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -85,12 +223,26 @@ var RemixImage = class {
|
|
|
85
223
|
pollIntervalMs: options?.pollIntervalMs
|
|
86
224
|
});
|
|
87
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Transform source images guided by a text prompt; returns immediately with a task id.
|
|
228
|
+
* @param params Remix-image parameters.
|
|
229
|
+
* @param options Per-request overrides.
|
|
230
|
+
* @returns The task creation result with id.
|
|
231
|
+
*/
|
|
88
232
|
async create(params, options) {
|
|
233
|
+
const body = (0, import_core2.compactParams)(params);
|
|
234
|
+
(0, import_core2.validateParams)(contract["remix-image"], body);
|
|
89
235
|
return this.http.request("POST", ENDPOINT2, {
|
|
90
|
-
body
|
|
236
|
+
body,
|
|
91
237
|
...options
|
|
92
238
|
});
|
|
93
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Fetch the current status of a remix-image task.
|
|
242
|
+
* @param id The task id.
|
|
243
|
+
* @param options Per-request overrides.
|
|
244
|
+
* @returns The current remix-image task status.
|
|
245
|
+
*/
|
|
94
246
|
async get(id, options) {
|
|
95
247
|
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
96
248
|
...options
|
|
@@ -99,13 +251,15 @@ var RemixImage = class {
|
|
|
99
251
|
};
|
|
100
252
|
|
|
101
253
|
// src/client.ts
|
|
102
|
-
var Imagen4Client = class {
|
|
254
|
+
var Imagen4Client = class extends import_core3.BaseClient {
|
|
255
|
+
/** Text-to-image generation across three quality tiers. */
|
|
103
256
|
textToImage;
|
|
257
|
+
/** Generate new images guided by one or more source images combined with a text prompt. */
|
|
104
258
|
remixImage;
|
|
105
259
|
constructor(options = {}) {
|
|
106
|
-
|
|
107
|
-
this.textToImage = new TextToImage(http);
|
|
108
|
-
this.remixImage = new RemixImage(http);
|
|
260
|
+
super(options);
|
|
261
|
+
this.textToImage = new TextToImage(this.http);
|
|
262
|
+
this.remixImage = new RemixImage(this.http);
|
|
109
263
|
}
|
|
110
264
|
};
|
|
111
265
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;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,MAA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AAA,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.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 { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Imagen 4 image generation API client.\n *\n * Three text-to-image quality tiers (imagen-4, imagen-4-fast, imagen-4-ultra)\n * and a dedicated remix model for guided image transformation from source images.\n *\n * @example\n * ```typescript\n * const client = new Imagen4Client({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToImage.run({\n * model: 'imagen-4',\n * prompt: 'A cat in a spacesuit on the moon',\n * });\n * ```\n */\nexport class Imagen4Client extends BaseClient {\n /** Text-to-image generation across three quality tiers. */\n public readonly textToImage: TextToImage;\n /** Generate new images guided by one or more source images combined with a text prompt. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.remixImage = new RemixImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\n/**\n * Generates images from a text prompt.\n * Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency,\n * batch output up to 4 images), and imagen-4-ultra (highest quality).\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate images from a text prompt and wait until complete.\n * @param params Text-to-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\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 /**\n * Generate images from a text prompt; returns immediately with a task id.\n * @param params Text-to-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-image task status.\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 const contract = {\n \"remix-image\": {\n \"models\": [\n \"imagen-4-pro-remix-image\"\n ],\n \"fields_by_model\": {\n \"imagen-4-pro-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"imagen-4\",\n \"imagen-4-fast\",\n \"imagen-4-ultra\"\n ],\n \"fields_by_model\": {\n \"imagen-4\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-fast\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-ultra\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n }\n }\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { RemixImageParams, RemixImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/remix_image';\n\n/**\n * Generates new images guided by 1-8 source images combined with a text prompt.\n * Supports output resolution control (1k/2k/4k) and format selection (png/jpg).\n */\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Transform source images guided by a text prompt and wait until complete.\n * @param params Remix-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\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 /**\n * Transform source images guided by a text prompt; returns immediately with a task id.\n * @param params Remix-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['remix-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a remix-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current remix-image task status.\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,eAA+C;;;ACC/C,kBAA8C;AAC9C,sBAAkC;;;ACF3B,IAAM,WAAW;AAAA,EACtB,eAAe;AAAA,IACb,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,4BAA4B;AAAA,QAC1B,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAA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,IAA+B;AACvF,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACvE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AHnCO,IAAM,gBAAN,cAA4B,wBAAW;AAAA;AAAA,EAE5B;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,aAAa,IAAI,WAAW,KAAK,IAAI;AAAA,EAC5C;AACF;;;AD1BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,133 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
|
-
import {
|
|
2
|
+
import { BaseClient } from "@runapi.ai/core";
|
|
3
3
|
|
|
4
4
|
// src/resources/text-to-image.ts
|
|
5
|
-
import { compactParams } from "@runapi.ai/core";
|
|
5
|
+
import { compactParams, validateParams } from "@runapi.ai/core";
|
|
6
6
|
import { pollUntilComplete } from "@runapi.ai/core/internal";
|
|
7
|
+
|
|
8
|
+
// src/contract_gen.ts
|
|
9
|
+
var contract = {
|
|
10
|
+
"remix-image": {
|
|
11
|
+
"models": [
|
|
12
|
+
"imagen-4-pro-remix-image"
|
|
13
|
+
],
|
|
14
|
+
"fields_by_model": {
|
|
15
|
+
"imagen-4-pro-remix-image": {
|
|
16
|
+
"aspect_ratio": {
|
|
17
|
+
"enum": [
|
|
18
|
+
"1:1",
|
|
19
|
+
"2:3",
|
|
20
|
+
"3:2",
|
|
21
|
+
"3:4",
|
|
22
|
+
"4:3",
|
|
23
|
+
"4:5",
|
|
24
|
+
"5:4",
|
|
25
|
+
"9:16",
|
|
26
|
+
"16:9",
|
|
27
|
+
"21:9",
|
|
28
|
+
"auto"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"output_format": {
|
|
32
|
+
"enum": [
|
|
33
|
+
"png",
|
|
34
|
+
"jpg"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"output_resolution": {
|
|
38
|
+
"enum": [
|
|
39
|
+
"1k",
|
|
40
|
+
"2k",
|
|
41
|
+
"4k"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"source_image_urls": {
|
|
45
|
+
"required": true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"text-to-image": {
|
|
51
|
+
"models": [
|
|
52
|
+
"imagen-4",
|
|
53
|
+
"imagen-4-fast",
|
|
54
|
+
"imagen-4-ultra"
|
|
55
|
+
],
|
|
56
|
+
"fields_by_model": {
|
|
57
|
+
"imagen-4": {
|
|
58
|
+
"aspect_ratio": {
|
|
59
|
+
"enum": [
|
|
60
|
+
"1:1",
|
|
61
|
+
"16:9",
|
|
62
|
+
"9:16",
|
|
63
|
+
"3:4",
|
|
64
|
+
"4:3"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"output_count": {
|
|
68
|
+
"type": "integer"
|
|
69
|
+
},
|
|
70
|
+
"seed": {
|
|
71
|
+
"type": "integer"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"imagen-4-fast": {
|
|
75
|
+
"aspect_ratio": {
|
|
76
|
+
"enum": [
|
|
77
|
+
"1:1",
|
|
78
|
+
"16:9",
|
|
79
|
+
"9:16",
|
|
80
|
+
"3:4",
|
|
81
|
+
"4:3"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"output_count": {
|
|
85
|
+
"enum": [
|
|
86
|
+
1,
|
|
87
|
+
2,
|
|
88
|
+
3,
|
|
89
|
+
4
|
|
90
|
+
],
|
|
91
|
+
"type": "integer"
|
|
92
|
+
},
|
|
93
|
+
"seed": {
|
|
94
|
+
"type": "integer"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"imagen-4-ultra": {
|
|
98
|
+
"aspect_ratio": {
|
|
99
|
+
"enum": [
|
|
100
|
+
"1:1",
|
|
101
|
+
"16:9",
|
|
102
|
+
"9:16",
|
|
103
|
+
"3:4",
|
|
104
|
+
"4:3"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"output_count": {
|
|
108
|
+
"type": "integer"
|
|
109
|
+
},
|
|
110
|
+
"seed": {
|
|
111
|
+
"type": "integer"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/resources/text-to-image.ts
|
|
7
119
|
var ENDPOINT = "/api/v1/imagen_4/text_to_image";
|
|
8
120
|
var TextToImage = class {
|
|
9
121
|
constructor(http) {
|
|
10
122
|
this.http = http;
|
|
11
123
|
}
|
|
12
124
|
http;
|
|
125
|
+
/**
|
|
126
|
+
* Generate images from a text prompt and wait until complete.
|
|
127
|
+
* @param params Text-to-image parameters.
|
|
128
|
+
* @param options Per-request and polling overrides.
|
|
129
|
+
* @returns The completed task with images.
|
|
130
|
+
*/
|
|
13
131
|
async run(params, options) {
|
|
14
132
|
const { id } = await this.create(params, options);
|
|
15
133
|
return pollUntilComplete(() => this.get(id, options), {
|
|
@@ -17,12 +135,26 @@ var TextToImage = class {
|
|
|
17
135
|
pollIntervalMs: options?.pollIntervalMs
|
|
18
136
|
});
|
|
19
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Generate images from a text prompt; returns immediately with a task id.
|
|
140
|
+
* @param params Text-to-image parameters.
|
|
141
|
+
* @param options Per-request overrides.
|
|
142
|
+
* @returns The task creation result with id.
|
|
143
|
+
*/
|
|
20
144
|
async create(params, options) {
|
|
145
|
+
const body = compactParams(params);
|
|
146
|
+
validateParams(contract["text-to-image"], body);
|
|
21
147
|
return this.http.request("POST", ENDPOINT, {
|
|
22
|
-
body
|
|
148
|
+
body,
|
|
23
149
|
...options
|
|
24
150
|
});
|
|
25
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Fetch the current status of a text-to-image task.
|
|
154
|
+
* @param id The task id.
|
|
155
|
+
* @param options Per-request overrides.
|
|
156
|
+
* @returns The current text-to-image task status.
|
|
157
|
+
*/
|
|
26
158
|
async get(id, options) {
|
|
27
159
|
return this.http.request("GET", `${ENDPOINT}/${id}`, {
|
|
28
160
|
...options
|
|
@@ -31,7 +163,7 @@ var TextToImage = class {
|
|
|
31
163
|
};
|
|
32
164
|
|
|
33
165
|
// src/resources/remix-image.ts
|
|
34
|
-
import { compactParams as compactParams2 } from "@runapi.ai/core";
|
|
166
|
+
import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
|
|
35
167
|
import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
|
|
36
168
|
var ENDPOINT2 = "/api/v1/imagen_4/remix_image";
|
|
37
169
|
var RemixImage = class {
|
|
@@ -39,6 +171,12 @@ var RemixImage = class {
|
|
|
39
171
|
this.http = http;
|
|
40
172
|
}
|
|
41
173
|
http;
|
|
174
|
+
/**
|
|
175
|
+
* Transform source images guided by a text prompt and wait until complete.
|
|
176
|
+
* @param params Remix-image parameters.
|
|
177
|
+
* @param options Per-request and polling overrides.
|
|
178
|
+
* @returns The completed task with images.
|
|
179
|
+
*/
|
|
42
180
|
async run(params, options) {
|
|
43
181
|
const { id } = await this.create(params, options);
|
|
44
182
|
return pollUntilComplete2(() => this.get(id, options), {
|
|
@@ -46,12 +184,26 @@ var RemixImage = class {
|
|
|
46
184
|
pollIntervalMs: options?.pollIntervalMs
|
|
47
185
|
});
|
|
48
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Transform source images guided by a text prompt; returns immediately with a task id.
|
|
189
|
+
* @param params Remix-image parameters.
|
|
190
|
+
* @param options Per-request overrides.
|
|
191
|
+
* @returns The task creation result with id.
|
|
192
|
+
*/
|
|
49
193
|
async create(params, options) {
|
|
194
|
+
const body = compactParams2(params);
|
|
195
|
+
validateParams2(contract["remix-image"], body);
|
|
50
196
|
return this.http.request("POST", ENDPOINT2, {
|
|
51
|
-
body
|
|
197
|
+
body,
|
|
52
198
|
...options
|
|
53
199
|
});
|
|
54
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Fetch the current status of a remix-image task.
|
|
203
|
+
* @param id The task id.
|
|
204
|
+
* @param options Per-request overrides.
|
|
205
|
+
* @returns The current remix-image task status.
|
|
206
|
+
*/
|
|
55
207
|
async get(id, options) {
|
|
56
208
|
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
57
209
|
...options
|
|
@@ -60,13 +212,15 @@ var RemixImage = class {
|
|
|
60
212
|
};
|
|
61
213
|
|
|
62
214
|
// src/client.ts
|
|
63
|
-
var Imagen4Client = class {
|
|
215
|
+
var Imagen4Client = class extends BaseClient {
|
|
216
|
+
/** Text-to-image generation across three quality tiers. */
|
|
64
217
|
textToImage;
|
|
218
|
+
/** Generate new images guided by one or more source images combined with a text prompt. */
|
|
65
219
|
remixImage;
|
|
66
220
|
constructor(options = {}) {
|
|
67
|
-
|
|
68
|
-
this.textToImage = new TextToImage(http);
|
|
69
|
-
this.remixImage = new RemixImage(http);
|
|
221
|
+
super(options);
|
|
222
|
+
this.textToImage = new TextToImage(this.http);
|
|
223
|
+
this.remixImage = new RemixImage(this.http);
|
|
70
224
|
}
|
|
71
225
|
};
|
|
72
226
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,EACH;AACF;;;AC7BA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,qBAAAC,0BAAyB;AAGlC,IAAMC,YAAW;AAEV,IAAM,aAAN,MAAiB;AAAA,EACtB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA0B,SAAwE;AAC1G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,WAAOD,mBAAsC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACxE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,QAA0B,SAAuD;AAC5F,WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGE,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,OAAO,iBAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,aAAa,IAAI,WAAW,IAAI;AAAA,EACvC;AACF;;;AGRA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/remix-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Imagen 4 image generation API client.\n *\n * Three text-to-image quality tiers (imagen-4, imagen-4-fast, imagen-4-ultra)\n * and a dedicated remix model for guided image transformation from source images.\n *\n * @example\n * ```typescript\n * const client = new Imagen4Client({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToImage.run({\n * model: 'imagen-4',\n * prompt: 'A cat in a spacesuit on the moon',\n * });\n * ```\n */\nexport class Imagen4Client extends BaseClient {\n /** Text-to-image generation across three quality tiers. */\n public readonly textToImage: TextToImage;\n /** Generate new images guided by one or more source images combined with a text prompt. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.remixImage = new RemixImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\n/**\n * Generates images from a text prompt.\n * Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency,\n * batch output up to 4 images), and imagen-4-ultra (highest quality).\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate images from a text prompt and wait until complete.\n * @param params Text-to-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\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 /**\n * Generate images from a text prompt; returns immediately with a task id.\n * @param params Text-to-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-image task status.\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 const contract = {\n \"remix-image\": {\n \"models\": [\n \"imagen-4-pro-remix-image\"\n ],\n \"fields_by_model\": {\n \"imagen-4-pro-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"imagen-4\",\n \"imagen-4-fast\",\n \"imagen-4-ultra\"\n ],\n \"fields_by_model\": {\n \"imagen-4\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-fast\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-ultra\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n }\n }\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { RemixImageParams, RemixImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/remix_image';\n\n/**\n * Generates new images guided by 1-8 source images combined with a text prompt.\n * Supports output resolution control (1k/2k/4k) and format selection (png/jpg).\n */\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Transform source images guided by a text prompt and wait until complete.\n * @param params Remix-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\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 /**\n * Transform source images guided by a text prompt; returns immediately with a task id.\n * @param params Remix-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['remix-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a remix-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current remix-image task status.\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,kBAAsC;;;ACC/C,SAAS,eAAe,sBAAsB;AAC9C,SAAS,yBAAyB;;;ACF3B,IAAM,WAAW;AAAA,EACtB,eAAe;AAAA,IACb,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,4BAA4B;AAAA,QAC1B,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,YAAY;AAAA,QACV,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,gBAAgB;AAAA,UACd,QAAQ;AAAA,QACV;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,gBAAgB;AAAA,UACd,QAAQ;AAAA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AI;AAAA,EAC5C;AACF;;;AI1BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/imagen-4",
|
|
3
|
-
"
|
|
4
|
-
|
|
3
|
+
"runapi": {
|
|
4
|
+
"slug": "imagen-4"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.2.7",
|
|
7
|
+
"description": "RunAPI Imagen 4 SDK for text-to-image and remix-image workflows in JavaScript, Python, Ruby, Go, and Java",
|
|
5
8
|
"main": "./dist/index.js",
|
|
6
9
|
"module": "./dist/index.mjs",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
"clean": "rm -rf dist"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@runapi.ai/core": "^0.2.
|
|
33
|
+
"@runapi.ai/core": "^0.2.7"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@types/node": "^20.0.0",
|
|
@@ -46,8 +49,16 @@
|
|
|
46
49
|
"api",
|
|
47
50
|
"sdk",
|
|
48
51
|
"typescript",
|
|
52
|
+
"python",
|
|
49
53
|
"ruby",
|
|
50
|
-
"golang"
|
|
54
|
+
"golang",
|
|
55
|
+
"java",
|
|
56
|
+
"maven",
|
|
57
|
+
"gradle",
|
|
58
|
+
"image-generation",
|
|
59
|
+
"text-to-image",
|
|
60
|
+
"image-api",
|
|
61
|
+
"imagen-api"
|
|
51
62
|
],
|
|
52
63
|
"author": "RunAPI",
|
|
53
64
|
"license": "Apache-2.0",
|
|
@@ -55,5 +66,8 @@
|
|
|
55
66
|
"repository": {
|
|
56
67
|
"type": "git",
|
|
57
68
|
"url": "git+https://github.com/runapi-ai/imagen-4-sdk.git"
|
|
69
|
+
},
|
|
70
|
+
"bugs": {
|
|
71
|
+
"url": "https://github.com/runapi-ai/imagen-4-sdk/issues"
|
|
58
72
|
}
|
|
59
73
|
}
|