@kvidai/sdk 0.2.2 → 0.3.1
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 +42 -21
- package/dist/esm/index.js +47 -61
- package/dist/index.d.ts +61 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,23 +12,23 @@ Works in Node.js and React Native (uses global `fetch` / `AbortSignal`; no Node
|
|
|
12
12
|
|
|
13
13
|
kvidai uses two credentials:
|
|
14
14
|
|
|
15
|
-
- **Strapi JWT** — identity: login +
|
|
16
|
-
- **
|
|
15
|
+
- **Strapi JWT** — identity: login + api‑key management (`console.kvid.ai`). Get it with `auth.login()`.
|
|
16
|
+
- **API key** (32‑hex) — generation, media, preset, agent (`api.kvid.ai`). Get/create it via the [dashboard](https://kvid.ai) or the `auth.loginAndGetApiKey()` shortcut.
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import { KvidaiClient } from '@kvidai/sdk';
|
|
20
20
|
|
|
21
|
+
// Default: targets api.kvid.ai (generation) and console.kvid.ai (auth).
|
|
21
22
|
const client = new KvidaiClient({
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
// apiKey: '<apim-32hex>', // for generation/media/preset/agent
|
|
23
|
+
// jwt: '<strapi-jwt>', // for auth/key management
|
|
24
|
+
// apiKey: '<api-key>', // for generation/media/preset/agent
|
|
25
25
|
});
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Quick start — generate a video
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
|
-
const client = new KvidaiClient({
|
|
31
|
+
const client = new KvidaiClient({});
|
|
32
32
|
|
|
33
33
|
// 1. Log in and get an API key in one call
|
|
34
34
|
const { apiKey, user } = await client.auth.loginAndGetApiKey('you@example.com', 'password');
|
|
@@ -54,8 +54,8 @@ console.log(result.url); // https://cdn.kvid.ai/...
|
|
|
54
54
|
```ts
|
|
55
55
|
const { jwt, user } = await client.auth.login({ identifier, password });
|
|
56
56
|
await client.auth.me();
|
|
57
|
-
await client.auth.products(); //
|
|
58
|
-
await client.auth.listKeys(); // your
|
|
57
|
+
await client.auth.products(); // available api products
|
|
58
|
+
await client.auth.listKeys(); // your api keys (masked)
|
|
59
59
|
await client.auth.keyDetail(subscriptionId); // full key
|
|
60
60
|
await client.auth.generateKey({ email, productId });
|
|
61
61
|
await client.auth.regenerateKey({ subscriptionId, email });
|
|
@@ -64,7 +64,7 @@ await client.auth.creditSummary(email);
|
|
|
64
64
|
await client.auth.loginAndGetApiKey(identifier, password); // login + reuse/create key
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
### `client.generation` (
|
|
67
|
+
### `client.generation` (api‑key)
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
70
|
client.generation.textToVideo({ model, prompt, ... });
|
|
@@ -82,7 +82,7 @@ client.generation.waitForResult({ requestId, model }); // poll → result
|
|
|
82
82
|
|
|
83
83
|
Create methods return `{ requestId, model }`. `waitForResult` returns `{ url, requestId, model }`.
|
|
84
84
|
|
|
85
|
-
### `client.media` (
|
|
85
|
+
### `client.media` (api‑key)
|
|
86
86
|
|
|
87
87
|
```ts
|
|
88
88
|
const cdnUrl = await client.media.upload(file); // presign → PUT → CDN url (browser File; <90 MB)
|
|
@@ -95,7 +95,7 @@ await client.media.list();
|
|
|
95
95
|
|
|
96
96
|
On React Native (no `File`), use `presign()` + your own `fetch(uploadUrl, { method: 'PUT', body })` + `completeUpload()`.
|
|
97
97
|
|
|
98
|
-
### `client.preset` (
|
|
98
|
+
### `client.preset` (api‑key)
|
|
99
99
|
|
|
100
100
|
```ts
|
|
101
101
|
client.preset.list(); client.preset.get(id);
|
|
@@ -103,19 +103,25 @@ client.preset.create({ name, settings }); client.preset.update(id, { ... });
|
|
|
103
103
|
client.preset.delete(id); client.preset.duplicate(id);
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
### `client.agent` — conversational video agent (SSE,
|
|
106
|
+
### `client.agent` — conversational video agent (SSE, api‑key)
|
|
107
107
|
|
|
108
108
|
```ts
|
|
109
109
|
const { projectId } = await client.agent.createProject('My video');
|
|
110
110
|
|
|
111
|
-
await client.agent.generate(
|
|
111
|
+
const { tools, toolErrors } = await client.agent.generate(
|
|
112
112
|
{ projectId, message: 'Make a 30s promo about coffee', chatHistory: [] },
|
|
113
|
-
(
|
|
113
|
+
(e) => console.log(e.event) // streamed events: tool_start, tool_end, done, error, ...
|
|
114
114
|
);
|
|
115
115
|
|
|
116
|
+
// generate() throws only when the stream carries an `error` event. A tool that failed ends with success:false and is listed in toolErrors,
|
|
117
|
+
// so check it: e.g. a generated video whose size/length could not be read is NOT added to the project (the message names the generated file).
|
|
118
|
+
if (toolErrors.length) console.warn(toolErrors); // [{ toolName, error, toolUseId? }]
|
|
119
|
+
|
|
116
120
|
const project = await client.agent.getProjectResult(projectId); // { renderUrl, sceneCount, composition }
|
|
117
121
|
```
|
|
118
122
|
|
|
123
|
+
Video assets in `project.composition.assets` carry the real `width`, `height` and `durationInSeconds` of the generated file. A timeline clip may use a shorter part of it (for example a 5 s clip of an 8 s file).
|
|
124
|
+
|
|
119
125
|
## Error handling
|
|
120
126
|
|
|
121
127
|
Every failure throws a typed `KvidaiError`:
|
|
@@ -134,18 +140,33 @@ try {
|
|
|
134
140
|
}
|
|
135
141
|
```
|
|
136
142
|
|
|
137
|
-
##
|
|
143
|
+
## Base URL override
|
|
144
|
+
|
|
145
|
+
By default the SDK targets `https://api.kvid.ai` (generation/media/preset/agent) and `https://console.kvid.ai` (auth). Override either URL for custom environments:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const client = new KvidaiClient({
|
|
149
|
+
baseUrl: 'https://api.kvid.ai', // generation/media/preset/agent base
|
|
150
|
+
consoleBaseUrl: 'http://localhost:1337', // auth/key-management base
|
|
151
|
+
generationPath: '/ai/generation-clone', // override generation path prefix
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| option | default | purpose |
|
|
156
|
+
| ------------------ | ------------------------- | -------------------------------------- |
|
|
157
|
+
| `baseUrl` | `https://api.kvid.ai` | generation, media, preset, agent calls |
|
|
158
|
+
| `consoleBaseUrl` | `https://console.kvid.ai` | auth (login, key management) calls |
|
|
159
|
+
| `generationPath` | `/ai/generation` | generation endpoint prefix |
|
|
160
|
+
| `mediaPath` | `/media` | media endpoint prefix |
|
|
161
|
+
| `presetPath` | `/preset` | preset endpoint prefix |
|
|
162
|
+
| `agentPath` | `/agent` | agent endpoint prefix |
|
|
163
|
+
| `videoProjectPath` | `/video-project` | video-project endpoint prefix |
|
|
138
164
|
|
|
139
|
-
|
|
140
|
-
| --------- | -------------------------------------------- | ------------------------- |
|
|
141
|
-
| `prod` | `https://api.kvid.ai` `/ai/generation` | `https://console.kvid.ai` |
|
|
142
|
-
| `staging` | `https://api.kvid.ai` `/ai/generation` | staging Strapi |
|
|
143
|
-
| `dev` | `https://api.kvid.ai` `/ai/generation-clone` | `http://localhost:1337` |
|
|
165
|
+
**Note**: base URLs are not secrets — the actual security boundary is the api key. Set them in app environment config, not in the SDK bundle.
|
|
144
166
|
|
|
145
167
|
## Notes
|
|
146
168
|
|
|
147
169
|
- API keys are shown in full **only once** (on create/regenerate); store them securely. Regenerating a key invalidates the old one immediately.
|
|
148
|
-
- A Strapi JWT expiring is independent from an APIM key expiring.
|
|
149
170
|
- Generation is **polling‑based** (no webhooks): use `waitForResult`.
|
|
150
171
|
|
|
151
172
|
## License
|
package/dist/esm/index.js
CHANGED
|
@@ -2,52 +2,29 @@
|
|
|
2
2
|
* @kvidai/sdk — kvidai TypeScript SDK
|
|
3
3
|
*
|
|
4
4
|
* Covers the 4 core external-client flows documented in docs/external-client-guide.md:
|
|
5
|
-
* 1. Auth — login +
|
|
6
|
-
* 2. Generation — AI video/image/voice creation + status polling + result fetch (api.kvid.ai
|
|
7
|
-
* 3. Media — presigned upload → CDN URL (api.kvid.ai
|
|
8
|
-
* 4. Preset — CRUD (api.kvid.ai
|
|
5
|
+
* 1. Auth — login + api-key management (console.kvid.ai / Strapi JWT)
|
|
6
|
+
* 2. Generation — AI video/image/voice creation + status polling + result fetch (api.kvid.ai)
|
|
7
|
+
* 3. Media — presigned upload → CDN URL (api.kvid.ai)
|
|
8
|
+
* 4. Preset — CRUD (api.kvid.ai)
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
|
-
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<
|
|
11
|
+
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<api-key>' });
|
|
12
12
|
* const { requestId, model } = await client.generation.textToVideo({ prompt: '...', model: 'wan' });
|
|
13
13
|
* const result = await client.generation.waitForResult({ requestId, model });
|
|
14
14
|
*
|
|
15
15
|
* Canonical sources: docs/external-client-api-reference.md, docs/external-client-guide.md
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
staging: {
|
|
29
|
-
strapiBaseUrl: 'https://hometips-strapi-ts-staging1-405573518541.asia-northeast1.run.app',
|
|
30
|
-
apimBaseUrl: 'https://api.kvid.ai',
|
|
31
|
-
webBaseUrl: 'https://staging1.kvid.ai',
|
|
32
|
-
generationPath: '/ai/generation',
|
|
33
|
-
mediaPath: '/media',
|
|
34
|
-
presetPath: '/preset',
|
|
35
|
-
agentPath: '/agent',
|
|
36
|
-
videoProjectPath: '/video-project',
|
|
37
|
-
},
|
|
38
|
-
dev: {
|
|
39
|
-
strapiBaseUrl: 'http://localhost:1337',
|
|
40
|
-
apimBaseUrl: 'https://api.kvid.ai',
|
|
41
|
-
webBaseUrl: 'http://localhost:3000',
|
|
42
|
-
generationPath: '/ai/generation-clone',
|
|
43
|
-
mediaPath: '/media-dev',
|
|
44
|
-
presetPath: '/preset-dev',
|
|
45
|
-
// Agent + video-project use the same gateway paths across all envs (confirmed live 2026-10-30).
|
|
46
|
-
// No dev-clone equivalent exists for these endpoints.
|
|
47
|
-
agentPath: '/agent',
|
|
48
|
-
videoProjectPath: '/video-project',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
17
|
+
function resolveUrls(opts) {
|
|
18
|
+
return {
|
|
19
|
+
consoleBaseUrl: opts.consoleBaseUrl ?? 'https://console.kvid.ai',
|
|
20
|
+
apiBaseUrl: opts.baseUrl ?? 'https://api.kvid.ai',
|
|
21
|
+
generationPath: opts.generationPath ?? '/ai/generation',
|
|
22
|
+
mediaPath: opts.mediaPath ?? '/media',
|
|
23
|
+
presetPath: opts.presetPath ?? '/preset',
|
|
24
|
+
agentPath: opts.agentPath ?? '/agent',
|
|
25
|
+
videoProjectPath: opts.videoProjectPath ?? '/video-project',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
51
28
|
export class KvidaiError extends Error {
|
|
52
29
|
constructor(code, message, status, details) {
|
|
53
30
|
super(message);
|
|
@@ -76,11 +53,7 @@ class Transport {
|
|
|
76
53
|
return headers;
|
|
77
54
|
}
|
|
78
55
|
async request(base, path, init = {}) {
|
|
79
|
-
const baseUrl = base === 'strapi'
|
|
80
|
-
? this.urls.strapiBaseUrl
|
|
81
|
-
: base === 'web'
|
|
82
|
-
? this.urls.webBaseUrl
|
|
83
|
-
: this.urls.apimBaseUrl;
|
|
56
|
+
const baseUrl = base === 'strapi' ? this.urls.consoleBaseUrl : this.urls.apiBaseUrl;
|
|
84
57
|
const authType = base === 'strapi' ? 'strapi' : 'apim';
|
|
85
58
|
let res;
|
|
86
59
|
try {
|
|
@@ -115,11 +88,7 @@ class Transport {
|
|
|
115
88
|
* No automatic timeout is applied since SSE streams are long-running.
|
|
116
89
|
*/
|
|
117
90
|
async requestText(base, path, init = {}) {
|
|
118
|
-
const baseUrl = base === 'strapi'
|
|
119
|
-
? this.urls.strapiBaseUrl
|
|
120
|
-
: base === 'web'
|
|
121
|
-
? this.urls.webBaseUrl
|
|
122
|
-
: this.urls.apimBaseUrl;
|
|
91
|
+
const baseUrl = base === 'strapi' ? this.urls.consoleBaseUrl : this.urls.apiBaseUrl;
|
|
123
92
|
const authType = base === 'strapi' ? 'strapi' : 'apim';
|
|
124
93
|
let res;
|
|
125
94
|
try {
|
|
@@ -168,7 +137,7 @@ class AuthModule {
|
|
|
168
137
|
async me() {
|
|
169
138
|
return this.t.request('strapi', '/api/users/me');
|
|
170
139
|
}
|
|
171
|
-
/** GET /api/apim-management/my-keys — list active keys (masked). */
|
|
140
|
+
/** GET /api/apim-management/my-keys — list active api keys (masked). */
|
|
172
141
|
async listKeys() {
|
|
173
142
|
const res = await this.t.request('strapi', '/api/apim-management/my-keys');
|
|
174
143
|
return Array.isArray(res) ? res : (res.data ?? []);
|
|
@@ -179,14 +148,14 @@ class AuthModule {
|
|
|
179
148
|
// Controller wraps in { data: ... }
|
|
180
149
|
return res.data ?? res;
|
|
181
150
|
}
|
|
182
|
-
/** GET /api/apim-management/products — available
|
|
151
|
+
/** GET /api/apim-management/products — available api products. */
|
|
183
152
|
async products() {
|
|
184
153
|
const res = await this.t.request('strapi', '/api/apim-management/products');
|
|
185
154
|
const data = res.data ?? res;
|
|
186
155
|
return data.products ?? [];
|
|
187
156
|
}
|
|
188
157
|
/**
|
|
189
|
-
* POST /api/apim-management/generate-key — issue a new
|
|
158
|
+
* POST /api/apim-management/generate-key — issue a new api key.
|
|
190
159
|
* ⚠️ primaryKey is shown only in this response — store it immediately.
|
|
191
160
|
*/
|
|
192
161
|
async generateKey(params) {
|
|
@@ -238,7 +207,7 @@ class AuthModule {
|
|
|
238
207
|
// No key — generate one
|
|
239
208
|
const products = await this.products();
|
|
240
209
|
if (!products.length)
|
|
241
|
-
throw new KvidaiError('NO_PRODUCT', 'No
|
|
210
|
+
throw new KvidaiError('NO_PRODUCT', 'No API products available', 404);
|
|
242
211
|
const { primaryKey } = await this.generateKey({ email: user.email, productId: products[0].id });
|
|
243
212
|
return { jwt, apiKey: primaryKey, user };
|
|
244
213
|
}
|
|
@@ -523,12 +492,13 @@ function extractRenderUrl(raw) {
|
|
|
523
492
|
return null;
|
|
524
493
|
}
|
|
525
494
|
/**
|
|
526
|
-
* Parses a raw SSE stream text. Calls onEvent for each `event:`/`data:` pair.
|
|
527
|
-
* Returns all tool_start toolNames and the first error event payload.
|
|
495
|
+
* Parses a raw SSE stream text. Calls onEvent for each `event:`/`data:` pair; comment lines (`: heartbeat`) are ignored.
|
|
496
|
+
* Returns all tool_start toolNames, the tools that ended with success:false and the first error event payload.
|
|
528
497
|
* Mirrors apps/mobile-app/src/generation/agent-generate-client.ts parseSseEvents.
|
|
529
498
|
*/
|
|
530
499
|
function parseSseStream(text, onEvent) {
|
|
531
500
|
const tools = [];
|
|
501
|
+
const toolErrors = [];
|
|
532
502
|
let error = null;
|
|
533
503
|
let eventName = '';
|
|
534
504
|
for (const line of text.split('\n')) {
|
|
@@ -549,11 +519,19 @@ function parseSseStream(text, onEvent) {
|
|
|
549
519
|
const toolName = data?.toolName;
|
|
550
520
|
if (eventName === 'tool_start' && typeof toolName === 'string')
|
|
551
521
|
tools.push(toolName);
|
|
522
|
+
if (eventName === 'tool_end' && data?.success === false) {
|
|
523
|
+
const failed = data;
|
|
524
|
+
toolErrors.push({
|
|
525
|
+
...(typeof failed.toolUseId === 'string' ? { toolUseId: failed.toolUseId } : {}),
|
|
526
|
+
toolName: typeof failed.toolName === 'string' ? failed.toolName : '',
|
|
527
|
+
error: typeof failed.error === 'string' && failed.error ? failed.error : 'tool failed',
|
|
528
|
+
});
|
|
529
|
+
}
|
|
552
530
|
if (eventName === 'error' && error === null)
|
|
553
531
|
error = data;
|
|
554
532
|
}
|
|
555
533
|
}
|
|
556
|
-
return { tools, error };
|
|
534
|
+
return { tools, toolErrors, error };
|
|
557
535
|
}
|
|
558
536
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
559
537
|
// Agent module
|
|
@@ -597,10 +575,10 @@ class AgentModule {
|
|
|
597
575
|
: {}),
|
|
598
576
|
}),
|
|
599
577
|
});
|
|
600
|
-
const { tools, error } = parseSseStream(text, onEvent);
|
|
578
|
+
const { tools, toolErrors, error } = parseSseStream(text, onEvent);
|
|
601
579
|
if (error !== null)
|
|
602
580
|
throw new KvidaiError('AGENT_ERROR', 'the agent reported an error', 0, error);
|
|
603
|
-
return { tools };
|
|
581
|
+
return { tools, toolErrors };
|
|
604
582
|
}
|
|
605
583
|
/**
|
|
606
584
|
* Reads the result of an agent turn from the project. GET /video-project/:id (APIM api-key).
|
|
@@ -627,7 +605,7 @@ class AgentModule {
|
|
|
627
605
|
*
|
|
628
606
|
* @example
|
|
629
607
|
* // With existing credentials:
|
|
630
|
-
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<
|
|
608
|
+
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<api-key>' });
|
|
631
609
|
* const { requestId, model } = await client.generation.textToVideo({ prompt: 'Space', model: 'wan' });
|
|
632
610
|
* const result = await client.generation.waitForResult({ requestId, model });
|
|
633
611
|
*
|
|
@@ -636,11 +614,19 @@ class AgentModule {
|
|
|
636
614
|
* const client = new KvidaiClient({});
|
|
637
615
|
* const { jwt, apiKey } = await client.auth.loginAndGetApiKey('user@example.com', 'password');
|
|
638
616
|
* client.setCredentials({ jwt, apiKey });
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* // Custom base URL (for internal/dev environments):
|
|
620
|
+
* const client = new KvidaiClient({
|
|
621
|
+
* baseUrl: 'https://api.kvid.ai',
|
|
622
|
+
* consoleBaseUrl: 'http://localhost:1337',
|
|
623
|
+
* generationPath: '/ai/generation-clone',
|
|
624
|
+
* });
|
|
639
625
|
*/
|
|
640
626
|
export class KvidaiClient {
|
|
641
627
|
constructor(options = {}) {
|
|
642
|
-
this.opts = {
|
|
643
|
-
const urls =
|
|
628
|
+
this.opts = { timeoutMs: 30000, ...options };
|
|
629
|
+
const urls = resolveUrls(this.opts);
|
|
644
630
|
this.transport = new Transport(this.opts, urls);
|
|
645
631
|
this.auth = new AuthModule(this.transport, this.opts);
|
|
646
632
|
this.generation = new GenerationModule(this.transport, urls);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @kvidai/sdk — kvidai TypeScript SDK
|
|
3
3
|
*
|
|
4
4
|
* Covers the 4 core external-client flows documented in docs/external-client-guide.md:
|
|
5
|
-
* 1. Auth — login +
|
|
6
|
-
* 2. Generation — AI video/image/voice creation + status polling + result fetch (api.kvid.ai
|
|
7
|
-
* 3. Media — presigned upload → CDN URL (api.kvid.ai
|
|
8
|
-
* 4. Preset — CRUD (api.kvid.ai
|
|
5
|
+
* 1. Auth — login + api-key management (console.kvid.ai / Strapi JWT)
|
|
6
|
+
* 2. Generation — AI video/image/voice creation + status polling + result fetch (api.kvid.ai)
|
|
7
|
+
* 3. Media — presigned upload → CDN URL (api.kvid.ai)
|
|
8
|
+
* 4. Preset — CRUD (api.kvid.ai)
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
|
-
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<
|
|
11
|
+
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<api-key>' });
|
|
12
12
|
* const { requestId, model } = await client.generation.textToVideo({ prompt: '...', model: 'wan' });
|
|
13
13
|
* const result = await client.generation.waitForResult({ requestId, model });
|
|
14
14
|
*
|
|
@@ -17,24 +17,32 @@
|
|
|
17
17
|
export interface KvidaiClientOptions {
|
|
18
18
|
/** Strapi JWT — required for auth (login, key management). Obtain via `auth.login()`. */
|
|
19
19
|
jwt?: string;
|
|
20
|
-
/**
|
|
20
|
+
/** API key (32-hex) — required for generation, media, preset calls. Obtain from the dashboard or `auth.loginAndGetApiKey()`. */
|
|
21
21
|
apiKey?: string;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** Base URL for generation, media, preset and agent calls (default: 'https://api.kvid.ai'). */
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
/** Base URL for auth (login, key management) calls (default: 'https://console.kvid.ai'). */
|
|
25
|
+
consoleBaseUrl?: string;
|
|
26
|
+
/** Override generation endpoint path prefix (default: '/ai/generation'). */
|
|
27
|
+
generationPath?: string;
|
|
28
|
+
/** Override media endpoint path prefix (default: '/media'). */
|
|
29
|
+
mediaPath?: string;
|
|
30
|
+
/** Override preset endpoint path prefix (default: '/preset'). */
|
|
31
|
+
presetPath?: string;
|
|
32
|
+
/** Override agent endpoint path prefix (default: '/agent'). */
|
|
33
|
+
agentPath?: string;
|
|
34
|
+
/** Override video-project endpoint path prefix (default: '/video-project'). */
|
|
35
|
+
videoProjectPath?: string;
|
|
24
36
|
/** Per-request timeout ms (default: 30000). */
|
|
25
37
|
timeoutMs?: number;
|
|
26
38
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
apimBaseUrl: string;
|
|
31
|
-
webBaseUrl: string;
|
|
39
|
+
interface ResolvedUrls {
|
|
40
|
+
consoleBaseUrl: string;
|
|
41
|
+
apiBaseUrl: string;
|
|
32
42
|
generationPath: string;
|
|
33
43
|
mediaPath: string;
|
|
34
44
|
presetPath: string;
|
|
35
|
-
/** APIM path prefix for agent generate endpoint (e.g. /agent, /agent-dev). */
|
|
36
45
|
agentPath: string;
|
|
37
|
-
/** APIM path prefix for video-project endpoints (e.g. /video-project, /video-project-dev). */
|
|
38
46
|
videoProjectPath: string;
|
|
39
47
|
}
|
|
40
48
|
export declare class KvidaiError extends Error {
|
|
@@ -59,17 +67,17 @@ export interface LoginResponse {
|
|
|
59
67
|
email: string;
|
|
60
68
|
};
|
|
61
69
|
}
|
|
62
|
-
export interface
|
|
70
|
+
export interface ApiKeyItem {
|
|
63
71
|
subscriptionId: string;
|
|
64
72
|
state: 'active' | 'suspended' | 'cancelled';
|
|
65
73
|
primaryKey: string;
|
|
66
74
|
displayName?: string;
|
|
67
75
|
}
|
|
68
|
-
export interface
|
|
76
|
+
export interface ApiKeyDetail {
|
|
69
77
|
subscriptionId: string;
|
|
70
78
|
primaryKey: string;
|
|
71
79
|
}
|
|
72
|
-
export interface
|
|
80
|
+
export interface Product {
|
|
73
81
|
id: string;
|
|
74
82
|
name: string;
|
|
75
83
|
description?: string;
|
|
@@ -168,7 +176,7 @@ export interface WaitForResultOptions {
|
|
|
168
176
|
}
|
|
169
177
|
export interface PresignedUploadRequest {
|
|
170
178
|
filename: string;
|
|
171
|
-
/**
|
|
179
|
+
/** Media endpoint expects `mimeType` */
|
|
172
180
|
mimeType: string;
|
|
173
181
|
size?: number;
|
|
174
182
|
email?: string;
|
|
@@ -233,8 +241,20 @@ export interface AgentGenerateInput {
|
|
|
233
241
|
chatHistory: AgentChatTurn[];
|
|
234
242
|
attachedFiles?: AgentAttachedFile[];
|
|
235
243
|
}
|
|
244
|
+
/** A tool the agent called that ended with `success: false` (SSE `tool_end`). */
|
|
245
|
+
export interface AgentToolError {
|
|
246
|
+
toolName: string;
|
|
247
|
+
/** The server's message; `tool failed` when it sent none. */
|
|
248
|
+
error: string;
|
|
249
|
+
toolUseId?: string;
|
|
250
|
+
}
|
|
236
251
|
export interface AgentRunResult {
|
|
237
252
|
tools: string[];
|
|
253
|
+
/**
|
|
254
|
+
* Tools that ended with `success: false`. `generate()` does not throw for them (only an `error` event throws), so check this list:
|
|
255
|
+
* for example a generated video whose size/length could not be read is NOT added to the project, and the message names the generated file.
|
|
256
|
+
*/
|
|
257
|
+
toolErrors: AgentToolError[];
|
|
238
258
|
}
|
|
239
259
|
export interface AgentProjectResult {
|
|
240
260
|
projectId: number;
|
|
@@ -246,14 +266,14 @@ export interface AgentProjectResult {
|
|
|
246
266
|
declare class Transport {
|
|
247
267
|
private readonly options;
|
|
248
268
|
private readonly urls;
|
|
249
|
-
constructor(options: KvidaiClientOptions, urls:
|
|
269
|
+
constructor(options: KvidaiClientOptions, urls: ResolvedUrls);
|
|
250
270
|
private buildHeaders;
|
|
251
|
-
request<T>(base: 'strapi' | 'apim'
|
|
271
|
+
request<T>(base: 'strapi' | 'apim', path: string, init?: RequestInit): Promise<T>;
|
|
252
272
|
/**
|
|
253
273
|
* Like request() but returns the raw text body — for SSE streams.
|
|
254
274
|
* No automatic timeout is applied since SSE streams are long-running.
|
|
255
275
|
*/
|
|
256
|
-
requestText(base: 'strapi' | 'apim'
|
|
276
|
+
requestText(base: 'strapi' | 'apim', path: string, init?: RequestInit): Promise<string>;
|
|
257
277
|
/** Strapi JSON API envelope unwrap: `{ data: ... }` */
|
|
258
278
|
strapiGet<T>(path: string): Promise<T>;
|
|
259
279
|
}
|
|
@@ -265,14 +285,14 @@ declare class AuthModule {
|
|
|
265
285
|
login(params: LoginRequest): Promise<LoginResponse>;
|
|
266
286
|
/** GET /api/users/me — verify JWT and fetch user profile. */
|
|
267
287
|
me(): Promise<LoginResponse['user']>;
|
|
268
|
-
/** GET /api/apim-management/my-keys — list active keys (masked). */
|
|
269
|
-
listKeys(): Promise<
|
|
288
|
+
/** GET /api/apim-management/my-keys — list active api keys (masked). */
|
|
289
|
+
listKeys(): Promise<ApiKeyItem[]>;
|
|
270
290
|
/** GET /api/apim-management/key-detail/:subscriptionId — full 32-hex key. */
|
|
271
|
-
keyDetail(subscriptionId: string): Promise<
|
|
272
|
-
/** GET /api/apim-management/products — available
|
|
273
|
-
products(): Promise<
|
|
291
|
+
keyDetail(subscriptionId: string): Promise<ApiKeyDetail>;
|
|
292
|
+
/** GET /api/apim-management/products — available api products. */
|
|
293
|
+
products(): Promise<Product[]>;
|
|
274
294
|
/**
|
|
275
|
-
* POST /api/apim-management/generate-key — issue a new
|
|
295
|
+
* POST /api/apim-management/generate-key — issue a new api key.
|
|
276
296
|
* ⚠️ primaryKey is shown only in this response — store it immediately.
|
|
277
297
|
*/
|
|
278
298
|
generateKey(params: {
|
|
@@ -304,7 +324,7 @@ declare class AuthModule {
|
|
|
304
324
|
declare class GenerationModule {
|
|
305
325
|
private readonly t;
|
|
306
326
|
private readonly urls;
|
|
307
|
-
constructor(t: Transport, urls:
|
|
327
|
+
constructor(t: Transport, urls: ResolvedUrls);
|
|
308
328
|
private createJob;
|
|
309
329
|
textToVideo(params: TextToVideoParams): Promise<GenerationCreateResponse>;
|
|
310
330
|
imageToVideo(params: ImageToVideoParams): Promise<GenerationCreateResponse>;
|
|
@@ -336,7 +356,7 @@ declare class GenerationModule {
|
|
|
336
356
|
declare class MediaModule {
|
|
337
357
|
private readonly t;
|
|
338
358
|
private readonly urls;
|
|
339
|
-
constructor(t: Transport, urls:
|
|
359
|
+
constructor(t: Transport, urls: ResolvedUrls);
|
|
340
360
|
/** Presign a new upload slot. */
|
|
341
361
|
presign(params: PresignedUploadRequest): Promise<PresignedUploadResponse>;
|
|
342
362
|
/** Notify server that PUT to uploadUrl succeeded. */
|
|
@@ -363,7 +383,7 @@ declare class MediaModule {
|
|
|
363
383
|
declare class PresetModule {
|
|
364
384
|
private readonly t;
|
|
365
385
|
private readonly urls;
|
|
366
|
-
constructor(t: Transport, urls:
|
|
386
|
+
constructor(t: Transport, urls: ResolvedUrls);
|
|
367
387
|
list(email?: string): Promise<PresetItem[]>;
|
|
368
388
|
get(id: string): Promise<PresetItem>;
|
|
369
389
|
create(params: CreatePresetRequest): Promise<PresetItem>;
|
|
@@ -374,7 +394,7 @@ declare class PresetModule {
|
|
|
374
394
|
declare class AgentModule {
|
|
375
395
|
private readonly t;
|
|
376
396
|
private readonly urls;
|
|
377
|
-
constructor(t: Transport, urls:
|
|
397
|
+
constructor(t: Transport, urls: ResolvedUrls);
|
|
378
398
|
/** Creates an empty project to generate into. POST /video-project/create (APIM api-key). */
|
|
379
399
|
createProject(name: string): Promise<{
|
|
380
400
|
projectId: number;
|
|
@@ -399,7 +419,7 @@ declare class AgentModule {
|
|
|
399
419
|
*
|
|
400
420
|
* @example
|
|
401
421
|
* // With existing credentials:
|
|
402
|
-
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<
|
|
422
|
+
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<api-key>' });
|
|
403
423
|
* const { requestId, model } = await client.generation.textToVideo({ prompt: 'Space', model: 'wan' });
|
|
404
424
|
* const result = await client.generation.waitForResult({ requestId, model });
|
|
405
425
|
*
|
|
@@ -408,6 +428,14 @@ declare class AgentModule {
|
|
|
408
428
|
* const client = new KvidaiClient({});
|
|
409
429
|
* const { jwt, apiKey } = await client.auth.loginAndGetApiKey('user@example.com', 'password');
|
|
410
430
|
* client.setCredentials({ jwt, apiKey });
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* // Custom base URL (for internal/dev environments):
|
|
434
|
+
* const client = new KvidaiClient({
|
|
435
|
+
* baseUrl: 'https://api.kvid.ai',
|
|
436
|
+
* consoleBaseUrl: 'http://localhost:1337',
|
|
437
|
+
* generationPath: '/ai/generation-clone',
|
|
438
|
+
* });
|
|
411
439
|
*/
|
|
412
440
|
export declare class KvidaiClient {
|
|
413
441
|
private opts;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;IACzC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;AAE3D,UAAU,OAAO;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,U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@@
|
|
|
3
3
|
* @kvidai/sdk — kvidai TypeScript SDK
|
|
4
4
|
*
|
|
5
5
|
* Covers the 4 core external-client flows documented in docs/external-client-guide.md:
|
|
6
|
-
* 1. Auth — login +
|
|
7
|
-
* 2. Generation — AI video/image/voice creation + status polling + result fetch (api.kvid.ai
|
|
8
|
-
* 3. Media — presigned upload → CDN URL (api.kvid.ai
|
|
9
|
-
* 4. Preset — CRUD (api.kvid.ai
|
|
6
|
+
* 1. Auth — login + api-key management (console.kvid.ai / Strapi JWT)
|
|
7
|
+
* 2. Generation — AI video/image/voice creation + status polling + result fetch (api.kvid.ai)
|
|
8
|
+
* 3. Media — presigned upload → CDN URL (api.kvid.ai)
|
|
9
|
+
* 4. Preset — CRUD (api.kvid.ai)
|
|
10
10
|
*
|
|
11
11
|
* Usage:
|
|
12
|
-
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<
|
|
12
|
+
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<api-key>' });
|
|
13
13
|
* const { requestId, model } = await client.generation.textToVideo({ prompt: '...', model: 'wan' });
|
|
14
14
|
* const result = await client.generation.waitForResult({ requestId, model });
|
|
15
15
|
*
|
|
@@ -17,40 +17,17 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.KvidaiClient = exports.KvidaiError = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
staging: {
|
|
32
|
-
strapiBaseUrl: 'https://hometips-strapi-ts-staging1-405573518541.asia-northeast1.run.app',
|
|
33
|
-
apimBaseUrl: 'https://api.kvid.ai',
|
|
34
|
-
webBaseUrl: 'https://staging1.kvid.ai',
|
|
35
|
-
generationPath: '/ai/generation',
|
|
36
|
-
mediaPath: '/media',
|
|
37
|
-
presetPath: '/preset',
|
|
38
|
-
agentPath: '/agent',
|
|
39
|
-
videoProjectPath: '/video-project',
|
|
40
|
-
},
|
|
41
|
-
dev: {
|
|
42
|
-
strapiBaseUrl: 'http://localhost:1337',
|
|
43
|
-
apimBaseUrl: 'https://api.kvid.ai',
|
|
44
|
-
webBaseUrl: 'http://localhost:3000',
|
|
45
|
-
generationPath: '/ai/generation-clone',
|
|
46
|
-
mediaPath: '/media-dev',
|
|
47
|
-
presetPath: '/preset-dev',
|
|
48
|
-
// Agent + video-project use the same gateway paths across all envs (confirmed live 2026-10-30).
|
|
49
|
-
// No dev-clone equivalent exists for these endpoints.
|
|
50
|
-
agentPath: '/agent',
|
|
51
|
-
videoProjectPath: '/video-project',
|
|
52
|
-
},
|
|
53
|
-
};
|
|
20
|
+
function resolveUrls(opts) {
|
|
21
|
+
return {
|
|
22
|
+
consoleBaseUrl: opts.consoleBaseUrl ?? 'https://console.kvid.ai',
|
|
23
|
+
apiBaseUrl: opts.baseUrl ?? 'https://api.kvid.ai',
|
|
24
|
+
generationPath: opts.generationPath ?? '/ai/generation',
|
|
25
|
+
mediaPath: opts.mediaPath ?? '/media',
|
|
26
|
+
presetPath: opts.presetPath ?? '/preset',
|
|
27
|
+
agentPath: opts.agentPath ?? '/agent',
|
|
28
|
+
videoProjectPath: opts.videoProjectPath ?? '/video-project',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
54
31
|
class KvidaiError extends Error {
|
|
55
32
|
constructor(code, message, status, details) {
|
|
56
33
|
super(message);
|
|
@@ -80,11 +57,7 @@ class Transport {
|
|
|
80
57
|
return headers;
|
|
81
58
|
}
|
|
82
59
|
async request(base, path, init = {}) {
|
|
83
|
-
const baseUrl = base === 'strapi'
|
|
84
|
-
? this.urls.strapiBaseUrl
|
|
85
|
-
: base === 'web'
|
|
86
|
-
? this.urls.webBaseUrl
|
|
87
|
-
: this.urls.apimBaseUrl;
|
|
60
|
+
const baseUrl = base === 'strapi' ? this.urls.consoleBaseUrl : this.urls.apiBaseUrl;
|
|
88
61
|
const authType = base === 'strapi' ? 'strapi' : 'apim';
|
|
89
62
|
let res;
|
|
90
63
|
try {
|
|
@@ -119,11 +92,7 @@ class Transport {
|
|
|
119
92
|
* No automatic timeout is applied since SSE streams are long-running.
|
|
120
93
|
*/
|
|
121
94
|
async requestText(base, path, init = {}) {
|
|
122
|
-
const baseUrl = base === 'strapi'
|
|
123
|
-
? this.urls.strapiBaseUrl
|
|
124
|
-
: base === 'web'
|
|
125
|
-
? this.urls.webBaseUrl
|
|
126
|
-
: this.urls.apimBaseUrl;
|
|
95
|
+
const baseUrl = base === 'strapi' ? this.urls.consoleBaseUrl : this.urls.apiBaseUrl;
|
|
127
96
|
const authType = base === 'strapi' ? 'strapi' : 'apim';
|
|
128
97
|
let res;
|
|
129
98
|
try {
|
|
@@ -172,7 +141,7 @@ class AuthModule {
|
|
|
172
141
|
async me() {
|
|
173
142
|
return this.t.request('strapi', '/api/users/me');
|
|
174
143
|
}
|
|
175
|
-
/** GET /api/apim-management/my-keys — list active keys (masked). */
|
|
144
|
+
/** GET /api/apim-management/my-keys — list active api keys (masked). */
|
|
176
145
|
async listKeys() {
|
|
177
146
|
const res = await this.t.request('strapi', '/api/apim-management/my-keys');
|
|
178
147
|
return Array.isArray(res) ? res : (res.data ?? []);
|
|
@@ -183,14 +152,14 @@ class AuthModule {
|
|
|
183
152
|
// Controller wraps in { data: ... }
|
|
184
153
|
return res.data ?? res;
|
|
185
154
|
}
|
|
186
|
-
/** GET /api/apim-management/products — available
|
|
155
|
+
/** GET /api/apim-management/products — available api products. */
|
|
187
156
|
async products() {
|
|
188
157
|
const res = await this.t.request('strapi', '/api/apim-management/products');
|
|
189
158
|
const data = res.data ?? res;
|
|
190
159
|
return data.products ?? [];
|
|
191
160
|
}
|
|
192
161
|
/**
|
|
193
|
-
* POST /api/apim-management/generate-key — issue a new
|
|
162
|
+
* POST /api/apim-management/generate-key — issue a new api key.
|
|
194
163
|
* ⚠️ primaryKey is shown only in this response — store it immediately.
|
|
195
164
|
*/
|
|
196
165
|
async generateKey(params) {
|
|
@@ -242,7 +211,7 @@ class AuthModule {
|
|
|
242
211
|
// No key — generate one
|
|
243
212
|
const products = await this.products();
|
|
244
213
|
if (!products.length)
|
|
245
|
-
throw new KvidaiError('NO_PRODUCT', 'No
|
|
214
|
+
throw new KvidaiError('NO_PRODUCT', 'No API products available', 404);
|
|
246
215
|
const { primaryKey } = await this.generateKey({ email: user.email, productId: products[0].id });
|
|
247
216
|
return { jwt, apiKey: primaryKey, user };
|
|
248
217
|
}
|
|
@@ -527,12 +496,13 @@ function extractRenderUrl(raw) {
|
|
|
527
496
|
return null;
|
|
528
497
|
}
|
|
529
498
|
/**
|
|
530
|
-
* Parses a raw SSE stream text. Calls onEvent for each `event:`/`data:` pair.
|
|
531
|
-
* Returns all tool_start toolNames and the first error event payload.
|
|
499
|
+
* Parses a raw SSE stream text. Calls onEvent for each `event:`/`data:` pair; comment lines (`: heartbeat`) are ignored.
|
|
500
|
+
* Returns all tool_start toolNames, the tools that ended with success:false and the first error event payload.
|
|
532
501
|
* Mirrors apps/mobile-app/src/generation/agent-generate-client.ts parseSseEvents.
|
|
533
502
|
*/
|
|
534
503
|
function parseSseStream(text, onEvent) {
|
|
535
504
|
const tools = [];
|
|
505
|
+
const toolErrors = [];
|
|
536
506
|
let error = null;
|
|
537
507
|
let eventName = '';
|
|
538
508
|
for (const line of text.split('\n')) {
|
|
@@ -553,11 +523,19 @@ function parseSseStream(text, onEvent) {
|
|
|
553
523
|
const toolName = data?.toolName;
|
|
554
524
|
if (eventName === 'tool_start' && typeof toolName === 'string')
|
|
555
525
|
tools.push(toolName);
|
|
526
|
+
if (eventName === 'tool_end' && data?.success === false) {
|
|
527
|
+
const failed = data;
|
|
528
|
+
toolErrors.push({
|
|
529
|
+
...(typeof failed.toolUseId === 'string' ? { toolUseId: failed.toolUseId } : {}),
|
|
530
|
+
toolName: typeof failed.toolName === 'string' ? failed.toolName : '',
|
|
531
|
+
error: typeof failed.error === 'string' && failed.error ? failed.error : 'tool failed',
|
|
532
|
+
});
|
|
533
|
+
}
|
|
556
534
|
if (eventName === 'error' && error === null)
|
|
557
535
|
error = data;
|
|
558
536
|
}
|
|
559
537
|
}
|
|
560
|
-
return { tools, error };
|
|
538
|
+
return { tools, toolErrors, error };
|
|
561
539
|
}
|
|
562
540
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
563
541
|
// Agent module
|
|
@@ -601,10 +579,10 @@ class AgentModule {
|
|
|
601
579
|
: {}),
|
|
602
580
|
}),
|
|
603
581
|
});
|
|
604
|
-
const { tools, error } = parseSseStream(text, onEvent);
|
|
582
|
+
const { tools, toolErrors, error } = parseSseStream(text, onEvent);
|
|
605
583
|
if (error !== null)
|
|
606
584
|
throw new KvidaiError('AGENT_ERROR', 'the agent reported an error', 0, error);
|
|
607
|
-
return { tools };
|
|
585
|
+
return { tools, toolErrors };
|
|
608
586
|
}
|
|
609
587
|
/**
|
|
610
588
|
* Reads the result of an agent turn from the project. GET /video-project/:id (APIM api-key).
|
|
@@ -631,7 +609,7 @@ class AgentModule {
|
|
|
631
609
|
*
|
|
632
610
|
* @example
|
|
633
611
|
* // With existing credentials:
|
|
634
|
-
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<
|
|
612
|
+
* const client = new KvidaiClient({ jwt: '<strapi-jwt>', apiKey: '<api-key>' });
|
|
635
613
|
* const { requestId, model } = await client.generation.textToVideo({ prompt: 'Space', model: 'wan' });
|
|
636
614
|
* const result = await client.generation.waitForResult({ requestId, model });
|
|
637
615
|
*
|
|
@@ -640,11 +618,19 @@ class AgentModule {
|
|
|
640
618
|
* const client = new KvidaiClient({});
|
|
641
619
|
* const { jwt, apiKey } = await client.auth.loginAndGetApiKey('user@example.com', 'password');
|
|
642
620
|
* client.setCredentials({ jwt, apiKey });
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* // Custom base URL (for internal/dev environments):
|
|
624
|
+
* const client = new KvidaiClient({
|
|
625
|
+
* baseUrl: 'https://api.kvid.ai',
|
|
626
|
+
* consoleBaseUrl: 'http://localhost:1337',
|
|
627
|
+
* generationPath: '/ai/generation-clone',
|
|
628
|
+
* });
|
|
643
629
|
*/
|
|
644
630
|
class KvidaiClient {
|
|
645
631
|
constructor(options = {}) {
|
|
646
|
-
this.opts = {
|
|
647
|
-
const urls =
|
|
632
|
+
this.opts = { timeoutMs: 30000, ...options };
|
|
633
|
+
const urls = resolveUrls(this.opts);
|
|
648
634
|
this.transport = new Transport(this.opts, urls);
|
|
649
635
|
this.auth = new AuthModule(this.transport, this.opts);
|
|
650
636
|
this.generation = new GenerationModule(this.transport, urls);
|