@runapi.ai/imagen-4 0.2.5 → 0.2.6

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 CHANGED
@@ -24,6 +24,8 @@ const status = await client.generations.get(task.id);
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
31
  Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources include generations. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
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
- declare class Imagen4Client {
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
- declare class Imagen4Client {
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
@@ -49,6 +49,12 @@ var TextToImage = class {
49
49
  this.http = http;
50
50
  }
51
51
  http;
52
+ /**
53
+ * Generate images from a text prompt and wait until complete.
54
+ * @param params Text-to-image parameters.
55
+ * @param options Per-request and polling overrides.
56
+ * @returns The completed task with images.
57
+ */
52
58
  async run(params, options) {
53
59
  const { id } = await this.create(params, options);
54
60
  return (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
@@ -56,12 +62,24 @@ var TextToImage = class {
56
62
  pollIntervalMs: options?.pollIntervalMs
57
63
  });
58
64
  }
65
+ /**
66
+ * Generate images from a text prompt; returns immediately with a task id.
67
+ * @param params Text-to-image parameters.
68
+ * @param options Per-request overrides.
69
+ * @returns The task creation result with id.
70
+ */
59
71
  async create(params, options) {
60
72
  return this.http.request("POST", ENDPOINT, {
61
73
  body: (0, import_core.compactParams)(params),
62
74
  ...options
63
75
  });
64
76
  }
77
+ /**
78
+ * Fetch the current status of a text-to-image task.
79
+ * @param id The task id.
80
+ * @param options Per-request overrides.
81
+ * @returns The current text-to-image task status.
82
+ */
65
83
  async get(id, options) {
66
84
  return this.http.request("GET", `${ENDPOINT}/${id}`, {
67
85
  ...options
@@ -78,6 +96,12 @@ var RemixImage = class {
78
96
  this.http = http;
79
97
  }
80
98
  http;
99
+ /**
100
+ * Transform source images guided by a text prompt and wait until complete.
101
+ * @param params Remix-image parameters.
102
+ * @param options Per-request and polling overrides.
103
+ * @returns The completed task with images.
104
+ */
81
105
  async run(params, options) {
82
106
  const { id } = await this.create(params, options);
83
107
  return (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
@@ -85,12 +109,24 @@ var RemixImage = class {
85
109
  pollIntervalMs: options?.pollIntervalMs
86
110
  });
87
111
  }
112
+ /**
113
+ * Transform source images guided by a text prompt; returns immediately with a task id.
114
+ * @param params Remix-image parameters.
115
+ * @param options Per-request overrides.
116
+ * @returns The task creation result with id.
117
+ */
88
118
  async create(params, options) {
89
119
  return this.http.request("POST", ENDPOINT2, {
90
120
  body: (0, import_core2.compactParams)(params),
91
121
  ...options
92
122
  });
93
123
  }
124
+ /**
125
+ * Fetch the current status of a remix-image task.
126
+ * @param id The task id.
127
+ * @param options Per-request overrides.
128
+ * @returns The current remix-image task status.
129
+ */
94
130
  async get(id, options) {
95
131
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
96
132
  ...options
@@ -99,13 +135,15 @@ var RemixImage = class {
99
135
  };
100
136
 
101
137
  // src/client.ts
102
- var Imagen4Client = class {
138
+ var Imagen4Client = class extends import_core3.BaseClient {
139
+ /** Text-to-image generation across three quality tiers. */
103
140
  textToImage;
141
+ /** Generate new images guided by one or more source images combined with a text prompt. */
104
142
  remixImage;
105
143
  constructor(options = {}) {
106
- const http = (0, import_core3.createHttpClient)(options);
107
- this.textToImage = new TextToImage(http);
108
- this.remixImage = new RemixImage(http);
144
+ super(options);
145
+ this.textToImage = new TextToImage(this.http);
146
+ this.remixImage = new RemixImage(this.http);
109
147
  }
110
148
  };
111
149
 
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,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;;;AC7BA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;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,eAAO,oCAAsC,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,QAAQA,WAAU;AAAA,MAC7D,UAAM,4BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,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"]}
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 { 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 } 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\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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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","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\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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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,kBAA8B;AAC9B,sBAAkC;AAGlC,IAAM,WAAW;AAOV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACpDA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;AAGlC,IAAMC,YAAW;AAMV,IAAM,aAAN,MAAiB;AAAA,EACtB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA0B,SAAwE;AAC1G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,eAAO,oCAAsC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACxE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA0B,SAAuD;AAC5F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D,UAAM,4BAAc,MAAM;AAAA,MAC1B,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;;;AFhCO,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,5 +1,5 @@
1
1
  // src/client.ts
2
- import { createHttpClient } from "@runapi.ai/core";
2
+ import { BaseClient } from "@runapi.ai/core";
3
3
 
4
4
  // src/resources/text-to-image.ts
5
5
  import { compactParams } from "@runapi.ai/core";
@@ -10,6 +10,12 @@ var TextToImage = class {
10
10
  this.http = http;
11
11
  }
12
12
  http;
13
+ /**
14
+ * Generate images from a text prompt and wait until complete.
15
+ * @param params Text-to-image parameters.
16
+ * @param options Per-request and polling overrides.
17
+ * @returns The completed task with images.
18
+ */
13
19
  async run(params, options) {
14
20
  const { id } = await this.create(params, options);
15
21
  return pollUntilComplete(() => this.get(id, options), {
@@ -17,12 +23,24 @@ var TextToImage = class {
17
23
  pollIntervalMs: options?.pollIntervalMs
18
24
  });
19
25
  }
26
+ /**
27
+ * Generate images from a text prompt; returns immediately with a task id.
28
+ * @param params Text-to-image parameters.
29
+ * @param options Per-request overrides.
30
+ * @returns The task creation result with id.
31
+ */
20
32
  async create(params, options) {
21
33
  return this.http.request("POST", ENDPOINT, {
22
34
  body: compactParams(params),
23
35
  ...options
24
36
  });
25
37
  }
38
+ /**
39
+ * Fetch the current status of a text-to-image task.
40
+ * @param id The task id.
41
+ * @param options Per-request overrides.
42
+ * @returns The current text-to-image task status.
43
+ */
26
44
  async get(id, options) {
27
45
  return this.http.request("GET", `${ENDPOINT}/${id}`, {
28
46
  ...options
@@ -39,6 +57,12 @@ var RemixImage = class {
39
57
  this.http = http;
40
58
  }
41
59
  http;
60
+ /**
61
+ * Transform source images guided by a text prompt and wait until complete.
62
+ * @param params Remix-image parameters.
63
+ * @param options Per-request and polling overrides.
64
+ * @returns The completed task with images.
65
+ */
42
66
  async run(params, options) {
43
67
  const { id } = await this.create(params, options);
44
68
  return pollUntilComplete2(() => this.get(id, options), {
@@ -46,12 +70,24 @@ var RemixImage = class {
46
70
  pollIntervalMs: options?.pollIntervalMs
47
71
  });
48
72
  }
73
+ /**
74
+ * Transform source images guided by a text prompt; returns immediately with a task id.
75
+ * @param params Remix-image parameters.
76
+ * @param options Per-request overrides.
77
+ * @returns The task creation result with id.
78
+ */
49
79
  async create(params, options) {
50
80
  return this.http.request("POST", ENDPOINT2, {
51
81
  body: compactParams2(params),
52
82
  ...options
53
83
  });
54
84
  }
85
+ /**
86
+ * Fetch the current status of a remix-image task.
87
+ * @param id The task id.
88
+ * @param options Per-request overrides.
89
+ * @returns The current remix-image task status.
90
+ */
55
91
  async get(id, options) {
56
92
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
57
93
  ...options
@@ -60,13 +96,15 @@ var RemixImage = class {
60
96
  };
61
97
 
62
98
  // src/client.ts
63
- var Imagen4Client = class {
99
+ var Imagen4Client = class extends BaseClient {
100
+ /** Text-to-image generation across three quality tiers. */
64
101
  textToImage;
102
+ /** Generate new images guided by one or more source images combined with a text prompt. */
65
103
  remixImage;
66
104
  constructor(options = {}) {
67
- const http = createHttpClient(options);
68
- this.textToImage = new TextToImage(http);
69
- this.remixImage = new RemixImage(http);
105
+ super(options);
106
+ this.textToImage = new TextToImage(this.http);
107
+ this.remixImage = new RemixImage(this.http);
70
108
  }
71
109
  };
72
110
 
@@ -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/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 } 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\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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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","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\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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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,qBAAqB;AAC9B,SAAS,yBAAyB;AAGlC,IAAM,WAAW;AAOV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACpDA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,qBAAAC,0BAAyB;AAGlC,IAAMC,YAAW;AAMV,IAAM,aAAN,MAAiB;AAAA,EACtB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MACvE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFhCO,IAAM,gBAAN,cAA4B,WAAW;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;;;AG1BA;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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runapi.ai/imagen-4",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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.5"
30
+ "@runapi.ai/core": "^0.2.6"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^20.0.0",