@runapi.ai/imagen-4 0.2.6 → 0.2.8

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
@@ -1,25 +1,25 @@
1
- # Imagen API JavaScript SDK for RunAPI
1
+ # Imagen 4 API JavaScript SDK for RunAPI
2
2
 
3
- The imagen api JavaScript SDK is the language-specific package for Imagen 4 on RunAPI. Use this imagen api package for text-to-image, image editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
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 imagen api README is the JavaScript package guide inside the public `imagen4-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/imagen-4; for API reference, use https://runapi.ai/docs#imagen-4; for SDK docs, use https://runapi.ai/docs#sdk-imagen-4.
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/imagen4
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/imagen4';
16
+ import { Imagen4Client } from '@runapi.ai/imagen-4';
17
17
 
18
18
  const client = new Imagen4Client();
19
- const task = await client.generations.create({
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.generations.get(task.id);
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.
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
30
 
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.
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.
32
32
 
33
33
  ## Links
34
34
 
package/dist/index.d.mts CHANGED
@@ -7,16 +7,18 @@ type Imagen4TextModel = 'imagen-4' | 'imagen-4-fast' | 'imagen-4-ultra';
7
7
  type Imagen4RemixModel = 'imagen-4-pro-remix-image';
8
8
  /** Union of all Imagen 4 model identifiers. */
9
9
  type Imagen4Model = Imagen4TextModel | Imagen4RemixModel;
10
+ /** Aspect ratios for standard and ultra text-to-image generation. */
11
+ type BaseTextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
12
+ /** Aspect ratios for fast text-to-image generation. */
13
+ type FastTextAspectRatio = BaseTextAspectRatio | 'auto';
10
14
  /** Aspect ratios for text-to-image generation. */
11
- type TextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
15
+ type TextAspectRatio = FastTextAspectRatio;
12
16
  /** Extended aspect ratios for remix, including "auto" which infers from source images. */
13
17
  type ProAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
14
18
  /** Pixel resolution tier for remix output. */
15
19
  type OutputResolution = '1k' | '2k' | '4k';
16
20
  /** Image encoding format for remix output. */
17
21
  type OutputFormat = 'png' | 'jpg';
18
- /** Batch size for imagen-4-fast (the only model supporting multi-image output). */
19
- type OutputCount = 1 | 2 | 3 | 4;
20
22
  /**
21
23
  * Parameters for imagen-4 (standard) and imagen-4-ultra (highest quality).
22
24
  * These models produce a single image per request.
@@ -27,25 +29,20 @@ interface BaseTextTextToImageParams {
27
29
  callback_url?: string;
28
30
  /** Content to steer the model away from in the output. */
29
31
  negative_prompt?: string;
30
- aspect_ratio?: TextAspectRatio;
32
+ aspect_ratio?: BaseTextAspectRatio;
31
33
  /** Fixed seed for reproducible generation. */
32
34
  seed?: number;
33
35
  }
34
- /**
35
- * Parameters for imagen-4-fast, which supports batch output (1-4 images)
36
- * at lower latency than the standard tier.
37
- */
36
+ /** Parameters for imagen-4-fast, the lower-latency text-to-image tier. */
38
37
  interface FastTextTextToImageParams {
39
38
  model: 'imagen-4-fast';
40
39
  prompt: string;
41
40
  callback_url?: string;
42
41
  /** Content to steer the model away from in the output. */
43
42
  negative_prompt?: string;
44
- aspect_ratio?: TextAspectRatio;
43
+ aspect_ratio?: FastTextAspectRatio;
45
44
  /** Fixed seed for reproducible generation. */
46
45
  seed?: number;
47
- /** Number of images to generate (only supported by imagen-4-fast). */
48
- output_count?: OutputCount;
49
46
  }
50
47
  /**
51
48
  * Parameters for image remix -- guided generation from 1-8 source images
@@ -92,8 +89,8 @@ type CompletedRemixImageResponse = CompletedTextToImageResponse;
92
89
 
93
90
  /**
94
91
  * 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).
92
+ * Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency),
93
+ * and imagen-4-ultra (highest quality).
97
94
  */
98
95
  declare class TextToImage {
99
96
  private readonly http;
@@ -175,4 +172,4 @@ declare class Imagen4Client extends BaseClient {
175
172
  constructor(options?: ClientOptions);
176
173
  }
177
174
 
178
- export { type BaseTextTextToImageParams, type CompletedRemixImageResponse, type CompletedTextToImageResponse, type FastTextTextToImageParams, type Image, Imagen4Client, type Imagen4Model, type Imagen4RemixModel, type Imagen4TextModel, type OutputCount, type OutputFormat, type OutputResolution, type ProAspectRatio, RemixImage, type RemixImageParams, type RemixImageResponse, type TaskCreateResponse, type TextAspectRatio, TextToImage, type TextToImageParams, type TextToImageResponse };
175
+ export { type BaseTextAspectRatio, type BaseTextTextToImageParams, type CompletedRemixImageResponse, type CompletedTextToImageResponse, type FastTextAspectRatio, type FastTextTextToImageParams, type Image, Imagen4Client, type Imagen4Model, type Imagen4RemixModel, type Imagen4TextModel, type OutputFormat, type OutputResolution, type ProAspectRatio, RemixImage, type RemixImageParams, type RemixImageResponse, type TaskCreateResponse, type TextAspectRatio, TextToImage, type TextToImageParams, type TextToImageResponse };
package/dist/index.d.ts CHANGED
@@ -7,16 +7,18 @@ type Imagen4TextModel = 'imagen-4' | 'imagen-4-fast' | 'imagen-4-ultra';
7
7
  type Imagen4RemixModel = 'imagen-4-pro-remix-image';
8
8
  /** Union of all Imagen 4 model identifiers. */
9
9
  type Imagen4Model = Imagen4TextModel | Imagen4RemixModel;
10
+ /** Aspect ratios for standard and ultra text-to-image generation. */
11
+ type BaseTextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
12
+ /** Aspect ratios for fast text-to-image generation. */
13
+ type FastTextAspectRatio = BaseTextAspectRatio | 'auto';
10
14
  /** Aspect ratios for text-to-image generation. */
11
- type TextAspectRatio = '1:1' | '16:9' | '9:16' | '3:4' | '4:3';
15
+ type TextAspectRatio = FastTextAspectRatio;
12
16
  /** Extended aspect ratios for remix, including "auto" which infers from source images. */
13
17
  type ProAspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
14
18
  /** Pixel resolution tier for remix output. */
15
19
  type OutputResolution = '1k' | '2k' | '4k';
16
20
  /** Image encoding format for remix output. */
17
21
  type OutputFormat = 'png' | 'jpg';
18
- /** Batch size for imagen-4-fast (the only model supporting multi-image output). */
19
- type OutputCount = 1 | 2 | 3 | 4;
20
22
  /**
21
23
  * Parameters for imagen-4 (standard) and imagen-4-ultra (highest quality).
22
24
  * These models produce a single image per request.
@@ -27,25 +29,20 @@ interface BaseTextTextToImageParams {
27
29
  callback_url?: string;
28
30
  /** Content to steer the model away from in the output. */
29
31
  negative_prompt?: string;
30
- aspect_ratio?: TextAspectRatio;
32
+ aspect_ratio?: BaseTextAspectRatio;
31
33
  /** Fixed seed for reproducible generation. */
32
34
  seed?: number;
33
35
  }
34
- /**
35
- * Parameters for imagen-4-fast, which supports batch output (1-4 images)
36
- * at lower latency than the standard tier.
37
- */
36
+ /** Parameters for imagen-4-fast, the lower-latency text-to-image tier. */
38
37
  interface FastTextTextToImageParams {
39
38
  model: 'imagen-4-fast';
40
39
  prompt: string;
41
40
  callback_url?: string;
42
41
  /** Content to steer the model away from in the output. */
43
42
  negative_prompt?: string;
44
- aspect_ratio?: TextAspectRatio;
43
+ aspect_ratio?: FastTextAspectRatio;
45
44
  /** Fixed seed for reproducible generation. */
46
45
  seed?: number;
47
- /** Number of images to generate (only supported by imagen-4-fast). */
48
- output_count?: OutputCount;
49
46
  }
50
47
  /**
51
48
  * Parameters for image remix -- guided generation from 1-8 source images
@@ -92,8 +89,8 @@ type CompletedRemixImageResponse = CompletedTextToImageResponse;
92
89
 
93
90
  /**
94
91
  * 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).
92
+ * Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency),
93
+ * and imagen-4-ultra (highest quality).
97
94
  */
98
95
  declare class TextToImage {
99
96
  private readonly http;
@@ -175,4 +172,4 @@ declare class Imagen4Client extends BaseClient {
175
172
  constructor(options?: ClientOptions);
176
173
  }
177
174
 
178
- export { type BaseTextTextToImageParams, type CompletedRemixImageResponse, type CompletedTextToImageResponse, type FastTextTextToImageParams, type Image, Imagen4Client, type Imagen4Model, type Imagen4RemixModel, type Imagen4TextModel, type OutputCount, type OutputFormat, type OutputResolution, type ProAspectRatio, RemixImage, type RemixImageParams, type RemixImageResponse, type TaskCreateResponse, type TextAspectRatio, TextToImage, type TextToImageParams, type TextToImageResponse };
175
+ export { type BaseTextAspectRatio, type BaseTextTextToImageParams, type CompletedRemixImageResponse, type CompletedTextToImageResponse, type FastTextAspectRatio, type FastTextTextToImageParams, type Image, Imagen4Client, type Imagen4Model, type Imagen4RemixModel, type Imagen4TextModel, type OutputFormat, type OutputResolution, type ProAspectRatio, RemixImage, type RemixImageParams, type RemixImageResponse, type TaskCreateResponse, type TextAspectRatio, TextToImage, type TextToImageParams, type TextToImageResponse };
package/dist/index.js CHANGED
@@ -43,6 +43,104 @@ 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
+ "seed": {
107
+ "type": "integer"
108
+ }
109
+ },
110
+ "imagen-4-fast": {
111
+ "aspect_ratio": {
112
+ "enum": [
113
+ "1:1",
114
+ "16:9",
115
+ "9:16",
116
+ "3:4",
117
+ "4:3",
118
+ "auto"
119
+ ]
120
+ },
121
+ "seed": {
122
+ "type": "integer"
123
+ }
124
+ },
125
+ "imagen-4-ultra": {
126
+ "aspect_ratio": {
127
+ "enum": [
128
+ "1:1",
129
+ "16:9",
130
+ "9:16",
131
+ "3:4",
132
+ "4:3"
133
+ ]
134
+ },
135
+ "seed": {
136
+ "type": "integer"
137
+ }
138
+ }
139
+ }
140
+ }
141
+ };
142
+
143
+ // src/resources/text-to-image.ts
46
144
  var ENDPOINT = "/api/v1/imagen_4/text_to_image";
47
145
  var TextToImage = class {
48
146
  constructor(http) {
@@ -69,8 +167,10 @@ var TextToImage = class {
69
167
  * @returns The task creation result with id.
70
168
  */
71
169
  async create(params, options) {
170
+ const body = (0, import_core.compactParams)(params);
171
+ (0, import_core.validateParams)(contract["text-to-image"], body);
72
172
  return this.http.request("POST", ENDPOINT, {
73
- body: (0, import_core.compactParams)(params),
173
+ body,
74
174
  ...options
75
175
  });
76
176
  }
@@ -116,8 +216,10 @@ var RemixImage = class {
116
216
  * @returns The task creation result with id.
117
217
  */
118
218
  async create(params, options) {
219
+ const body = (0, import_core2.compactParams)(params);
220
+ (0, import_core2.validateParams)(contract["remix-image"], body);
119
221
  return this.http.request("POST", ENDPOINT2, {
120
- body: (0, import_core2.compactParams)(params),
222
+ body,
121
223
  ...options
122
224
  });
123
225
  }
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 { 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"]}
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 * 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 \"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 \"auto\"\n ]\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 \"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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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,UAAM,WAAO,4BAAc,MAAM;AACjC,qCAAe,SAAS,aAAa,GAAmB,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
@@ -2,8 +2,106 @@
2
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
+ "seed": {
68
+ "type": "integer"
69
+ }
70
+ },
71
+ "imagen-4-fast": {
72
+ "aspect_ratio": {
73
+ "enum": [
74
+ "1:1",
75
+ "16:9",
76
+ "9:16",
77
+ "3:4",
78
+ "4:3",
79
+ "auto"
80
+ ]
81
+ },
82
+ "seed": {
83
+ "type": "integer"
84
+ }
85
+ },
86
+ "imagen-4-ultra": {
87
+ "aspect_ratio": {
88
+ "enum": [
89
+ "1:1",
90
+ "16:9",
91
+ "9:16",
92
+ "3:4",
93
+ "4:3"
94
+ ]
95
+ },
96
+ "seed": {
97
+ "type": "integer"
98
+ }
99
+ }
100
+ }
101
+ }
102
+ };
103
+
104
+ // src/resources/text-to-image.ts
7
105
  var ENDPOINT = "/api/v1/imagen_4/text_to_image";
8
106
  var TextToImage = class {
9
107
  constructor(http) {
@@ -30,8 +128,10 @@ var TextToImage = class {
30
128
  * @returns The task creation result with id.
31
129
  */
32
130
  async create(params, options) {
131
+ const body = compactParams(params);
132
+ validateParams(contract["text-to-image"], body);
33
133
  return this.http.request("POST", ENDPOINT, {
34
- body: compactParams(params),
134
+ body,
35
135
  ...options
36
136
  });
37
137
  }
@@ -49,7 +149,7 @@ var TextToImage = class {
49
149
  };
50
150
 
51
151
  // src/resources/remix-image.ts
52
- import { compactParams as compactParams2 } from "@runapi.ai/core";
152
+ import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
53
153
  import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
54
154
  var ENDPOINT2 = "/api/v1/imagen_4/remix_image";
55
155
  var RemixImage = class {
@@ -77,8 +177,10 @@ var RemixImage = class {
77
177
  * @returns The task creation result with id.
78
178
  */
79
179
  async create(params, options) {
180
+ const body = compactParams2(params);
181
+ validateParams2(contract["remix-image"], body);
80
182
  return this.http.request("POST", ENDPOINT2, {
81
- body: compactParams2(params),
183
+ body,
82
184
  ...options
83
185
  });
84
186
  }
@@ -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 { 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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AC7D,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"]}
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 * 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 \"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 \"auto\"\n ]\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 \"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,Y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a,GAAmB,IAA+B;AACvF,WAAO,KAAK,KAAK,QAA4B,QAAQH,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,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;;;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
- "version": "0.2.6",
4
- "description": "RunAPI Imagen 4 SDK for JavaScript, Ruby, and Go",
3
+ "runapi": {
4
+ "slug": "imagen-4"
5
+ },
6
+ "version": "0.2.8",
7
+ "description": "RunAPI Imagen 4 SDK for text-to-image and remix-image workflows in JavaScript, Python, Ruby, Go, Java, and PHP",
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.6"
33
+ "@runapi.ai/core": "^0.2.10"
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
  }