@tangle-network/tcloud 0.1.2 → 0.1.4
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-FL352XGA.js → chunk-KVXWEAK3.js} +204 -6
- package/dist/{chunk-76AB7HOV.js → chunk-PILYAKCF.js} +1 -1
- package/dist/cli.cjs +204 -6
- package/dist/cli.js +2 -2
- package/dist/index.cjs +204 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{shielded-6uJexMiT.d.cts → shielded-BTi_OftW.d.cts} +173 -3
- package/dist/{shielded-6uJexMiT.d.ts → shielded-BTi_OftW.d.ts} +173 -3
- package/dist/shielded.cjs +204 -6
- package/dist/shielded.d.cts +1 -1
- package/dist/shielded.d.ts +1 -1
- package/dist/shielded.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -98,14 +98,23 @@ var TCloudClient = class {
|
|
|
98
98
|
this.limits = config.limits;
|
|
99
99
|
this.headers = {
|
|
100
100
|
"Content-Type": "application/json",
|
|
101
|
-
"X-Tangle-Client": "tcloud-sdk/0.1.
|
|
101
|
+
"X-Tangle-Client": "tcloud-sdk/0.1.4"
|
|
102
102
|
};
|
|
103
103
|
if (this.apiKey) {
|
|
104
104
|
this.headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
105
105
|
}
|
|
106
|
+
if (config.routing?.mode) {
|
|
107
|
+
this.headers["X-Tangle-Routing"] = config.routing.mode;
|
|
108
|
+
}
|
|
106
109
|
if (config.routing?.prefer) {
|
|
107
110
|
this.headers["X-Tangle-Operator"] = config.routing.prefer;
|
|
108
111
|
}
|
|
112
|
+
if (config.routing?.blueprintId) {
|
|
113
|
+
this.headers["X-Tangle-Blueprint"] = config.routing.blueprintId;
|
|
114
|
+
}
|
|
115
|
+
if (config.routing?.serviceId) {
|
|
116
|
+
this.headers["X-Tangle-Service"] = config.routing.serviceId;
|
|
117
|
+
}
|
|
109
118
|
if (config.routing?.region) {
|
|
110
119
|
this.headers["X-Tangle-Region"] = config.routing.region;
|
|
111
120
|
}
|
|
@@ -142,12 +151,19 @@ var TCloudClient = class {
|
|
|
142
151
|
if (pct >= 0.8) this.limits.onLimitWarning({ type: "total", current: this._totalSpent, limit: this.limits.maxTotalSpend });
|
|
143
152
|
}
|
|
144
153
|
}
|
|
145
|
-
/** Track cost after a response */
|
|
146
|
-
trackCost(completion) {
|
|
154
|
+
/** Track cost after a response, using actual pricing from response headers when available */
|
|
155
|
+
trackCost(completion, res) {
|
|
147
156
|
this._requestCount++;
|
|
148
157
|
if (completion.usage) {
|
|
149
|
-
|
|
150
|
-
const
|
|
158
|
+
let estimatedCost;
|
|
159
|
+
const inputPrice = res ? parseFloat(res.headers.get("x-tangle-price-input") || "0") : 0;
|
|
160
|
+
const outputPrice = res ? parseFloat(res.headers.get("x-tangle-price-output") || "0") : 0;
|
|
161
|
+
if (inputPrice > 0 || outputPrice > 0) {
|
|
162
|
+
estimatedCost = (completion.usage.prompt_tokens || 0) * inputPrice + (completion.usage.completion_tokens || 0) * outputPrice;
|
|
163
|
+
} else {
|
|
164
|
+
const tokens = completion.usage.total_tokens || 0;
|
|
165
|
+
estimatedCost = tokens * 1e-6;
|
|
166
|
+
}
|
|
151
167
|
this._totalSpent += estimatedCost;
|
|
152
168
|
if (this.limits?.maxCostPerRequest && estimatedCost > this.limits.maxCostPerRequest) {
|
|
153
169
|
this.limits.onLimitReached?.({ type: "cost", current: estimatedCost, limit: this.limits.maxCostPerRequest });
|
|
@@ -185,7 +201,7 @@ var TCloudClient = class {
|
|
|
185
201
|
throw new TCloudError(res.status, err.error?.message || err.error || err.message || res.statusText);
|
|
186
202
|
}
|
|
187
203
|
const completion = await res.json();
|
|
188
|
-
this.trackCost(completion);
|
|
204
|
+
this.trackCost(completion, res);
|
|
189
205
|
return completion;
|
|
190
206
|
}
|
|
191
207
|
/** Chat completion (streaming) — returns an async iterator of chunks */
|
|
@@ -324,6 +340,188 @@ var TCloudClient = class {
|
|
|
324
340
|
}, false);
|
|
325
341
|
if (!res.ok) throw new TCloudError(res.status, "Failed to revoke key");
|
|
326
342
|
}
|
|
343
|
+
/** Generate embeddings */
|
|
344
|
+
async embeddings(options) {
|
|
345
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/embeddings`, {
|
|
346
|
+
method: "POST",
|
|
347
|
+
headers: this.headers,
|
|
348
|
+
body: JSON.stringify({
|
|
349
|
+
model: options.model || "text-embedding-3-small",
|
|
350
|
+
input: options.input
|
|
351
|
+
})
|
|
352
|
+
}, false);
|
|
353
|
+
if (!res.ok) {
|
|
354
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
355
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
356
|
+
}
|
|
357
|
+
this._requestCount++;
|
|
358
|
+
return res.json();
|
|
359
|
+
}
|
|
360
|
+
/** Generate images */
|
|
361
|
+
async imageGenerate(options) {
|
|
362
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/images/generations`, {
|
|
363
|
+
method: "POST",
|
|
364
|
+
headers: this.headers,
|
|
365
|
+
body: JSON.stringify({
|
|
366
|
+
model: options.model || "dall-e-3",
|
|
367
|
+
prompt: options.prompt,
|
|
368
|
+
n: options.n,
|
|
369
|
+
size: options.size,
|
|
370
|
+
quality: options.quality,
|
|
371
|
+
response_format: options.response_format
|
|
372
|
+
})
|
|
373
|
+
}, false);
|
|
374
|
+
if (!res.ok) {
|
|
375
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
376
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
377
|
+
}
|
|
378
|
+
this._requestCount++;
|
|
379
|
+
return res.json();
|
|
380
|
+
}
|
|
381
|
+
/** Rerank documents by relevance to a query */
|
|
382
|
+
async rerank(options) {
|
|
383
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/rerank`, {
|
|
384
|
+
method: "POST",
|
|
385
|
+
headers: this.headers,
|
|
386
|
+
body: JSON.stringify({
|
|
387
|
+
model: options.model || "rerank-english-v3.0",
|
|
388
|
+
query: options.query,
|
|
389
|
+
documents: options.documents,
|
|
390
|
+
top_n: options.top_n
|
|
391
|
+
})
|
|
392
|
+
}, false);
|
|
393
|
+
if (!res.ok) {
|
|
394
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
395
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
396
|
+
}
|
|
397
|
+
this._requestCount++;
|
|
398
|
+
return res.json();
|
|
399
|
+
}
|
|
400
|
+
/** Text-to-speech */
|
|
401
|
+
async speech(options) {
|
|
402
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/audio/speech`, {
|
|
403
|
+
method: "POST",
|
|
404
|
+
headers: this.headers,
|
|
405
|
+
body: JSON.stringify({
|
|
406
|
+
model: options.model || "tts-1",
|
|
407
|
+
input: options.input,
|
|
408
|
+
voice: options.voice || "alloy"
|
|
409
|
+
})
|
|
410
|
+
}, false);
|
|
411
|
+
if (!res.ok) {
|
|
412
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
413
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
414
|
+
}
|
|
415
|
+
this._requestCount++;
|
|
416
|
+
return res.arrayBuffer();
|
|
417
|
+
}
|
|
418
|
+
/** Legacy completions endpoint */
|
|
419
|
+
async completions(options) {
|
|
420
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/completions`, {
|
|
421
|
+
method: "POST",
|
|
422
|
+
headers: this.headers,
|
|
423
|
+
body: JSON.stringify({
|
|
424
|
+
model: options.model || this.model,
|
|
425
|
+
prompt: options.prompt,
|
|
426
|
+
temperature: options.temperature,
|
|
427
|
+
max_tokens: options.maxTokens,
|
|
428
|
+
stop: options.stop,
|
|
429
|
+
top_p: options.topP
|
|
430
|
+
})
|
|
431
|
+
}, false);
|
|
432
|
+
if (!res.ok) {
|
|
433
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
434
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
435
|
+
}
|
|
436
|
+
this._requestCount++;
|
|
437
|
+
return res.json();
|
|
438
|
+
}
|
|
439
|
+
/** Audio transcription (speech-to-text) */
|
|
440
|
+
async transcribe(file, options) {
|
|
441
|
+
const formData = new FormData();
|
|
442
|
+
formData.append("file", file, "audio.webm");
|
|
443
|
+
formData.append("model", options?.model || "whisper-1");
|
|
444
|
+
if (options?.language) formData.append("language", options.language);
|
|
445
|
+
if (options?.prompt) formData.append("prompt", options.prompt);
|
|
446
|
+
const headers = { ...this.headers };
|
|
447
|
+
delete headers["Content-Type"];
|
|
448
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/audio/transcriptions`, {
|
|
449
|
+
method: "POST",
|
|
450
|
+
headers,
|
|
451
|
+
body: formData
|
|
452
|
+
}, false);
|
|
453
|
+
if (!res.ok) {
|
|
454
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
455
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
456
|
+
}
|
|
457
|
+
this._requestCount++;
|
|
458
|
+
return res.json();
|
|
459
|
+
}
|
|
460
|
+
/** Create a fine-tuning job */
|
|
461
|
+
async fineTuneCreate(options) {
|
|
462
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/fine_tuning/jobs`, {
|
|
463
|
+
method: "POST",
|
|
464
|
+
headers: this.headers,
|
|
465
|
+
body: JSON.stringify(options)
|
|
466
|
+
}, false);
|
|
467
|
+
if (!res.ok) {
|
|
468
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
469
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
470
|
+
}
|
|
471
|
+
this._requestCount++;
|
|
472
|
+
return res.json();
|
|
473
|
+
}
|
|
474
|
+
/** List fine-tuning jobs */
|
|
475
|
+
async fineTuneList() {
|
|
476
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/fine_tuning/jobs`, {
|
|
477
|
+
headers: this.headers
|
|
478
|
+
}, false);
|
|
479
|
+
if (!res.ok) throw new TCloudError(res.status, "Failed to fetch fine-tuning jobs");
|
|
480
|
+
return res.json();
|
|
481
|
+
}
|
|
482
|
+
/** Submit a batch of chat requests */
|
|
483
|
+
async batch(requests) {
|
|
484
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/batch`, {
|
|
485
|
+
method: "POST",
|
|
486
|
+
headers: this.headers,
|
|
487
|
+
body: JSON.stringify({ requests })
|
|
488
|
+
}, false);
|
|
489
|
+
if (!res.ok) {
|
|
490
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
491
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
492
|
+
}
|
|
493
|
+
return res.json();
|
|
494
|
+
}
|
|
495
|
+
/** Get batch job status */
|
|
496
|
+
async batchStatus(jobId) {
|
|
497
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/batch?id=${jobId}`, {
|
|
498
|
+
headers: this.headers
|
|
499
|
+
}, false);
|
|
500
|
+
if (!res.ok) throw new TCloudError(res.status, "Failed to fetch batch status");
|
|
501
|
+
return res.json();
|
|
502
|
+
}
|
|
503
|
+
/** Generate video */
|
|
504
|
+
async videoGenerate(options) {
|
|
505
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/video/generate`, {
|
|
506
|
+
method: "POST",
|
|
507
|
+
headers: this.headers,
|
|
508
|
+
body: JSON.stringify(options)
|
|
509
|
+
}, false);
|
|
510
|
+
if (!res.ok) {
|
|
511
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
512
|
+
throw new TCloudError(res.status, err.error?.message || err.error || res.statusText);
|
|
513
|
+
}
|
|
514
|
+
this._requestCount++;
|
|
515
|
+
return res.json();
|
|
516
|
+
}
|
|
517
|
+
/** Get video generation status */
|
|
518
|
+
async videoStatus(id) {
|
|
519
|
+
const res = await proxiedFetch(this.privacy, `${this.baseURL}/video?id=${id}`, {
|
|
520
|
+
headers: this.headers
|
|
521
|
+
}, false);
|
|
522
|
+
if (!res.ok) throw new TCloudError(res.status, "Failed to fetch video status");
|
|
523
|
+
return res.json();
|
|
524
|
+
}
|
|
327
525
|
/** Search models by name, provider, or capability */
|
|
328
526
|
async searchModels(query) {
|
|
329
527
|
const all = await this.models();
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TCloudClient, a as TCloudConfig, S as ShieldedWallet, g as generateWallet } from './shielded-
|
|
2
|
-
export { C as ChatCompletion,
|
|
1
|
+
import { T as TCloudClient, a as TCloudConfig, S as ShieldedWallet, g as generateWallet } from './shielded-BTi_OftW.cjs';
|
|
2
|
+
export { B as BatchJobResponse, b as BatchRequest, C as ChatCompletion, c as ChatCompletionChunk, d as ChatMessage, e as ChatOptions, f as CompletionOptions, h as CompletionResponse, i as CreditBalance, E as EmbeddingOptions, j as EmbeddingResponse, F as FineTuningJob, k as FineTuningJobOptions, I as ImageGenerateOptions, l as ImageResponse, M as Model, O as Operator, P as PrivacyConfig, R as RerankOptions, m as RerankResponse, n as RoutingConfig, o as ShieldedConfig, p as SpendAuth, q as SpendingLimits, r as TCloudError, s as TranscriptionResponse, V as VideoGenerateOptions, t as VideoResponse, u as createShieldedClient, v as estimateCost, w as signSpendAuth } from './shielded-BTi_OftW.cjs';
|
|
3
3
|
import 'viem';
|
|
4
4
|
|
|
5
5
|
declare class TCloud extends TCloudClient {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TCloudClient, a as TCloudConfig, S as ShieldedWallet, g as generateWallet } from './shielded-
|
|
2
|
-
export { C as ChatCompletion,
|
|
1
|
+
import { T as TCloudClient, a as TCloudConfig, S as ShieldedWallet, g as generateWallet } from './shielded-BTi_OftW.js';
|
|
2
|
+
export { B as BatchJobResponse, b as BatchRequest, C as ChatCompletion, c as ChatCompletionChunk, d as ChatMessage, e as ChatOptions, f as CompletionOptions, h as CompletionResponse, i as CreditBalance, E as EmbeddingOptions, j as EmbeddingResponse, F as FineTuningJob, k as FineTuningJobOptions, I as ImageGenerateOptions, l as ImageResponse, M as Model, O as Operator, P as PrivacyConfig, R as RerankOptions, m as RerankResponse, n as RoutingConfig, o as ShieldedConfig, p as SpendAuth, q as SpendingLimits, r as TCloudError, s as TranscriptionResponse, V as VideoGenerateOptions, t as VideoResponse, u as createShieldedClient, v as estimateCost, w as signSpendAuth } from './shielded-BTi_OftW.js';
|
|
3
3
|
import 'viem';
|
|
4
4
|
|
|
5
5
|
declare class TCloud extends TCloudClient {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TCloud
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PILYAKCF.js";
|
|
4
4
|
import {
|
|
5
5
|
TCloudClient,
|
|
6
6
|
TCloudError,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
estimateCost,
|
|
9
9
|
generateWallet,
|
|
10
10
|
signSpendAuth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-KVXWEAK3.js";
|
|
12
12
|
export {
|
|
13
13
|
TCloud,
|
|
14
14
|
TCloudClient,
|
|
@@ -38,8 +38,14 @@ interface SpendingLimits {
|
|
|
38
38
|
}) => void;
|
|
39
39
|
}
|
|
40
40
|
interface RoutingConfig {
|
|
41
|
-
/**
|
|
41
|
+
/** Routing mode: 'operator' (Tangle operators only), 'provider' (direct APIs only), 'auto' (try operators, fall back to providers) */
|
|
42
|
+
mode?: 'operator' | 'provider' | 'auto';
|
|
43
|
+
/** Preferred operator slug or address */
|
|
42
44
|
prefer?: string;
|
|
45
|
+
/** Blueprint ID — route to operators under this Blueprint */
|
|
46
|
+
blueprintId?: string;
|
|
47
|
+
/** Service instance ID — route to a specific service instance */
|
|
48
|
+
serviceId?: string;
|
|
43
49
|
/** Routing strategy */
|
|
44
50
|
strategy?: 'lowest-latency' | 'lowest-price' | 'highest-reputation' | 'round-robin';
|
|
45
51
|
/** Region filter */
|
|
@@ -47,6 +53,136 @@ interface RoutingConfig {
|
|
|
47
53
|
/** Fallback operator slugs (tried in order) */
|
|
48
54
|
fallback?: string[];
|
|
49
55
|
}
|
|
56
|
+
interface EmbeddingOptions {
|
|
57
|
+
model?: string;
|
|
58
|
+
input: string | string[];
|
|
59
|
+
}
|
|
60
|
+
interface EmbeddingResponse {
|
|
61
|
+
object: string;
|
|
62
|
+
data: {
|
|
63
|
+
object: string;
|
|
64
|
+
embedding: number[];
|
|
65
|
+
index: number;
|
|
66
|
+
}[];
|
|
67
|
+
model: string;
|
|
68
|
+
usage: {
|
|
69
|
+
prompt_tokens: number;
|
|
70
|
+
total_tokens: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
interface ImageGenerateOptions {
|
|
74
|
+
model?: string;
|
|
75
|
+
prompt: string;
|
|
76
|
+
n?: number;
|
|
77
|
+
size?: string;
|
|
78
|
+
quality?: string;
|
|
79
|
+
response_format?: 'url' | 'b64_json';
|
|
80
|
+
}
|
|
81
|
+
interface ImageResponse {
|
|
82
|
+
created: number;
|
|
83
|
+
data: {
|
|
84
|
+
url?: string;
|
|
85
|
+
b64_json?: string;
|
|
86
|
+
revised_prompt?: string;
|
|
87
|
+
}[];
|
|
88
|
+
}
|
|
89
|
+
interface RerankOptions {
|
|
90
|
+
model?: string;
|
|
91
|
+
query: string;
|
|
92
|
+
documents: string[];
|
|
93
|
+
top_n?: number;
|
|
94
|
+
}
|
|
95
|
+
interface RerankResponse {
|
|
96
|
+
results: {
|
|
97
|
+
index: number;
|
|
98
|
+
relevance_score: number;
|
|
99
|
+
}[];
|
|
100
|
+
}
|
|
101
|
+
interface CompletionOptions {
|
|
102
|
+
model?: string;
|
|
103
|
+
prompt: string;
|
|
104
|
+
temperature?: number;
|
|
105
|
+
maxTokens?: number;
|
|
106
|
+
stop?: string | string[];
|
|
107
|
+
topP?: number;
|
|
108
|
+
}
|
|
109
|
+
interface CompletionResponse {
|
|
110
|
+
id: string;
|
|
111
|
+
object: string;
|
|
112
|
+
created: number;
|
|
113
|
+
model: string;
|
|
114
|
+
choices: {
|
|
115
|
+
text: string;
|
|
116
|
+
index: number;
|
|
117
|
+
finish_reason: string;
|
|
118
|
+
}[];
|
|
119
|
+
usage?: {
|
|
120
|
+
prompt_tokens: number;
|
|
121
|
+
completion_tokens: number;
|
|
122
|
+
total_tokens: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
interface TranscriptionResponse {
|
|
126
|
+
text: string;
|
|
127
|
+
}
|
|
128
|
+
interface FineTuningJobOptions {
|
|
129
|
+
model: string;
|
|
130
|
+
training_file: string;
|
|
131
|
+
hyperparameters?: {
|
|
132
|
+
n_epochs?: number | 'auto';
|
|
133
|
+
batch_size?: number | 'auto';
|
|
134
|
+
learning_rate_multiplier?: number | 'auto';
|
|
135
|
+
};
|
|
136
|
+
suffix?: string;
|
|
137
|
+
}
|
|
138
|
+
interface FineTuningJob {
|
|
139
|
+
id: string;
|
|
140
|
+
object: string;
|
|
141
|
+
model: string;
|
|
142
|
+
status: string;
|
|
143
|
+
created_at: number;
|
|
144
|
+
finished_at: number | null;
|
|
145
|
+
fine_tuned_model: string | null;
|
|
146
|
+
error: {
|
|
147
|
+
code: string;
|
|
148
|
+
message: string;
|
|
149
|
+
} | null;
|
|
150
|
+
}
|
|
151
|
+
interface BatchRequest {
|
|
152
|
+
model: string;
|
|
153
|
+
messages: ChatMessage[];
|
|
154
|
+
temperature?: number;
|
|
155
|
+
max_tokens?: number;
|
|
156
|
+
}
|
|
157
|
+
interface BatchJobResponse {
|
|
158
|
+
id: string;
|
|
159
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
160
|
+
total_items: number;
|
|
161
|
+
completed: number;
|
|
162
|
+
failed: number;
|
|
163
|
+
results: ({
|
|
164
|
+
status: 'fulfilled';
|
|
165
|
+
data: ChatCompletion;
|
|
166
|
+
} | {
|
|
167
|
+
status: 'rejected';
|
|
168
|
+
error: string;
|
|
169
|
+
})[] | null;
|
|
170
|
+
error: string | null;
|
|
171
|
+
created_at: string;
|
|
172
|
+
completed_at: string | null;
|
|
173
|
+
}
|
|
174
|
+
interface VideoGenerateOptions {
|
|
175
|
+
model?: string;
|
|
176
|
+
prompt: string;
|
|
177
|
+
duration?: number;
|
|
178
|
+
resolution?: string;
|
|
179
|
+
}
|
|
180
|
+
interface VideoResponse {
|
|
181
|
+
id: string;
|
|
182
|
+
status: string;
|
|
183
|
+
url?: string;
|
|
184
|
+
error?: string;
|
|
185
|
+
}
|
|
50
186
|
interface PrivacyConfig {
|
|
51
187
|
/** 'direct' — no proxy (default). 'relayer' — route through tcloud-relayer. 'socks5' — route through SOCKS5 proxy (e.g. Tor). */
|
|
52
188
|
mode: 'direct' | 'relayer' | 'socks5';
|
|
@@ -225,7 +361,7 @@ declare class TCloudClient {
|
|
|
225
361
|
};
|
|
226
362
|
/** Check spending limits before a request. Throws TCloudError if blocked. */
|
|
227
363
|
private checkLimits;
|
|
228
|
-
/** Track cost after a response */
|
|
364
|
+
/** Track cost after a response, using actual pricing from response headers when available */
|
|
229
365
|
private trackCost;
|
|
230
366
|
/** Chat completion (non-streaming) */
|
|
231
367
|
chat(options: ChatOptions): Promise<ChatCompletion>;
|
|
@@ -265,6 +401,40 @@ declare class TCloudClient {
|
|
|
265
401
|
}[]>;
|
|
266
402
|
/** Revoke an API key */
|
|
267
403
|
revokeKey(id: string): Promise<void>;
|
|
404
|
+
/** Generate embeddings */
|
|
405
|
+
embeddings(options: EmbeddingOptions): Promise<EmbeddingResponse>;
|
|
406
|
+
/** Generate images */
|
|
407
|
+
imageGenerate(options: ImageGenerateOptions): Promise<ImageResponse>;
|
|
408
|
+
/** Rerank documents by relevance to a query */
|
|
409
|
+
rerank(options: RerankOptions): Promise<RerankResponse>;
|
|
410
|
+
/** Text-to-speech */
|
|
411
|
+
speech(options: {
|
|
412
|
+
model?: string;
|
|
413
|
+
input: string;
|
|
414
|
+
voice?: string;
|
|
415
|
+
}): Promise<ArrayBuffer>;
|
|
416
|
+
/** Legacy completions endpoint */
|
|
417
|
+
completions(options: CompletionOptions): Promise<CompletionResponse>;
|
|
418
|
+
/** Audio transcription (speech-to-text) */
|
|
419
|
+
transcribe(file: Blob, options?: {
|
|
420
|
+
model?: string;
|
|
421
|
+
language?: string;
|
|
422
|
+
prompt?: string;
|
|
423
|
+
}): Promise<TranscriptionResponse>;
|
|
424
|
+
/** Create a fine-tuning job */
|
|
425
|
+
fineTuneCreate(options: FineTuningJobOptions): Promise<FineTuningJob>;
|
|
426
|
+
/** List fine-tuning jobs */
|
|
427
|
+
fineTuneList(): Promise<{
|
|
428
|
+
data: FineTuningJob[];
|
|
429
|
+
}>;
|
|
430
|
+
/** Submit a batch of chat requests */
|
|
431
|
+
batch(requests: BatchRequest[]): Promise<BatchJobResponse>;
|
|
432
|
+
/** Get batch job status */
|
|
433
|
+
batchStatus(jobId: string): Promise<BatchJobResponse>;
|
|
434
|
+
/** Generate video */
|
|
435
|
+
videoGenerate(options: VideoGenerateOptions): Promise<VideoResponse>;
|
|
436
|
+
/** Get video generation status */
|
|
437
|
+
videoStatus(id: string): Promise<VideoResponse>;
|
|
268
438
|
/** Search models by name, provider, or capability */
|
|
269
439
|
searchModels(query: string): Promise<Model[]>;
|
|
270
440
|
/** Estimate cost for a request (without sending it) */
|
|
@@ -340,4 +510,4 @@ declare function createShieldedClient(config?: TCloudConfig & {
|
|
|
340
510
|
stopAutoReplenish: () => void;
|
|
341
511
|
};
|
|
342
512
|
|
|
343
|
-
export { type AutoReplenishOptions as A, type ChatCompletion as C, type Model as M, type Operator as O, type PrivacyConfig as P, type
|
|
513
|
+
export { type AutoReplenishOptions as A, type BatchJobResponse as B, type ChatCompletion as C, type EmbeddingOptions as E, type FineTuningJob as F, type ImageGenerateOptions as I, type Model as M, type Operator as O, type PrivacyConfig as P, type RerankOptions as R, type ShieldedWallet as S, TCloudClient as T, type VideoGenerateOptions as V, type TCloudConfig as a, type BatchRequest as b, type ChatCompletionChunk as c, type ChatMessage as d, type ChatOptions as e, type CompletionOptions as f, generateWallet as g, type CompletionResponse as h, type CreditBalance as i, type EmbeddingResponse as j, type FineTuningJobOptions as k, type ImageResponse as l, type RerankResponse as m, type RoutingConfig as n, type ShieldedConfig as o, type SpendAuth as p, type SpendingLimits as q, TCloudError as r, type TranscriptionResponse as s, type VideoResponse as t, createShieldedClient as u, estimateCost as v, signSpendAuth as w };
|