@runapi.ai/imagen-4 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.js +118 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -4
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
|
|
3
|
+
The Imagen 4 JavaScript SDK is the language-specific package for Imagen 4 on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
|
|
4
4
|
|
|
5
|
-
This
|
|
5
|
+
This README is the JavaScript package guide inside the public `imagen-4-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/imagen-4; for API reference, use https://runapi.ai/docs#imagen-4; for SDK docs, use https://runapi.ai/docs#sdk-imagen-4.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @runapi.ai/
|
|
10
|
+
npm install @runapi.ai/imagen-4
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { Imagen4Client } from '@runapi.ai/
|
|
16
|
+
import { Imagen4Client } from '@runapi.ai/imagen-4';
|
|
17
17
|
|
|
18
18
|
const client = new Imagen4Client();
|
|
19
|
-
const task = await client.
|
|
19
|
+
const task = await client.textToImage.create({
|
|
20
20
|
// Pass the Imagen 4 JSON request body from https://runapi.ai/docs#imagen-4.
|
|
21
21
|
});
|
|
22
|
-
const status = await client.
|
|
22
|
+
const status = await client.textToImage.get(task.id);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
|
|
@@ -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
|
|
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.js
CHANGED
|
@@ -43,6 +43,118 @@ var import_core3 = require("@runapi.ai/core");
|
|
|
43
43
|
// src/resources/text-to-image.ts
|
|
44
44
|
var import_core = require("@runapi.ai/core");
|
|
45
45
|
var import_internal = require("@runapi.ai/core/internal");
|
|
46
|
+
|
|
47
|
+
// src/contract_gen.ts
|
|
48
|
+
var contract = {
|
|
49
|
+
"remix-image": {
|
|
50
|
+
"models": [
|
|
51
|
+
"imagen-4-pro-remix-image"
|
|
52
|
+
],
|
|
53
|
+
"fields_by_model": {
|
|
54
|
+
"imagen-4-pro-remix-image": {
|
|
55
|
+
"aspect_ratio": {
|
|
56
|
+
"enum": [
|
|
57
|
+
"1:1",
|
|
58
|
+
"2:3",
|
|
59
|
+
"3:2",
|
|
60
|
+
"3:4",
|
|
61
|
+
"4:3",
|
|
62
|
+
"4:5",
|
|
63
|
+
"5:4",
|
|
64
|
+
"9:16",
|
|
65
|
+
"16:9",
|
|
66
|
+
"21:9",
|
|
67
|
+
"auto"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"output_format": {
|
|
71
|
+
"enum": [
|
|
72
|
+
"png",
|
|
73
|
+
"jpg"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"output_resolution": {
|
|
77
|
+
"enum": [
|
|
78
|
+
"1k",
|
|
79
|
+
"2k",
|
|
80
|
+
"4k"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"source_image_urls": {
|
|
84
|
+
"required": true
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"text-to-image": {
|
|
90
|
+
"models": [
|
|
91
|
+
"imagen-4",
|
|
92
|
+
"imagen-4-fast",
|
|
93
|
+
"imagen-4-ultra"
|
|
94
|
+
],
|
|
95
|
+
"fields_by_model": {
|
|
96
|
+
"imagen-4": {
|
|
97
|
+
"aspect_ratio": {
|
|
98
|
+
"enum": [
|
|
99
|
+
"1:1",
|
|
100
|
+
"16:9",
|
|
101
|
+
"9:16",
|
|
102
|
+
"3:4",
|
|
103
|
+
"4:3"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"output_count": {
|
|
107
|
+
"type": "integer"
|
|
108
|
+
},
|
|
109
|
+
"seed": {
|
|
110
|
+
"type": "integer"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"imagen-4-fast": {
|
|
114
|
+
"aspect_ratio": {
|
|
115
|
+
"enum": [
|
|
116
|
+
"1:1",
|
|
117
|
+
"16:9",
|
|
118
|
+
"9:16",
|
|
119
|
+
"3:4",
|
|
120
|
+
"4:3"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"output_count": {
|
|
124
|
+
"enum": [
|
|
125
|
+
1,
|
|
126
|
+
2,
|
|
127
|
+
3,
|
|
128
|
+
4
|
|
129
|
+
],
|
|
130
|
+
"type": "integer"
|
|
131
|
+
},
|
|
132
|
+
"seed": {
|
|
133
|
+
"type": "integer"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"imagen-4-ultra": {
|
|
137
|
+
"aspect_ratio": {
|
|
138
|
+
"enum": [
|
|
139
|
+
"1:1",
|
|
140
|
+
"16:9",
|
|
141
|
+
"9:16",
|
|
142
|
+
"3:4",
|
|
143
|
+
"4:3"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
"output_count": {
|
|
147
|
+
"type": "integer"
|
|
148
|
+
},
|
|
149
|
+
"seed": {
|
|
150
|
+
"type": "integer"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/resources/text-to-image.ts
|
|
46
158
|
var ENDPOINT = "/api/v1/imagen_4/text_to_image";
|
|
47
159
|
var TextToImage = class {
|
|
48
160
|
constructor(http) {
|
|
@@ -69,8 +181,10 @@ var TextToImage = class {
|
|
|
69
181
|
* @returns The task creation result with id.
|
|
70
182
|
*/
|
|
71
183
|
async create(params, options) {
|
|
184
|
+
const body = (0, import_core.compactParams)(params);
|
|
185
|
+
(0, import_core.validateParams)(contract["text-to-image"], body);
|
|
72
186
|
return this.http.request("POST", ENDPOINT, {
|
|
73
|
-
body
|
|
187
|
+
body,
|
|
74
188
|
...options
|
|
75
189
|
});
|
|
76
190
|
}
|
|
@@ -116,8 +230,10 @@ var RemixImage = class {
|
|
|
116
230
|
* @returns The task creation result with id.
|
|
117
231
|
*/
|
|
118
232
|
async create(params, options) {
|
|
233
|
+
const body = (0, import_core2.compactParams)(params);
|
|
234
|
+
(0, import_core2.validateParams)(contract["remix-image"], body);
|
|
119
235
|
return this.http.request("POST", ENDPOINT2, {
|
|
120
|
-
body
|
|
236
|
+
body,
|
|
121
237
|
...options
|
|
122
238
|
});
|
|
123
239
|
}
|
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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A;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 * batch output up to 4 images), and imagen-4-ultra (highest quality).\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate images from a text prompt and wait until complete.\n * @param params Text-to-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n /**\n * Generate images from a text prompt; returns immediately with a task id.\n * @param params Text-to-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-image task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export const contract = {\n \"remix-image\": {\n \"models\": [\n \"imagen-4-pro-remix-image\"\n ],\n \"fields_by_model\": {\n \"imagen-4-pro-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"imagen-4\",\n \"imagen-4-fast\",\n \"imagen-4-ultra\"\n ],\n \"fields_by_model\": {\n \"imagen-4\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-fast\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-ultra\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n }\n }\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { RemixImageParams, RemixImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/remix_image';\n\n/**\n * Generates new images guided by 1-8 source images combined with a text prompt.\n * Supports output resolution control (1k/2k/4k) and format selection (png/jpg).\n */\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Transform source images guided by a text prompt and wait until complete.\n * @param params Remix-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\n */\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n /**\n * Transform source images guided by a text prompt; returns immediately with a task id.\n * @param params Remix-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['remix-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a remix-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current remix-image task status.\n */\n async get(id: string, options?: RequestOptions): Promise<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA8C;AAC9C,sBAAkC;;;ACF3B,IAAM,WAAW;AAAA,EACtB,eAAe;AAAA,IACb,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,4BAA4B;AAAA,QAC1B,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,YAAY;AAAA,QACV,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,gBAAgB;AAAA,UACd,QAAQ;AAAA,QACV;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,MACA,iBAAiB;AAA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AAI;AAAA,EAC5C;AACF;;;AD1BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,120 @@
|
|
|
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
|
+
"output_count": {
|
|
68
|
+
"type": "integer"
|
|
69
|
+
},
|
|
70
|
+
"seed": {
|
|
71
|
+
"type": "integer"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"imagen-4-fast": {
|
|
75
|
+
"aspect_ratio": {
|
|
76
|
+
"enum": [
|
|
77
|
+
"1:1",
|
|
78
|
+
"16:9",
|
|
79
|
+
"9:16",
|
|
80
|
+
"3:4",
|
|
81
|
+
"4:3"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"output_count": {
|
|
85
|
+
"enum": [
|
|
86
|
+
1,
|
|
87
|
+
2,
|
|
88
|
+
3,
|
|
89
|
+
4
|
|
90
|
+
],
|
|
91
|
+
"type": "integer"
|
|
92
|
+
},
|
|
93
|
+
"seed": {
|
|
94
|
+
"type": "integer"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"imagen-4-ultra": {
|
|
98
|
+
"aspect_ratio": {
|
|
99
|
+
"enum": [
|
|
100
|
+
"1:1",
|
|
101
|
+
"16:9",
|
|
102
|
+
"9:16",
|
|
103
|
+
"3:4",
|
|
104
|
+
"4:3"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"output_count": {
|
|
108
|
+
"type": "integer"
|
|
109
|
+
},
|
|
110
|
+
"seed": {
|
|
111
|
+
"type": "integer"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/resources/text-to-image.ts
|
|
7
119
|
var ENDPOINT = "/api/v1/imagen_4/text_to_image";
|
|
8
120
|
var TextToImage = class {
|
|
9
121
|
constructor(http) {
|
|
@@ -30,8 +142,10 @@ var TextToImage = class {
|
|
|
30
142
|
* @returns The task creation result with id.
|
|
31
143
|
*/
|
|
32
144
|
async create(params, options) {
|
|
145
|
+
const body = compactParams(params);
|
|
146
|
+
validateParams(contract["text-to-image"], body);
|
|
33
147
|
return this.http.request("POST", ENDPOINT, {
|
|
34
|
-
body
|
|
148
|
+
body,
|
|
35
149
|
...options
|
|
36
150
|
});
|
|
37
151
|
}
|
|
@@ -49,7 +163,7 @@ var TextToImage = class {
|
|
|
49
163
|
};
|
|
50
164
|
|
|
51
165
|
// src/resources/remix-image.ts
|
|
52
|
-
import { compactParams as compactParams2 } from "@runapi.ai/core";
|
|
166
|
+
import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
|
|
53
167
|
import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
|
|
54
168
|
var ENDPOINT2 = "/api/v1/imagen_4/remix_image";
|
|
55
169
|
var RemixImage = class {
|
|
@@ -77,8 +191,10 @@ var RemixImage = class {
|
|
|
77
191
|
* @returns The task creation result with id.
|
|
78
192
|
*/
|
|
79
193
|
async create(params, options) {
|
|
194
|
+
const body = compactParams2(params);
|
|
195
|
+
validateParams2(contract["remix-image"], body);
|
|
80
196
|
return this.http.request("POST", ENDPOINT2, {
|
|
81
|
-
body
|
|
197
|
+
body,
|
|
82
198
|
...options
|
|
83
199
|
});
|
|
84
200
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/resources/remix-image.ts","../src/index.ts"],"sourcesContent":["import { 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/remix-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Imagen 4 image generation API client.\n *\n * Three text-to-image quality tiers (imagen-4, imagen-4-fast, imagen-4-ultra)\n * and a dedicated remix model for guided image transformation from source images.\n *\n * @example\n * ```typescript\n * const client = new Imagen4Client({ apiKey: 'your-api-key' });\n *\n * const result = await client.textToImage.run({\n * model: 'imagen-4',\n * prompt: 'A cat in a spacesuit on the moon',\n * });\n * ```\n */\nexport class Imagen4Client extends BaseClient {\n /** Text-to-image generation across three quality tiers. */\n public readonly textToImage: TextToImage;\n /** Generate new images guided by one or more source images combined with a text prompt. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.remixImage = new RemixImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/text_to_image';\n\n/**\n * Generates images from a text prompt.\n * Three model tiers are available: imagen-4 (standard), imagen-4-fast (lower latency,\n * batch output up to 4 images), and imagen-4-ultra (highest quality).\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate images from a text prompt and wait until complete.\n * @param params Text-to-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n /**\n * Generate images from a text prompt; returns immediately with a task id.\n * @param params Text-to-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-image task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export const contract = {\n \"remix-image\": {\n \"models\": [\n \"imagen-4-pro-remix-image\"\n ],\n \"fields_by_model\": {\n \"imagen-4-pro-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"imagen-4\",\n \"imagen-4-fast\",\n \"imagen-4-ultra\"\n ],\n \"fields_by_model\": {\n \"imagen-4\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-fast\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4\n ],\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"imagen-4-ultra\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"16:9\",\n \"9:16\",\n \"3:4\",\n \"4:3\"\n ]\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n }\n }\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { RemixImageParams, RemixImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/imagen_4/remix_image';\n\n/**\n * Generates new images guided by 1-8 source images combined with a text prompt.\n * Supports output resolution control (1k/2k/4k) and format selection (png/jpg).\n */\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Transform source images guided by a text prompt and wait until complete.\n * @param params Remix-image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed task with images.\n */\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<RemixImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n }\n\n /**\n * Transform source images guided by a text prompt; returns immediately with a task id.\n * @param params Remix-image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['remix-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a remix-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current remix-image task status.\n */\n async get(id: string, options?: RequestOptions): Promise<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { Imagen4Client } from './client';\nexport { TextToImage } from './resources/text-to-image';\nexport { RemixImage } from './resources/remix-image';\nexport type * from './types';\n\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,eAAe,sBAAsB;AAC9C,SAAS,yBAAyB;;;ACF3B,IAAM,WAAW;AAAA,EACtB,eAAe;AAAA,IACb,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,4BAA4B;AAAA,QAC1B,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,YAAY;AAAA,QACV,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,gBAAgB;AAAA,UACd,QAAQ;AAAA,QACV;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;A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A;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/imagen-4",
|
|
3
|
-
"
|
|
4
|
-
|
|
3
|
+
"runapi": {
|
|
4
|
+
"slug": "imagen-4"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.2.7",
|
|
7
|
+
"description": "RunAPI Imagen 4 SDK for text-to-image and remix-image workflows in JavaScript, Python, Ruby, Go, and Java",
|
|
5
8
|
"main": "./dist/index.js",
|
|
6
9
|
"module": "./dist/index.mjs",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
"clean": "rm -rf dist"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@runapi.ai/core": "^0.2.
|
|
33
|
+
"@runapi.ai/core": "^0.2.7"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@types/node": "^20.0.0",
|
|
@@ -46,8 +49,16 @@
|
|
|
46
49
|
"api",
|
|
47
50
|
"sdk",
|
|
48
51
|
"typescript",
|
|
52
|
+
"python",
|
|
49
53
|
"ruby",
|
|
50
|
-
"golang"
|
|
54
|
+
"golang",
|
|
55
|
+
"java",
|
|
56
|
+
"maven",
|
|
57
|
+
"gradle",
|
|
58
|
+
"image-generation",
|
|
59
|
+
"text-to-image",
|
|
60
|
+
"image-api",
|
|
61
|
+
"imagen-api"
|
|
51
62
|
],
|
|
52
63
|
"author": "RunAPI",
|
|
53
64
|
"license": "Apache-2.0",
|
|
@@ -55,5 +66,8 @@
|
|
|
55
66
|
"repository": {
|
|
56
67
|
"type": "git",
|
|
57
68
|
"url": "git+https://github.com/runapi-ai/imagen-4-sdk.git"
|
|
69
|
+
},
|
|
70
|
+
"bugs": {
|
|
71
|
+
"url": "https://github.com/runapi-ai/imagen-4-sdk/issues"
|
|
58
72
|
}
|
|
59
73
|
}
|