totalum-sdk 0.1.0-dev.4 → 0.1.0-dev.5
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 +7 -3
- package/dist/_types/billing.d-Cj9gNbAW.d.ts +38 -0
- package/dist/_types/coerce.d-C1KWvgPp.d.ts +6 -0
- package/dist/_types/errors.d-ZrZKjL3U.d.ts +2991 -0
- package/dist/_types/integrations.d-Cii20Vl4.d.ts +793 -0
- package/dist/_types/ops.d-BIgDkhpR.d.ts +117 -0
- package/dist/ai/index.d.ts +424 -0
- package/dist/ai/index.js +185 -0
- package/dist/analytics/index.d.ts +35 -0
- package/dist/analytics/index.js +15 -0
- package/dist/browser/index.d.ts +1442 -0
- package/dist/browser/index.js +168 -0
- package/dist/cron/index.d.ts +180 -0
- package/dist/cron/index.js +61 -0
- package/dist/d1/errors.js +5 -13
- package/dist/d1/index.d.ts +90 -5
- package/dist/d1/index.js +6 -10
- package/dist/email/index.d.ts +31 -0
- package/dist/email/index.js +30 -0
- package/dist/errors.js +35 -0
- package/dist/files/index.d.ts +119 -0
- package/dist/files/index.js +63 -0
- package/dist/http.js +85 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +68 -0
- package/dist/logs/index.d.ts +51 -0
- package/dist/logs/index.js +18 -0
- package/dist/payments/index.d.ts +47 -0
- package/dist/payments/index.js +20 -0
- package/dist/pdf/index.d.ts +42 -0
- package/dist/pdf/index.js +17 -0
- package/dist/realtime/index.d.ts +68 -0
- package/dist/realtime/index.js +20 -0
- package/dist/scan/index.d.ts +46 -0
- package/dist/scan/index.js +12 -0
- package/dist/seo/index.d.ts +23 -0
- package/dist/seo/index.js +12 -0
- package/dist/speech/index.d.ts +41 -0
- package/dist/speech/index.js +22 -0
- package/dist/web/index.d.ts +170 -0
- package/dist/web/index.js +31 -0
- package/dist/webhooks/index.d.ts +48 -0
- package/dist/webhooks/index.js +61 -0
- package/package.json +77 -5
- package/totalum-sdk.md +1040 -0
- package/dist/d1/errors.d.ts +0 -27
- package/dist/d1/https.d.ts +0 -10
- package/dist/d1/lazy.d.ts +0 -7
- package/dist/d1/libsql.d.ts +0 -23
- package/dist/d1/sql.d.ts +0 -9
- package/dist/d1/types.d.ts +0 -72
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Z as ZodObject, c as ZodOptional, e as ZodArray, t as ZodISODateTime, u as $catchall, k as ZodNumber, d as ZodString, f as ZodEnum, m as $strip, q as ZodLiteral, j as ZodBoolean, o as output, v as ZodNullable, l as ZodInt } from './errors.d-ZrZKjL3U.js';
|
|
2
|
+
import { Z as ZodCoercedNumber } from './coerce.d-C1KWvgPp.js';
|
|
3
|
+
|
|
4
|
+
declare const SiteMetric: ZodEnum<{
|
|
5
|
+
bytes: "bytes";
|
|
6
|
+
errors: "errors";
|
|
7
|
+
page_views: "page_views";
|
|
8
|
+
hits: "hits";
|
|
9
|
+
uniques: "uniques";
|
|
10
|
+
ttfb_p50: "ttfb_p50";
|
|
11
|
+
ttfb_p95: "ttfb_p95";
|
|
12
|
+
}>;
|
|
13
|
+
type SiteMetric = output<typeof SiteMetric>;
|
|
14
|
+
declare const SiteDimension: ZodEnum<{
|
|
15
|
+
hostname: "hostname";
|
|
16
|
+
browser: "browser";
|
|
17
|
+
path: "path";
|
|
18
|
+
status: "status";
|
|
19
|
+
country: "country";
|
|
20
|
+
device: "device";
|
|
21
|
+
os: "os";
|
|
22
|
+
referrer: "referrer";
|
|
23
|
+
}>;
|
|
24
|
+
type SiteDimension = output<typeof SiteDimension>;
|
|
25
|
+
/** `series` for a time series, `top` when a `dimension` is asked; every count is `SUM(_sample_interval)`. */
|
|
26
|
+
declare const SiteAnalyticsOutput: ZodObject<{
|
|
27
|
+
series: ZodOptional<ZodArray<ZodObject<{
|
|
28
|
+
t: ZodISODateTime;
|
|
29
|
+
}, $catchall<ZodNumber>>>>;
|
|
30
|
+
top: ZodOptional<ZodArray<ZodObject<{
|
|
31
|
+
key: ZodString;
|
|
32
|
+
share: ZodNumber;
|
|
33
|
+
}, $catchall<ZodNumber>>>>;
|
|
34
|
+
window: ZodObject<{
|
|
35
|
+
from: ZodISODateTime;
|
|
36
|
+
to: ZodISODateTime;
|
|
37
|
+
granularity: ZodEnum<{
|
|
38
|
+
hour: "hour";
|
|
39
|
+
day: "day";
|
|
40
|
+
minute: "minute";
|
|
41
|
+
}>;
|
|
42
|
+
}, $strip>;
|
|
43
|
+
source: ZodLiteral<"wae">;
|
|
44
|
+
approximate: ZodObject<{
|
|
45
|
+
uniques: ZodBoolean;
|
|
46
|
+
}, $strip>;
|
|
47
|
+
cachedAt: ZodISODateTime;
|
|
48
|
+
}, $strip>;
|
|
49
|
+
type SiteAnalyticsOutput = output<typeof SiteAnalyticsOutput>;
|
|
50
|
+
/** `POST /projects/:id/logs/query` (PGM) = `GET /v1/logs` query (SDK-API). `env`: dev = preview, live = published. */
|
|
51
|
+
declare const LogsQueryInput: ZodObject<{
|
|
52
|
+
requestId: ZodOptional<ZodString>;
|
|
53
|
+
limit: ZodOptional<ZodCoercedNumber<unknown>>;
|
|
54
|
+
source: ZodOptional<ZodEnum<{
|
|
55
|
+
live: "live";
|
|
56
|
+
auto: "auto";
|
|
57
|
+
buffer: "buffer";
|
|
58
|
+
}>>;
|
|
59
|
+
env: ZodOptional<ZodEnum<{
|
|
60
|
+
dev: "dev";
|
|
61
|
+
live: "live";
|
|
62
|
+
}>>;
|
|
63
|
+
caller: ZodOptional<ZodLiteral<"agent">>;
|
|
64
|
+
runId: ZodOptional<ZodString>;
|
|
65
|
+
level: ZodOptional<ZodEnum<{
|
|
66
|
+
error: "error";
|
|
67
|
+
log: "log";
|
|
68
|
+
debug: "debug";
|
|
69
|
+
info: "info";
|
|
70
|
+
warn: "warn";
|
|
71
|
+
}>>;
|
|
72
|
+
q: ZodOptional<ZodString>;
|
|
73
|
+
status: ZodOptional<ZodString>;
|
|
74
|
+
path: ZodOptional<ZodString>;
|
|
75
|
+
from: ZodOptional<ZodISODateTime>;
|
|
76
|
+
to: ZodOptional<ZodISODateTime>;
|
|
77
|
+
}, $strip>;
|
|
78
|
+
type LogsQueryInput = output<typeof LogsQueryInput>;
|
|
79
|
+
declare const LogsPage: ZodObject<{
|
|
80
|
+
items: ZodArray<ZodObject<{
|
|
81
|
+
ts: ZodISODateTime;
|
|
82
|
+
level: ZodEnum<{
|
|
83
|
+
error: "error";
|
|
84
|
+
log: "log";
|
|
85
|
+
debug: "debug";
|
|
86
|
+
info: "info";
|
|
87
|
+
warn: "warn";
|
|
88
|
+
}>;
|
|
89
|
+
message: ZodString;
|
|
90
|
+
requestId: ZodNullable<ZodString>;
|
|
91
|
+
method: ZodNullable<ZodString>;
|
|
92
|
+
path: ZodNullable<ZodString>;
|
|
93
|
+
status: ZodNullable<ZodInt>;
|
|
94
|
+
cpuMs: ZodNullable<ZodNumber>;
|
|
95
|
+
wallMs: ZodNullable<ZodNumber>;
|
|
96
|
+
outcome: ZodString;
|
|
97
|
+
exception: ZodOptional<ZodObject<{
|
|
98
|
+
name: ZodString;
|
|
99
|
+
message: ZodString;
|
|
100
|
+
stack: ZodOptional<ZodString>;
|
|
101
|
+
}, $strip>>;
|
|
102
|
+
}, $strip>>;
|
|
103
|
+
window: ZodObject<{
|
|
104
|
+
from: ZodISODateTime;
|
|
105
|
+
to: ZodISODateTime;
|
|
106
|
+
source: ZodEnum<{
|
|
107
|
+
live: "live";
|
|
108
|
+
buffer: "buffer";
|
|
109
|
+
}>;
|
|
110
|
+
}, $strip>;
|
|
111
|
+
nextCursor: ZodNullable<ZodString>;
|
|
112
|
+
sampled: ZodBoolean;
|
|
113
|
+
hint: ZodOptional<ZodString>;
|
|
114
|
+
}, $strip>;
|
|
115
|
+
type LogsPage = output<typeof LogsPage>;
|
|
116
|
+
|
|
117
|
+
export { LogsPage as L, SiteAnalyticsOutput as S, SiteDimension as a, SiteMetric as b, LogsQueryInput as c };
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { Z as ZodObject, c as ZodOptional, d as ZodString, e as ZodArray, f as ZodEnum, g as ZodUnknown, $ as $loose, h as ZodRecord, j as ZodBoolean, k as ZodNumber, l as ZodInt, m as $strip, o as output, n as ZodUnion, p as ZodURL, q as ZodLiteral, T as TotalumClientOptions } from '../_types/errors.d-ZrZKjL3U.js';
|
|
2
|
+
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-ZrZKjL3U.js';
|
|
3
|
+
import { I as IntegrationUsage } from '../_types/billing.d-Cj9gNbAW.js';
|
|
4
|
+
import { SpeakInput, StoredMedia, TranscribeInput } from '../index.js';
|
|
5
|
+
import '../_types/coerce.d-C1KWvgPp.js';
|
|
6
|
+
|
|
7
|
+
/** `POST /v1/ai/chat` (integration `ai_text`); `stream:true` answers SSE ending with `AiStreamCreditsChunk`. */
|
|
8
|
+
declare const AiChatInput: ZodObject<{
|
|
9
|
+
model: ZodOptional<ZodString>;
|
|
10
|
+
messages: ZodArray<ZodObject<{
|
|
11
|
+
role: ZodEnum<{
|
|
12
|
+
user: "user";
|
|
13
|
+
system: "system";
|
|
14
|
+
assistant: "assistant";
|
|
15
|
+
tool: "tool";
|
|
16
|
+
developer: "developer";
|
|
17
|
+
}>;
|
|
18
|
+
content: ZodUnknown;
|
|
19
|
+
}, $loose>>;
|
|
20
|
+
tools: ZodOptional<ZodArray<ZodRecord<ZodString, ZodUnknown>>>;
|
|
21
|
+
toolChoice: ZodOptional<ZodUnknown>;
|
|
22
|
+
parallelToolCalls: ZodOptional<ZodBoolean>;
|
|
23
|
+
responseFormat: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
24
|
+
temperature: ZodOptional<ZodNumber>;
|
|
25
|
+
maxTokens: ZodOptional<ZodInt>;
|
|
26
|
+
reasoning: ZodOptional<ZodObject<{
|
|
27
|
+
effort: ZodString;
|
|
28
|
+
}, $strip>>;
|
|
29
|
+
serverTools: ZodOptional<ZodArray<ZodEnum<{
|
|
30
|
+
web_search: "web_search";
|
|
31
|
+
image_generation: "image_generation";
|
|
32
|
+
web_fetch: "web_fetch";
|
|
33
|
+
datetime: "datetime";
|
|
34
|
+
}>>>;
|
|
35
|
+
maxToolCalls: ZodOptional<ZodInt>;
|
|
36
|
+
stream: ZodOptional<ZodBoolean>;
|
|
37
|
+
cache: ZodOptional<ZodObject<{
|
|
38
|
+
ttlSec: ZodInt;
|
|
39
|
+
}, $strip>>;
|
|
40
|
+
zdr: ZodOptional<ZodBoolean>;
|
|
41
|
+
fastMode: ZodOptional<ZodBoolean>;
|
|
42
|
+
user: ZodOptional<ZodString>;
|
|
43
|
+
}, $strip>;
|
|
44
|
+
type AiChatInput = output<typeof AiChatInput>;
|
|
45
|
+
/** `POST /v1/ai/embed` (integration `ai_embed`): ≤ 256 inputs. */
|
|
46
|
+
declare const AiEmbedInput: ZodObject<{
|
|
47
|
+
model: ZodOptional<ZodString>;
|
|
48
|
+
input: ZodUnion<readonly [ZodString, ZodArray<ZodString>]>;
|
|
49
|
+
}, $strip>;
|
|
50
|
+
type AiEmbedInput = output<typeof AiEmbedInput>;
|
|
51
|
+
declare const AiEmbedOutput: ZodObject<{
|
|
52
|
+
embeddings: ZodArray<ZodArray<ZodNumber>>;
|
|
53
|
+
usage: ZodObject<{
|
|
54
|
+
credits: ZodNumber;
|
|
55
|
+
vendor: ZodOptional<ZodString>;
|
|
56
|
+
units: ZodOptional<ZodNumber>;
|
|
57
|
+
vendorCostUsd: ZodOptional<ZodNumber>;
|
|
58
|
+
}, $strip>;
|
|
59
|
+
}, $strip>;
|
|
60
|
+
type AiEmbedOutput = output<typeof AiEmbedOutput>;
|
|
61
|
+
/** `POST /v1/ai/image` (integration `ai_image`): stored in R2 through the storage gate. */
|
|
62
|
+
declare const AiImageInput: ZodObject<{
|
|
63
|
+
prompt: ZodString;
|
|
64
|
+
model: ZodOptional<ZodString>;
|
|
65
|
+
aspectRatio: ZodOptional<ZodString>;
|
|
66
|
+
resolution: ZodOptional<ZodEnum<{
|
|
67
|
+
512: "512";
|
|
68
|
+
"1K": "1K";
|
|
69
|
+
"2K": "2K";
|
|
70
|
+
"4K": "4K";
|
|
71
|
+
}>>;
|
|
72
|
+
quality: ZodOptional<ZodString>;
|
|
73
|
+
outputFormat: ZodOptional<ZodEnum<{
|
|
74
|
+
png: "png";
|
|
75
|
+
jpeg: "jpeg";
|
|
76
|
+
webp: "webp";
|
|
77
|
+
}>>;
|
|
78
|
+
background: ZodOptional<ZodString>;
|
|
79
|
+
n: ZodOptional<ZodInt>;
|
|
80
|
+
references: ZodOptional<ZodArray<ZodString>>;
|
|
81
|
+
fileName: ZodOptional<ZodString>;
|
|
82
|
+
store: ZodOptional<ZodBoolean>;
|
|
83
|
+
}, $strip>;
|
|
84
|
+
type AiImageInput = output<typeof AiImageInput>;
|
|
85
|
+
/** `POST /v1/ai/image/edit` (v1 `image-edit` parity: 1–16 source images). */
|
|
86
|
+
declare const AiImageEditInput: ZodObject<{
|
|
87
|
+
prompt: ZodString;
|
|
88
|
+
images: ZodArray<ZodURL>;
|
|
89
|
+
mask: ZodOptional<ZodString>;
|
|
90
|
+
fileName: ZodOptional<ZodString>;
|
|
91
|
+
size: ZodOptional<ZodString>;
|
|
92
|
+
quality: ZodOptional<ZodString>;
|
|
93
|
+
outputFormat: ZodOptional<ZodEnum<{
|
|
94
|
+
png: "png";
|
|
95
|
+
jpeg: "jpeg";
|
|
96
|
+
webp: "webp";
|
|
97
|
+
}>>;
|
|
98
|
+
background: ZodOptional<ZodString>;
|
|
99
|
+
inputFidelity: ZodOptional<ZodString>;
|
|
100
|
+
}, $strip>;
|
|
101
|
+
type AiImageEditInput = output<typeof AiImageEditInput>;
|
|
102
|
+
/** `images[]` in R2; the v1 compat keys `fileName`/`imageUrl` describe the first image. */
|
|
103
|
+
declare const AiImageOutput: ZodObject<{
|
|
104
|
+
images: ZodArray<ZodObject<{
|
|
105
|
+
key: ZodString;
|
|
106
|
+
url: ZodURL;
|
|
107
|
+
mediaType: ZodString;
|
|
108
|
+
width: ZodOptional<ZodInt>;
|
|
109
|
+
height: ZodOptional<ZodInt>;
|
|
110
|
+
}, $strip>>;
|
|
111
|
+
usage: ZodObject<{
|
|
112
|
+
credits: ZodNumber;
|
|
113
|
+
vendor: ZodOptional<ZodString>;
|
|
114
|
+
units: ZodOptional<ZodNumber>;
|
|
115
|
+
vendorCostUsd: ZodOptional<ZodNumber>;
|
|
116
|
+
}, $strip>;
|
|
117
|
+
fileName: ZodOptional<ZodString>;
|
|
118
|
+
imageUrl: ZodOptional<ZodURL>;
|
|
119
|
+
}, $strip>;
|
|
120
|
+
type AiImageOutput = output<typeof AiImageOutput>;
|
|
121
|
+
/** `POST /v1/ai/video` (integration `ai_video`, every plan incl. Free — A10.1): `202 AiVideoCreated`. */
|
|
122
|
+
declare const AiVideoInput: ZodObject<{
|
|
123
|
+
prompt: ZodString;
|
|
124
|
+
model: ZodOptional<ZodString>;
|
|
125
|
+
durationSec: ZodInt;
|
|
126
|
+
resolution: ZodOptional<ZodString>;
|
|
127
|
+
aspectRatio: ZodOptional<ZodString>;
|
|
128
|
+
firstFrame: ZodOptional<ZodString>;
|
|
129
|
+
lastFrame: ZodOptional<ZodString>;
|
|
130
|
+
references: ZodOptional<ZodArray<ZodString>>;
|
|
131
|
+
generateAudio: ZodOptional<ZodBoolean>;
|
|
132
|
+
seed: ZodOptional<ZodInt>;
|
|
133
|
+
webhook: ZodOptional<ZodBoolean>;
|
|
134
|
+
}, $strip>;
|
|
135
|
+
type AiVideoInput = output<typeof AiVideoInput>;
|
|
136
|
+
declare const AiVideoCreated: ZodObject<{
|
|
137
|
+
jobId: ZodString;
|
|
138
|
+
status: ZodLiteral<"queued">;
|
|
139
|
+
estimatedCredits: ZodNumber;
|
|
140
|
+
}, $strip>;
|
|
141
|
+
type AiVideoCreated = output<typeof AiVideoCreated>;
|
|
142
|
+
/** `GET /v1/ai/video/:jobId`; `failed`/`expired` settle to 0. */
|
|
143
|
+
declare const AiVideoJob: ZodObject<{
|
|
144
|
+
jobId: ZodString;
|
|
145
|
+
status: ZodEnum<{
|
|
146
|
+
queued: "queued";
|
|
147
|
+
running: "running";
|
|
148
|
+
completed: "completed";
|
|
149
|
+
failed: "failed";
|
|
150
|
+
cancelled: "cancelled";
|
|
151
|
+
expired: "expired";
|
|
152
|
+
}>;
|
|
153
|
+
progress: ZodOptional<ZodNumber>;
|
|
154
|
+
video: ZodOptional<ZodObject<{
|
|
155
|
+
key: ZodString;
|
|
156
|
+
url: ZodURL;
|
|
157
|
+
}, $strip>>;
|
|
158
|
+
usage: ZodOptional<ZodObject<{
|
|
159
|
+
credits: ZodNumber;
|
|
160
|
+
vendor: ZodOptional<ZodString>;
|
|
161
|
+
units: ZodOptional<ZodNumber>;
|
|
162
|
+
vendorCostUsd: ZodOptional<ZodNumber>;
|
|
163
|
+
}, $strip>>;
|
|
164
|
+
error: ZodOptional<ZodObject<{
|
|
165
|
+
code: ZodString;
|
|
166
|
+
message: ZodString;
|
|
167
|
+
}, $strip>>;
|
|
168
|
+
}, $strip>;
|
|
169
|
+
type AiVideoJob = output<typeof AiVideoJob>;
|
|
170
|
+
/** `POST /v1/ai/vision/describe`. */
|
|
171
|
+
declare const AiVisionDescribeInput: ZodObject<{
|
|
172
|
+
image: ZodString;
|
|
173
|
+
prompt: ZodOptional<ZodString>;
|
|
174
|
+
model: ZodOptional<ZodString>;
|
|
175
|
+
}, $strip>;
|
|
176
|
+
type AiVisionDescribeInput = output<typeof AiVisionDescribeInput>;
|
|
177
|
+
declare const AiTextOutput: ZodObject<{
|
|
178
|
+
text: ZodString;
|
|
179
|
+
usage: ZodObject<{
|
|
180
|
+
credits: ZodNumber;
|
|
181
|
+
vendor: ZodOptional<ZodString>;
|
|
182
|
+
units: ZodOptional<ZodNumber>;
|
|
183
|
+
vendorCostUsd: ZodOptional<ZodNumber>;
|
|
184
|
+
}, $strip>;
|
|
185
|
+
}, $strip>;
|
|
186
|
+
type AiTextOutput = output<typeof AiTextOutput>;
|
|
187
|
+
/** `GET /v1/ai/models` (cached 1 h). */
|
|
188
|
+
declare const AiModelsOutput: ZodObject<{
|
|
189
|
+
aliases: ZodObject<{
|
|
190
|
+
cheap: ZodString;
|
|
191
|
+
normal: ZodString;
|
|
192
|
+
best: ZodString;
|
|
193
|
+
}, $strip>;
|
|
194
|
+
models: ZodArray<ZodObject<{
|
|
195
|
+
slug: ZodString;
|
|
196
|
+
name: ZodString;
|
|
197
|
+
inputModalities: ZodArray<ZodString>;
|
|
198
|
+
pricing: ZodRecord<ZodString, ZodUnknown>;
|
|
199
|
+
contextLength: ZodInt;
|
|
200
|
+
}, $strip>>;
|
|
201
|
+
denylist: ZodOptional<ZodArray<ZodString>>;
|
|
202
|
+
}, $strip>;
|
|
203
|
+
type AiModelsOutput = output<typeof AiModelsOutput>;
|
|
204
|
+
|
|
205
|
+
interface TotalumAiOptions extends TotalumClientOptions {
|
|
206
|
+
/** The exact-OpenRouter gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
|
|
207
|
+
aiBaseUrl?: string;
|
|
208
|
+
}
|
|
209
|
+
interface ChatUsage {
|
|
210
|
+
inputTokens: number;
|
|
211
|
+
outputTokens: number;
|
|
212
|
+
costUsd: number;
|
|
213
|
+
credits: number;
|
|
214
|
+
}
|
|
215
|
+
interface ToolCall {
|
|
216
|
+
id: string;
|
|
217
|
+
type: string;
|
|
218
|
+
function: {
|
|
219
|
+
name: string;
|
|
220
|
+
arguments: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** `ai.chat()` (plan 05 §6.1): the first choice read out, the raw completion kept. */
|
|
224
|
+
interface ChatResult {
|
|
225
|
+
id: string;
|
|
226
|
+
model: string;
|
|
227
|
+
text: string;
|
|
228
|
+
toolCalls: ToolCall[];
|
|
229
|
+
finishReason: string | null;
|
|
230
|
+
usage: ChatUsage;
|
|
231
|
+
raw: unknown;
|
|
232
|
+
}
|
|
233
|
+
/** `ai.chat.stream()`: the OpenAI-format SSE (`raw`), its text deltas, and the result once it ends. */
|
|
234
|
+
interface ChatStream {
|
|
235
|
+
readonly raw: ReadableStream<Uint8Array>;
|
|
236
|
+
text(): AsyncIterable<string>;
|
|
237
|
+
result(): Promise<ChatResult>;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`): aliases `cheap|normal|best` or any
|
|
241
|
+
* OpenRouter slug, every call priced `usage.cost × 28` and returned with its credits. No `ai.agent()` (A5.27) — the
|
|
242
|
+
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
243
|
+
*/
|
|
244
|
+
declare function totalumAi(options?: TotalumAiOptions): {
|
|
245
|
+
chat: ((req: Omit<AiChatInput, "stream">) => Promise<ChatResult>) & {
|
|
246
|
+
/**
|
|
247
|
+
* The same request streamed: `raw` is the OpenAI-format SSE (return it from a route), `text()` its deltas,
|
|
248
|
+
* `result()` the final result with its credits.
|
|
249
|
+
*/
|
|
250
|
+
stream: (req: Omit<AiChatInput, "stream">) => Promise<ChatStream>;
|
|
251
|
+
};
|
|
252
|
+
generateObject: (req: {
|
|
253
|
+
schema: Record<string, unknown>;
|
|
254
|
+
prompt?: string;
|
|
255
|
+
messages?: AiChatInput["messages"];
|
|
256
|
+
model?: string;
|
|
257
|
+
healing?: boolean;
|
|
258
|
+
}) => Promise<{
|
|
259
|
+
object: unknown;
|
|
260
|
+
usage: IntegrationUsage;
|
|
261
|
+
}>;
|
|
262
|
+
/** Sugar over `generateObject`: one of `options`, chosen by the model. */
|
|
263
|
+
classify(req: {
|
|
264
|
+
input: string;
|
|
265
|
+
options: readonly string[];
|
|
266
|
+
model?: string;
|
|
267
|
+
instructions?: string;
|
|
268
|
+
}): Promise<{
|
|
269
|
+
label: string;
|
|
270
|
+
}>;
|
|
271
|
+
/** Embedding vectors for one or more texts. */
|
|
272
|
+
embed: (req: AiEmbedInput) => Promise<{
|
|
273
|
+
embeddings: number[][];
|
|
274
|
+
usage: {
|
|
275
|
+
credits: number;
|
|
276
|
+
vendor?: string | undefined;
|
|
277
|
+
units?: number | undefined;
|
|
278
|
+
vendorCostUsd?: number | undefined;
|
|
279
|
+
};
|
|
280
|
+
}>;
|
|
281
|
+
image: {
|
|
282
|
+
/** Images from a prompt; `store: true` keeps them as project files. */
|
|
283
|
+
generate: (req: AiImageInput) => Promise<{
|
|
284
|
+
images: {
|
|
285
|
+
key: string;
|
|
286
|
+
url: string;
|
|
287
|
+
mediaType: string;
|
|
288
|
+
width?: number | undefined;
|
|
289
|
+
height?: number | undefined;
|
|
290
|
+
}[];
|
|
291
|
+
usage: {
|
|
292
|
+
credits: number;
|
|
293
|
+
vendor?: string | undefined;
|
|
294
|
+
units?: number | undefined;
|
|
295
|
+
vendorCostUsd?: number | undefined;
|
|
296
|
+
};
|
|
297
|
+
fileName?: string | undefined;
|
|
298
|
+
imageUrl?: string | undefined;
|
|
299
|
+
}>;
|
|
300
|
+
/** An image edited by a prompt. */
|
|
301
|
+
edit: (req: AiImageEditInput) => Promise<{
|
|
302
|
+
images: {
|
|
303
|
+
key: string;
|
|
304
|
+
url: string;
|
|
305
|
+
mediaType: string;
|
|
306
|
+
width?: number | undefined;
|
|
307
|
+
height?: number | undefined;
|
|
308
|
+
}[];
|
|
309
|
+
usage: {
|
|
310
|
+
credits: number;
|
|
311
|
+
vendor?: string | undefined;
|
|
312
|
+
units?: number | undefined;
|
|
313
|
+
vendorCostUsd?: number | undefined;
|
|
314
|
+
};
|
|
315
|
+
fileName?: string | undefined;
|
|
316
|
+
imageUrl?: string | undefined;
|
|
317
|
+
}>;
|
|
318
|
+
};
|
|
319
|
+
video: {
|
|
320
|
+
/** `202`: the job and the credits reserved for it; poll `get(jobId)` (the clip is stored when it completes). */
|
|
321
|
+
generate: (req: AiVideoInput) => Promise<{
|
|
322
|
+
jobId: string;
|
|
323
|
+
status: "queued";
|
|
324
|
+
estimatedCredits: number;
|
|
325
|
+
}>;
|
|
326
|
+
/** The video job: `status`, and the stored clip once completed. */
|
|
327
|
+
get: (jobId: string) => Promise<{
|
|
328
|
+
jobId: string;
|
|
329
|
+
status: "queued" | "running" | "completed" | "failed" | "cancelled" | "expired";
|
|
330
|
+
progress?: number | undefined;
|
|
331
|
+
video?: {
|
|
332
|
+
key: string;
|
|
333
|
+
url: string;
|
|
334
|
+
} | undefined;
|
|
335
|
+
usage?: {
|
|
336
|
+
credits: number;
|
|
337
|
+
vendor?: string | undefined;
|
|
338
|
+
units?: number | undefined;
|
|
339
|
+
vendorCostUsd?: number | undefined;
|
|
340
|
+
} | undefined;
|
|
341
|
+
error?: {
|
|
342
|
+
code: string;
|
|
343
|
+
message: string;
|
|
344
|
+
} | undefined;
|
|
345
|
+
}>;
|
|
346
|
+
/**
|
|
347
|
+
* ⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most 10 min).
|
|
348
|
+
* In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` later instead.
|
|
349
|
+
*/
|
|
350
|
+
wait(jobId: string, opts?: {
|
|
351
|
+
intervalMs?: number;
|
|
352
|
+
timeoutMs?: number;
|
|
353
|
+
}): Promise<AiVideoJob>;
|
|
354
|
+
};
|
|
355
|
+
vision: {
|
|
356
|
+
/** A text description of an image (URL, data URL or project file key). */
|
|
357
|
+
describe: (req: AiVisionDescribeInput) => Promise<{
|
|
358
|
+
text: string;
|
|
359
|
+
usage: {
|
|
360
|
+
credits: number;
|
|
361
|
+
vendor?: string | undefined;
|
|
362
|
+
units?: number | undefined;
|
|
363
|
+
vendorCostUsd?: number | undefined;
|
|
364
|
+
};
|
|
365
|
+
}>;
|
|
366
|
+
};
|
|
367
|
+
speech: {
|
|
368
|
+
/** Same as `speech.synthesize`. */
|
|
369
|
+
speak: (input: SpeakInput) => Promise<StoredMedia | {
|
|
370
|
+
audio: ArrayBuffer;
|
|
371
|
+
contentType: string;
|
|
372
|
+
credits: number;
|
|
373
|
+
}>;
|
|
374
|
+
/** Same as `speech.transcribe`. */
|
|
375
|
+
transcribe: (input: TranscribeInput) => Promise<{
|
|
376
|
+
text: string;
|
|
377
|
+
durationSec: number;
|
|
378
|
+
usage: {
|
|
379
|
+
credits: number;
|
|
380
|
+
vendor?: string | undefined;
|
|
381
|
+
units?: number | undefined;
|
|
382
|
+
vendorCostUsd?: number | undefined;
|
|
383
|
+
};
|
|
384
|
+
language?: string | undefined;
|
|
385
|
+
segments?: {
|
|
386
|
+
start: number;
|
|
387
|
+
end: number;
|
|
388
|
+
text: string;
|
|
389
|
+
}[] | undefined;
|
|
390
|
+
words?: {
|
|
391
|
+
word: string;
|
|
392
|
+
start: number;
|
|
393
|
+
end: number;
|
|
394
|
+
}[] | undefined;
|
|
395
|
+
}>;
|
|
396
|
+
};
|
|
397
|
+
models: {
|
|
398
|
+
/** The model aliases and the models a project may call, with their prices. */
|
|
399
|
+
list: () => Promise<{
|
|
400
|
+
aliases: {
|
|
401
|
+
cheap: string;
|
|
402
|
+
normal: string;
|
|
403
|
+
best: string;
|
|
404
|
+
};
|
|
405
|
+
models: {
|
|
406
|
+
slug: string;
|
|
407
|
+
name: string;
|
|
408
|
+
inputModalities: string[];
|
|
409
|
+
pricing: Record<string, unknown>;
|
|
410
|
+
contextLength: number;
|
|
411
|
+
}[];
|
|
412
|
+
denylist?: string[] | undefined;
|
|
413
|
+
}>;
|
|
414
|
+
};
|
|
415
|
+
/** The exact OpenRouter API for any OpenRouter/OpenAI client (A6.19): `new OpenAI(ai.gatewayConfig())`. Server-side only. */
|
|
416
|
+
gatewayConfig: () => {
|
|
417
|
+
baseURL: string;
|
|
418
|
+
apiKey: string;
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
type TotalumAi = ReturnType<typeof totalumAi>;
|
|
422
|
+
|
|
423
|
+
export { AiChatInput, AiEmbedInput, AiEmbedOutput, AiImageEditInput, AiImageInput, AiImageOutput, AiModelsOutput, AiTextOutput, AiVideoCreated, AiVideoInput, AiVideoJob, AiVisionDescribeInput, TotalumClientOptions, totalumAi };
|
|
424
|
+
export type { ChatResult, ChatStream, ChatUsage, TotalumAi, TotalumAiOptions };
|