getaiapi 1.0.5 → 1.2.0
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/dist/{chunk-ONS4P4YK.js → chunk-QVQQFPOY.js} +2180 -114
- package/dist/{chunk-ONS4P4YK.js.map → chunk-QVQQFPOY.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +132 -3
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type OutputType = 'image' | 'video' | 'audio' | 'text' | '3d' | 'segmentation';
|
|
2
2
|
type InputType = 'text' | 'image' | 'audio' | 'video';
|
|
3
|
-
type ProviderName = 'fal-ai' | 'replicate' | 'wavespeed' | 'openrouter';
|
|
3
|
+
type ProviderName = 'fal-ai' | 'replicate' | 'wavespeed' | 'openrouter' | 'kling';
|
|
4
4
|
interface ModelEntry {
|
|
5
5
|
canonical_name: string;
|
|
6
6
|
aliases: string[];
|
|
@@ -16,6 +16,7 @@ interface ProviderBinding {
|
|
|
16
16
|
endpoint: string;
|
|
17
17
|
auth_env: string;
|
|
18
18
|
param_map: Record<string, string | string[]>;
|
|
19
|
+
defaults?: Record<string, unknown>;
|
|
19
20
|
output_map: OutputMapping;
|
|
20
21
|
}
|
|
21
22
|
interface OutputMapping {
|
|
@@ -44,7 +45,113 @@ interface GenerateRequest {
|
|
|
44
45
|
format?: 'png' | 'jpeg' | 'webp' | 'mp4' | 'mp3' | 'wav' | 'obj' | 'glb';
|
|
45
46
|
quality?: number;
|
|
46
47
|
safety?: boolean;
|
|
47
|
-
|
|
48
|
+
duration?: string;
|
|
49
|
+
options?: Record<string, unknown> | KlingOptions;
|
|
50
|
+
}
|
|
51
|
+
type KlingVideoModel = 'kling-v1' | 'kling-v1-5' | 'kling-v1-6' | 'kling-v2-master' | 'kling-v2-1' | 'kling-v2-1-master' | 'kling-v2-5-turbo' | 'kling-v2-6' | 'kling-v3' | 'kling-v3-omni' | 'kling-video-o1';
|
|
52
|
+
type KlingImageModel = 'kling-v1' | 'kling-v1-5' | 'kling-v2' | 'kling-v2-1' | 'kling-v3' | 'kling-v3-omni' | 'kling-v3-remaster' | 'kling-image-o1' | 'kling-image-o3';
|
|
53
|
+
interface KlingCameraControl {
|
|
54
|
+
type: 'simple' | 'combined';
|
|
55
|
+
config?: {
|
|
56
|
+
horizontal?: number;
|
|
57
|
+
vertical?: number;
|
|
58
|
+
pan?: number;
|
|
59
|
+
tilt?: number;
|
|
60
|
+
roll?: number;
|
|
61
|
+
zoom?: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface KlingOptions {
|
|
65
|
+
/** Model version for video/image generation. */
|
|
66
|
+
model_name?: KlingVideoModel | KlingImageModel | string;
|
|
67
|
+
/** Quality mode — 'std' (standard) or 'pro'. */
|
|
68
|
+
mode?: 'std' | 'pro';
|
|
69
|
+
/** Enable audio generation on video output. */
|
|
70
|
+
sound?: 'on' | 'off';
|
|
71
|
+
/** Camera movement control. */
|
|
72
|
+
camera_control?: KlingCameraControl;
|
|
73
|
+
/** Enable storyboard multi-shot mode. */
|
|
74
|
+
multi_shot?: boolean;
|
|
75
|
+
/** Shot generation method when multi_shot is true. */
|
|
76
|
+
shot_type?: 'customize' | 'intelligence';
|
|
77
|
+
/** Per-shot prompt descriptions for multi-shot mode. */
|
|
78
|
+
multi_prompt?: Array<{
|
|
79
|
+
prompt: string;
|
|
80
|
+
}>;
|
|
81
|
+
/** Aspect ratio for output (e.g., '16:9', '9:16', '1:1'). */
|
|
82
|
+
aspect_ratio?: string;
|
|
83
|
+
/** Image resolution for image generation. */
|
|
84
|
+
resolution?: '1k' | '2k' | '4k';
|
|
85
|
+
/** Image reference mode for image generation. */
|
|
86
|
+
image_reference?: 'subject' | 'face';
|
|
87
|
+
/** Image reference fidelity [0, 1]. */
|
|
88
|
+
image_fidelity?: number;
|
|
89
|
+
/** Human face similarity [0, 1]. */
|
|
90
|
+
human_fidelity?: number;
|
|
91
|
+
/** Reference elements list. */
|
|
92
|
+
element_list?: Array<{
|
|
93
|
+
id: string;
|
|
94
|
+
image: string;
|
|
95
|
+
}>;
|
|
96
|
+
/** End frame image for image-to-video. */
|
|
97
|
+
image_tail?: string;
|
|
98
|
+
/** Static brush mask for image-to-video. */
|
|
99
|
+
static_mask?: string;
|
|
100
|
+
/** Motion brush masks for image-to-video. */
|
|
101
|
+
dynamic_masks?: Array<{
|
|
102
|
+
mask: string;
|
|
103
|
+
trajectory: Array<{
|
|
104
|
+
x: number;
|
|
105
|
+
y: number;
|
|
106
|
+
}>;
|
|
107
|
+
}>;
|
|
108
|
+
/** Clothing image for virtual try-on. */
|
|
109
|
+
cloth_image?: string;
|
|
110
|
+
/** Video effects scene name (e.g., 'flash_drive', 'hug', 'kiss_pro'). */
|
|
111
|
+
effect_scene?: string;
|
|
112
|
+
/** TTS voice identifier. */
|
|
113
|
+
voice_id?: string;
|
|
114
|
+
/** TTS language code. */
|
|
115
|
+
voice_language?: 'zh' | 'en' | string;
|
|
116
|
+
/** TTS speech rate [0.8, 2.0]. */
|
|
117
|
+
voice_speed?: number;
|
|
118
|
+
/** Custom voice name for voice cloning (max 20 chars). */
|
|
119
|
+
voice_name?: string;
|
|
120
|
+
/** Expansion ratios for image outpainting [0, 2]. */
|
|
121
|
+
up_expansion_ratio?: number;
|
|
122
|
+
down_expansion_ratio?: number;
|
|
123
|
+
left_expansion_ratio?: number;
|
|
124
|
+
right_expansion_ratio?: number;
|
|
125
|
+
/** Sound effect prompt for video-to-audio. */
|
|
126
|
+
sound_effect_prompt?: string;
|
|
127
|
+
/** Background music prompt for video-to-audio. */
|
|
128
|
+
bgm_prompt?: string;
|
|
129
|
+
/** ASMR enhancement mode for video-to-audio. */
|
|
130
|
+
asmr_mode?: boolean;
|
|
131
|
+
/** Face ID for lip sync (from facial recognition API). */
|
|
132
|
+
face_id?: string;
|
|
133
|
+
/** Audio timing for lip sync (milliseconds). */
|
|
134
|
+
sound_start_time?: number;
|
|
135
|
+
sound_end_time?: number;
|
|
136
|
+
sound_insert_time?: number;
|
|
137
|
+
/** Audio volume [0, 2]. */
|
|
138
|
+
sound_volume?: number;
|
|
139
|
+
/** Original video audio volume [0, 2]. */
|
|
140
|
+
original_audio_volume?: number;
|
|
141
|
+
/** Element frontal image for multi-shot. */
|
|
142
|
+
element_frontal_image?: string;
|
|
143
|
+
/** Enable watermark. */
|
|
144
|
+
watermark_info?: {
|
|
145
|
+
watermark: boolean;
|
|
146
|
+
};
|
|
147
|
+
/** Async callback URL for result notification. */
|
|
148
|
+
callback_url?: string;
|
|
149
|
+
/** User-defined external task ID for tracking. */
|
|
150
|
+
external_task_id?: string;
|
|
151
|
+
/** Request timeout in milliseconds. */
|
|
152
|
+
timeout?: number;
|
|
153
|
+
/** Re-upload binary URLs to R2 before sending. */
|
|
154
|
+
reupload?: boolean;
|
|
48
155
|
}
|
|
49
156
|
interface GenerateResponse {
|
|
50
157
|
id: string;
|
|
@@ -103,9 +210,27 @@ interface ProviderAdapter {
|
|
|
103
210
|
poll(taskId: string, auth: string, endpoint?: string): Promise<ProviderResponse>;
|
|
104
211
|
parseOutput(raw: unknown, outputMapping: OutputMapping): OutputItem[];
|
|
105
212
|
}
|
|
213
|
+
interface FetchLogEntry {
|
|
214
|
+
kind: 'request' | 'response' | 'error';
|
|
215
|
+
method: string;
|
|
216
|
+
url: string;
|
|
217
|
+
bodyBytes?: number;
|
|
218
|
+
headers?: Record<string, string>;
|
|
219
|
+
status?: number;
|
|
220
|
+
durationMs?: number;
|
|
221
|
+
responseBytes?: number;
|
|
222
|
+
error?: string;
|
|
223
|
+
}
|
|
224
|
+
type LogFn = (entry: FetchLogEntry) => void;
|
|
225
|
+
interface FetchOptions {
|
|
226
|
+
timeoutMs?: number;
|
|
227
|
+
logging?: boolean;
|
|
228
|
+
logger?: LogFn;
|
|
229
|
+
}
|
|
106
230
|
interface ConfigureOptions {
|
|
107
231
|
keys?: Partial<Record<ProviderName, string>>;
|
|
108
232
|
storage?: StorageConfig;
|
|
233
|
+
fetch?: FetchOptions;
|
|
109
234
|
}
|
|
110
235
|
interface StorageConfig {
|
|
111
236
|
accountId: string;
|
|
@@ -139,6 +264,8 @@ declare function configure(options: ConfigureOptions): void;
|
|
|
139
264
|
|
|
140
265
|
declare function configureAuth(keys: Partial<Record<ProviderName, string>>): void;
|
|
141
266
|
|
|
267
|
+
declare function configureFetch(options: FetchOptions): void;
|
|
268
|
+
|
|
142
269
|
/**
|
|
143
270
|
* Lists models filtered by modality, provider, or text query.
|
|
144
271
|
* Category is derived, not stored — filter by input/output modality instead.
|
|
@@ -190,6 +317,8 @@ declare function presignAsset(key: string, options?: {
|
|
|
190
317
|
}): string;
|
|
191
318
|
declare function deleteAsset(key: string): Promise<void>;
|
|
192
319
|
|
|
320
|
+
declare const klingAdapter: ProviderAdapter;
|
|
321
|
+
|
|
193
322
|
declare class GetAIApiError extends Error {
|
|
194
323
|
constructor(message: string);
|
|
195
324
|
}
|
|
@@ -239,4 +368,4 @@ declare class StorageError extends GetAIApiError {
|
|
|
239
368
|
constructor(operation: StorageOperation, message: string, statusCode?: number);
|
|
240
369
|
}
|
|
241
370
|
|
|
242
|
-
export { AuthError, type ConfigureOptions, type GenerateRequest, type GenerateResponse, GetAIApiError, type InputType, type ListModelsFilters, type ModelEntry, ModelNotFoundError, NoProviderError, type OutputItem, type OutputMapping, type OutputType, type PollResponse, type ProviderAdapter, type ProviderBinding, ProviderError, type ProviderName, type ProviderResponse, RateLimitError, type StorageConfig, StorageError, type SubmitResponse, TimeoutError, type UploadOptions, type UploadResult, ValidationError, clearRegistryCache, configure, configureAuth, configureStorage, deleteAsset, deriveCategory, generate, listModels, loadRegistry, mapInput, mapOutput, poll, presignAsset, resolveModel, submit, submitAndPoll, uploadAsset };
|
|
371
|
+
export { AuthError, type ConfigureOptions, type FetchLogEntry, type FetchOptions, type GenerateRequest, type GenerateResponse, GetAIApiError, type InputType, type KlingCameraControl, type KlingImageModel, type KlingOptions, type KlingVideoModel, type ListModelsFilters, type LogFn, type ModelEntry, ModelNotFoundError, NoProviderError, type OutputItem, type OutputMapping, type OutputType, type PollResponse, type ProviderAdapter, type ProviderBinding, ProviderError, type ProviderName, type ProviderResponse, RateLimitError, type StorageConfig, StorageError, type SubmitResponse, TimeoutError, type UploadOptions, type UploadResult, ValidationError, clearRegistryCache, configure, configureAuth, configureFetch, configureStorage, deleteAsset, deriveCategory, generate, klingAdapter, listModels, loadRegistry, mapInput, mapOutput, poll, presignAsset, resolveModel, submit, submitAndPoll, uploadAsset };
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
ValidationError,
|
|
11
11
|
clearRegistryCache,
|
|
12
12
|
configureAuth,
|
|
13
|
+
configureFetch,
|
|
13
14
|
configureStorage,
|
|
14
15
|
deleteAsset,
|
|
15
16
|
deriveCategory,
|
|
16
17
|
generate,
|
|
18
|
+
klingAdapter,
|
|
17
19
|
listModels,
|
|
18
20
|
loadRegistry,
|
|
19
21
|
mapInput,
|
|
@@ -24,7 +26,7 @@ import {
|
|
|
24
26
|
submit,
|
|
25
27
|
submitAndPoll,
|
|
26
28
|
uploadAsset
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-QVQQFPOY.js";
|
|
28
30
|
|
|
29
31
|
// src/configure.ts
|
|
30
32
|
function configure(options) {
|
|
@@ -34,6 +36,9 @@ function configure(options) {
|
|
|
34
36
|
if (options.storage) {
|
|
35
37
|
configureStorage(options.storage);
|
|
36
38
|
}
|
|
39
|
+
if (options.fetch) {
|
|
40
|
+
configureFetch(options.fetch);
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
export {
|
|
39
44
|
AuthError,
|
|
@@ -48,10 +53,12 @@ export {
|
|
|
48
53
|
clearRegistryCache,
|
|
49
54
|
configure,
|
|
50
55
|
configureAuth,
|
|
56
|
+
configureFetch,
|
|
51
57
|
configureStorage,
|
|
52
58
|
deleteAsset,
|
|
53
59
|
deriveCategory,
|
|
54
60
|
generate,
|
|
61
|
+
klingAdapter,
|
|
55
62
|
listModels,
|
|
56
63
|
loadRegistry,
|
|
57
64
|
mapInput,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/configure.ts"],"sourcesContent":["import type { ConfigureOptions } from \"./types.js\";\nimport { configureAuth } from \"./auth.js\";\nimport { configureStorage } from \"./storage.js\";\n\nexport function configure(options: ConfigureOptions): void {\n if (options.keys) {\n configureAuth(options.keys);\n }\n if (options.storage) {\n configureStorage(options.storage);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/configure.ts"],"sourcesContent":["import type { ConfigureOptions } from \"./types.js\";\nimport { configureAuth } from \"./auth.js\";\nimport { configureStorage } from \"./storage.js\";\nimport { configureFetch } from \"./fetch.js\";\n\nexport function configure(options: ConfigureOptions): void {\n if (options.keys) {\n configureAuth(options.keys);\n }\n if (options.storage) {\n configureStorage(options.storage);\n }\n if (options.fetch) {\n configureFetch(options.fetch);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,SAAS,UAAU,SAAiC;AACzD,MAAI,QAAQ,MAAM;AAChB,kBAAc,QAAQ,IAAI;AAAA,EAC5B;AACA,MAAI,QAAQ,SAAS;AACnB,qBAAiB,QAAQ,OAAO;AAAA,EAClC;AACA,MAAI,QAAQ,OAAO;AACjB,mBAAe,QAAQ,KAAK;AAAA,EAC9B;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "getaiapi",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Unified AI API Gateway - one function to call any AI model",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@fal-ai/client": "^1.9.4",
|
|
61
61
|
"@types/node": "^25.5.0",
|
|
62
62
|
"@vitest/coverage-v8": "^3.2.4",
|
|
63
|
+
"playwright": "^1.59.1",
|
|
63
64
|
"replicate": "^1.4.0",
|
|
64
65
|
"tsup": "^8.4.0",
|
|
65
66
|
"tsx": "^4.19.0",
|