segmind 0.2.4 → 0.3.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/README.md +50 -2
- package/dist/index.cjs +221 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +226 -80
- package/dist/index.d.ts +226 -80
- package/dist/index.js +221 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
2
|
+
/** Returns the signed-in user's token, or null when there is none. Called before every request. */
|
|
3
|
+
type TokenProvider = () => string | null | undefined | Promise<string | null | undefined>;
|
|
4
|
+
/** Milliseconds between status checks: fixed, or worked out from the milliseconds elapsed so far. */
|
|
5
|
+
type PollInterval = number | ((elapsedMs: number) => number);
|
|
6
|
+
interface HttpConfig {
|
|
7
|
+
apiKey: string | undefined;
|
|
8
|
+
tokenProvider?: TokenProvider;
|
|
9
|
+
onUnauthorized?: () => void | Promise<void>;
|
|
10
|
+
fetch: typeof fetch;
|
|
11
|
+
timeout: number;
|
|
12
|
+
maxRetries: number;
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
interface HttpRequest {
|
|
16
|
+
method: HttpMethod;
|
|
17
|
+
url: string;
|
|
18
|
+
/** Query parameters; `undefined` values are left out. */
|
|
19
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
20
|
+
/** Sent as JSON. */
|
|
21
|
+
body?: unknown;
|
|
22
|
+
/** Sent as is, instead of a JSON `body`. */
|
|
23
|
+
rawBody?: Uint8Array | Blob;
|
|
24
|
+
/**
|
|
25
|
+
* Send only `headers`: no API key, no `X-Initiator`, no default headers. For
|
|
26
|
+
* presigned URLs on other hosts, which must never see the key.
|
|
27
|
+
*/
|
|
28
|
+
bare?: boolean;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
/** Milliseconds for this attempt; defaults to the client's timeout. */
|
|
32
|
+
timeout?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Retry connection errors and retryable statuses. Only for requests that
|
|
35
|
+
* cannot bill twice: reads, polls, and v2 submits that carry an
|
|
36
|
+
* `X-Request-ID` (the gateway answers a repeat with 409, not a second job).
|
|
37
|
+
*/
|
|
38
|
+
retry?: boolean;
|
|
39
|
+
}
|
|
40
|
+
declare class HttpClient {
|
|
41
|
+
readonly config: HttpConfig;
|
|
42
|
+
/** The hook call in flight, so that requests failing together share one refresh. */
|
|
43
|
+
private unauthorized;
|
|
44
|
+
constructor(config: HttpConfig);
|
|
45
|
+
/** The response whatever its status, after retries when `retry` is set. */
|
|
46
|
+
fetchRaw(req: HttpRequest): Promise<Response>;
|
|
47
|
+
/** The response, or a `SegmindError` for any status outside 2xx. */
|
|
48
|
+
request(req: HttpRequest): Promise<Response>;
|
|
49
|
+
/** The parsed JSON body of a 2xx response. */
|
|
50
|
+
json<T>(req: HttpRequest): Promise<T>;
|
|
51
|
+
private sessionToken;
|
|
52
|
+
/** Tells the app its token was refused. True when it now has a different one to try. */
|
|
53
|
+
private reauthenticate;
|
|
54
|
+
private attempt;
|
|
55
|
+
}
|
|
56
|
+
|
|
1
57
|
/** Model inputs, forwarded to the model exactly as given. */
|
|
2
58
|
type Params = Record<string, unknown>;
|
|
3
59
|
/** A v2 request's state. */
|
|
@@ -34,13 +90,26 @@ interface SubmitResponse {
|
|
|
34
90
|
poll_url?: string;
|
|
35
91
|
[key: string]: unknown;
|
|
36
92
|
}
|
|
37
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Which surface a request is recorded under in usage history. Known values are
|
|
95
|
+
* listed, but any string is accepted: the platform records one it does not know
|
|
96
|
+
* as `OTHERS`, and values are case-sensitive. Give the bare name: the gateway
|
|
97
|
+
* adds the `-V2` itself on queued requests.
|
|
98
|
+
*/
|
|
99
|
+
type Initiator = 'API' | 'WEBPROD' | 'WEBSTAGE' | 'WORKFLOWS' | 'MCP' | 'AGENT' | 'PIXIE' | 'SDK-JS' | (string & {});
|
|
100
|
+
interface InitiatorOptions {
|
|
101
|
+
/** Overrides the client's `initiator` for this request. */
|
|
102
|
+
initiator?: Initiator;
|
|
103
|
+
/** Overrides the client's `initiatorId`: what the request belongs to, such as a workflow id. */
|
|
104
|
+
initiatorId?: string;
|
|
105
|
+
}
|
|
106
|
+
interface CallOptions extends InitiatorOptions {
|
|
38
107
|
/** Cancels the call. */
|
|
39
108
|
signal?: AbortSignal;
|
|
40
109
|
/** Milliseconds per HTTP request; defaults to the client's `timeout`. */
|
|
41
110
|
timeout?: number;
|
|
42
111
|
}
|
|
43
|
-
interface SubmitOptions {
|
|
112
|
+
interface SubmitOptions extends InitiatorOptions {
|
|
44
113
|
signal?: AbortSignal;
|
|
45
114
|
/**
|
|
46
115
|
* Idempotency key sent as `X-Request-ID` ([A-Za-z0-9_-]{8,128}). Submitting
|
|
@@ -53,8 +122,13 @@ interface WaitOptions {
|
|
|
53
122
|
signal?: AbortSignal;
|
|
54
123
|
/** Give up after this many milliseconds. Default 600 000 (10 minutes). */
|
|
55
124
|
timeout?: number;
|
|
56
|
-
/**
|
|
57
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Milliseconds between status checks, or a function of the milliseconds
|
|
127
|
+
* elapsed since `wait()` began, for a schedule. Default 1000.
|
|
128
|
+
*/
|
|
129
|
+
interval?: PollInterval;
|
|
130
|
+
/** Called with every status read, including the final one. */
|
|
131
|
+
onStatus?: (status: JobStatus) => void;
|
|
58
132
|
}
|
|
59
133
|
type RunOptions = SubmitOptions & WaitOptions;
|
|
60
134
|
|
|
@@ -94,51 +168,6 @@ declare class ChatResponse {
|
|
|
94
168
|
get toolCalls(): unknown[];
|
|
95
169
|
}
|
|
96
170
|
|
|
97
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
98
|
-
interface HttpConfig {
|
|
99
|
-
apiKey: string | undefined;
|
|
100
|
-
fetch: typeof fetch;
|
|
101
|
-
timeout: number;
|
|
102
|
-
maxRetries: number;
|
|
103
|
-
headers: Record<string, string>;
|
|
104
|
-
}
|
|
105
|
-
interface HttpRequest {
|
|
106
|
-
method: HttpMethod;
|
|
107
|
-
url: string;
|
|
108
|
-
/** Query parameters; `undefined` values are left out. */
|
|
109
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
110
|
-
/** Sent as JSON. */
|
|
111
|
-
body?: unknown;
|
|
112
|
-
/** Sent as is, instead of a JSON `body`. */
|
|
113
|
-
rawBody?: Uint8Array | Blob;
|
|
114
|
-
/**
|
|
115
|
-
* Send only `headers`: no API key, no `X-Initiator`, no default headers. For
|
|
116
|
-
* presigned URLs on other hosts, which must never see the key.
|
|
117
|
-
*/
|
|
118
|
-
bare?: boolean;
|
|
119
|
-
headers?: Record<string, string>;
|
|
120
|
-
signal?: AbortSignal;
|
|
121
|
-
/** Milliseconds for this attempt; defaults to the client's timeout. */
|
|
122
|
-
timeout?: number;
|
|
123
|
-
/**
|
|
124
|
-
* Retry connection errors and retryable statuses. Only for requests that
|
|
125
|
-
* cannot bill twice: reads, polls, and v2 submits that carry an
|
|
126
|
-
* `X-Request-ID` (the gateway answers a repeat with 409, not a second job).
|
|
127
|
-
*/
|
|
128
|
-
retry?: boolean;
|
|
129
|
-
}
|
|
130
|
-
declare class HttpClient {
|
|
131
|
-
readonly config: HttpConfig;
|
|
132
|
-
constructor(config: HttpConfig);
|
|
133
|
-
/** The response whatever its status, after retries when `retry` is set. */
|
|
134
|
-
fetchRaw(req: HttpRequest): Promise<Response>;
|
|
135
|
-
/** The response, or a `SegmindError` for any status outside 2xx. */
|
|
136
|
-
request(req: HttpRequest): Promise<Response>;
|
|
137
|
-
/** The parsed JSON body of a 2xx response. */
|
|
138
|
-
json<T>(req: HttpRequest): Promise<T>;
|
|
139
|
-
private attempt;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
171
|
/** A file to send: a path (Node only), a `Blob` or `File`, or raw bytes. */
|
|
143
172
|
type FileInput = string | Blob | ArrayBuffer | Uint8Array;
|
|
144
173
|
|
|
@@ -287,22 +316,22 @@ declare const DEFAULT_WAIT_INTERVAL_MS = 1000;
|
|
|
287
316
|
*/
|
|
288
317
|
declare class Job<T = RunResult> {
|
|
289
318
|
private readonly http;
|
|
290
|
-
/** The body the submit returned. */
|
|
319
|
+
/** The body the submit returned. A job rebuilt with `segmind.job()` has only its id and URLs. */
|
|
291
320
|
readonly submitResponse: SubmitResponse;
|
|
292
321
|
private readonly transform;
|
|
293
322
|
readonly requestId: string;
|
|
294
323
|
readonly statusUrl: string;
|
|
295
324
|
readonly responseUrl: string;
|
|
296
325
|
constructor(http: HttpClient,
|
|
297
|
-
/** The body the submit returned. */
|
|
326
|
+
/** The body the submit returned. A job rebuilt with `segmind.job()` has only its id and URLs. */
|
|
298
327
|
submitResponse: SubmitResponse, transform?: (body: RunResult) => T);
|
|
299
328
|
/** The current state, without waiting. */
|
|
300
329
|
status(options?: {
|
|
301
330
|
signal?: AbortSignal;
|
|
302
331
|
}): Promise<JobStatus>;
|
|
303
332
|
/**
|
|
304
|
-
* The finished result. Throws `InferenceFailed` when the request failed
|
|
305
|
-
* a `SegmindError` when it has not finished yet (use `wait()` for that).
|
|
333
|
+
* The finished result. Throws `InferenceFailed` when the request failed
|
|
334
|
+
* (`InsufficientCredits` when that was for lack of credits), and a `SegmindError` when it has not finished yet (use `wait()` for that).
|
|
306
335
|
*/
|
|
307
336
|
result(options?: {
|
|
308
337
|
signal?: AbortSignal;
|
|
@@ -317,7 +346,7 @@ declare class Job<T = RunResult> {
|
|
|
317
346
|
private read;
|
|
318
347
|
}
|
|
319
348
|
|
|
320
|
-
interface PixelflowSubmitOptions {
|
|
349
|
+
interface PixelflowSubmitOptions extends InitiatorOptions {
|
|
321
350
|
/**
|
|
322
351
|
* `v2` (default) runs on the current workflow engine, which also loads
|
|
323
352
|
* older graphs. `v1` is the legacy engine.
|
|
@@ -328,8 +357,13 @@ interface PixelflowSubmitOptions {
|
|
|
328
357
|
interface PixelflowWaitOptions {
|
|
329
358
|
/** Give up after this many milliseconds. Default 600 000. */
|
|
330
359
|
timeout?: number;
|
|
331
|
-
/**
|
|
332
|
-
|
|
360
|
+
/**
|
|
361
|
+
* Milliseconds between status checks, or a function of the milliseconds
|
|
362
|
+
* elapsed since `wait()` began, for a schedule. Default 2000.
|
|
363
|
+
*/
|
|
364
|
+
interval?: PollInterval;
|
|
365
|
+
/** Called with every status read, including the final one. */
|
|
366
|
+
onStatus?: (status: PixelflowStatus) => void;
|
|
333
367
|
signal?: AbortSignal;
|
|
334
368
|
}
|
|
335
369
|
interface PixelflowStatus {
|
|
@@ -369,7 +403,7 @@ declare class PixelflowJob {
|
|
|
369
403
|
}): Promise<PixelflowStatus>;
|
|
370
404
|
/**
|
|
371
405
|
* Polls until the run finishes. Throws `InferenceFailed` (its `detail` names
|
|
372
|
-
* the failing node) or `InferenceTimeout`; the run may still finish after a
|
|
406
|
+
* the failing node), `InsufficientCredits` or `InferenceTimeout`; the run may still finish after a
|
|
373
407
|
* timeout, so `wait()` can be called again.
|
|
374
408
|
*/
|
|
375
409
|
wait(options?: PixelflowWaitOptions): Promise<PixelflowStatus>;
|
|
@@ -433,11 +467,29 @@ declare const DEFAULT_BASE_URL = "https://api.segmind.com";
|
|
|
433
467
|
declare const DEFAULT_SPOT_URL = "https://api.spotprod.segmind.com";
|
|
434
468
|
declare const DEFAULT_CONSOLE_URL = "https://cloud.segmind.com/api";
|
|
435
469
|
interface ClientOptions {
|
|
436
|
-
/** Your Segmind API key. Defaults to `SEGMIND_API_KEY` from the environment. */
|
|
470
|
+
/** Your Segmind API key. Defaults to `SEGMIND_API_KEY` from the environment, unless `tokenProvider` is set. */
|
|
437
471
|
apiKey?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Authenticates as a signed-in Segmind user instead of with an API key, sending
|
|
474
|
+
* `Authorization: Bearer <token>`. Called before every request, so a rotated
|
|
475
|
+
* token is picked up mid-poll. Allowed in browsers, because the token is the
|
|
476
|
+
* user's own session. When it returns nothing, requests go out unauthenticated.
|
|
477
|
+
*/
|
|
478
|
+
tokenProvider?: TokenProvider;
|
|
479
|
+
/**
|
|
480
|
+
* Called when a request made with `tokenProvider` gets a 401: refresh the
|
|
481
|
+
* session here. If `tokenProvider` then returns a different token, the request
|
|
482
|
+
* is sent once more; otherwise the 401 is thrown. Requests failing at the same
|
|
483
|
+
* time share one call.
|
|
484
|
+
*/
|
|
485
|
+
onUnauthorized?: () => void | Promise<void>;
|
|
486
|
+
/** Recorded as the source of these requests in usage history. Default `SDK-JS`. */
|
|
487
|
+
initiator?: Initiator;
|
|
488
|
+
/** Recorded with `initiator`: what the requests belong to, such as a workflow id. */
|
|
489
|
+
initiatorId?: string;
|
|
438
490
|
/** The inference API root, without `/v1`. Defaults to `SEGMIND_BASE_URL` or https://api.segmind.com. */
|
|
439
491
|
baseURL?: string;
|
|
440
|
-
/** The
|
|
492
|
+
/** The history, webhook and upload API. Default https://api.spotprod.segmind.com. */
|
|
441
493
|
spotURL?: string;
|
|
442
494
|
/** The account API. Default https://cloud.segmind.com/api. */
|
|
443
495
|
consoleURL?: string;
|
|
@@ -501,6 +553,13 @@ declare class Segmind {
|
|
|
501
553
|
* the existing request rather than a second one.
|
|
502
554
|
*/
|
|
503
555
|
submit(slug: string, params?: Params, options?: SubmitOptions): Promise<Job>;
|
|
556
|
+
/**
|
|
557
|
+
* A job submitted earlier, from its id alone, for picking one up after a
|
|
558
|
+
* reload or in another process. Makes no request. The result is kept for about
|
|
559
|
+
* an hour, and only for the user who submitted it: anything else reads as a
|
|
560
|
+
* `SegmindError` with status 404.
|
|
561
|
+
*/
|
|
562
|
+
job(requestId: string): Job;
|
|
504
563
|
/** Chat with an LLM through the v2 queue. Returns a provider-neutral reply. */
|
|
505
564
|
chat(slug: string, params: ChatParams, options?: RunOptions): Promise<ChatResponse>;
|
|
506
565
|
/** Chat with one blocking `POST /v1/{slug}`. */
|
|
@@ -509,32 +568,96 @@ declare class Segmind {
|
|
|
509
568
|
submitChat(slug: string, params: ChatParams, options?: SubmitOptions): Promise<Job<ChatResponse>>;
|
|
510
569
|
private submitJob;
|
|
511
570
|
}
|
|
512
|
-
|
|
571
|
+
type ModelInput = 'text' | 'image' | 'video' | 'audio';
|
|
572
|
+
type ModelOutput = ModelInput | '3d' | 'embedding' | 'data';
|
|
573
|
+
type ModelSort = 'popular' | 'newest' | 'name' | 'cheapest' | 'fastest' | 'relevance';
|
|
574
|
+
/** One catalog entry, as `GET /models` returns it. */
|
|
513
575
|
interface ModelInfo {
|
|
514
576
|
slug: string;
|
|
515
|
-
|
|
516
|
-
type?: string;
|
|
577
|
+
name: string;
|
|
517
578
|
description?: string;
|
|
518
|
-
|
|
519
|
-
|
|
579
|
+
/** For example `textToImage` or `imageToVideo`. */
|
|
580
|
+
category?: string;
|
|
581
|
+
modality?: string;
|
|
582
|
+
input?: ModelInput;
|
|
583
|
+
output?: ModelOutput;
|
|
584
|
+
provider?: string;
|
|
585
|
+
thumbnail_url?: string;
|
|
520
586
|
is_new?: boolean;
|
|
521
587
|
coming_soon?: boolean;
|
|
522
|
-
|
|
588
|
+
/** 0–100, across the whole catalog. */
|
|
589
|
+
popularity_score?: number;
|
|
590
|
+
/** 0–100, within the model's category. */
|
|
591
|
+
category_percentile?: number;
|
|
592
|
+
/** Observed average spend per request in USD, not the list price. */
|
|
593
|
+
average_cost?: number | null;
|
|
594
|
+
latency_seconds?: number | null;
|
|
595
|
+
created_at?: string;
|
|
596
|
+
operations?: string[];
|
|
597
|
+
features?: string[];
|
|
523
598
|
[key: string]: unknown;
|
|
524
599
|
}
|
|
525
|
-
/**
|
|
526
|
-
interface
|
|
527
|
-
|
|
600
|
+
/** Filters and paging for `models.list()`. Every filter is optional. */
|
|
601
|
+
interface ModelListParams {
|
|
602
|
+
/** Free-text search; sorts by relevance unless `sort` is given. */
|
|
603
|
+
q?: string;
|
|
604
|
+
/** Default `popular`, or `relevance` when `q` is set. */
|
|
605
|
+
sort?: ModelSort;
|
|
606
|
+
category?: string;
|
|
607
|
+
modality?: string;
|
|
608
|
+
/** Models that take any of these inputs. */
|
|
609
|
+
input?: ModelInput | ModelInput[];
|
|
610
|
+
/** Models that produce any of these outputs. */
|
|
611
|
+
output?: ModelOutput | ModelOutput[];
|
|
612
|
+
provider?: string;
|
|
613
|
+
/** Look up these slugs, up to 100. Unlisted models resolve too. */
|
|
614
|
+
slugs?: string[];
|
|
615
|
+
operations?: string | string[];
|
|
616
|
+
features?: string | string[];
|
|
617
|
+
minPopularity?: number;
|
|
618
|
+
minCategoryPercentile?: number;
|
|
619
|
+
minCost?: number;
|
|
620
|
+
maxCost?: number;
|
|
621
|
+
maxLatency?: number;
|
|
622
|
+
isNew?: boolean;
|
|
623
|
+
/** `YYYY-MM-DD`. */
|
|
624
|
+
createdAfter?: string;
|
|
625
|
+
includeComingSoon?: boolean;
|
|
626
|
+
/** Also return filter counts under `facets`. */
|
|
627
|
+
facets?: boolean;
|
|
628
|
+
/** 1–100, default 50. */
|
|
629
|
+
limit?: number;
|
|
630
|
+
offset?: number;
|
|
631
|
+
}
|
|
632
|
+
/** One page of the catalog. */
|
|
633
|
+
interface ModelsPage {
|
|
634
|
+
models: ModelInfo[];
|
|
635
|
+
total: number;
|
|
636
|
+
limit: number;
|
|
637
|
+
offset: number;
|
|
638
|
+
has_more: boolean;
|
|
639
|
+
facets?: Record<string, unknown>;
|
|
528
640
|
[key: string]: unknown;
|
|
529
641
|
}
|
|
530
|
-
/** The model catalog
|
|
642
|
+
/** The model catalog, served by the gateway at `GET /models`. */
|
|
531
643
|
declare class Models {
|
|
532
644
|
private readonly client;
|
|
533
645
|
constructor(client: Segmind);
|
|
534
|
-
/**
|
|
535
|
-
list(options?: {
|
|
646
|
+
/** One page of the catalog. Pass `offset` from the previous page while `has_more` is true. */
|
|
647
|
+
list(params?: ModelListParams, options?: {
|
|
648
|
+
signal?: AbortSignal;
|
|
649
|
+
}): Promise<ModelsPage>;
|
|
650
|
+
/** Every model matching `params`, reading page after page. */
|
|
651
|
+
listAll(params?: Omit<ModelListParams, 'limit' | 'offset' | 'facets'>, options?: {
|
|
536
652
|
signal?: AbortSignal;
|
|
537
|
-
}): Promise<
|
|
653
|
+
}): Promise<ModelInfo[]>;
|
|
654
|
+
}
|
|
655
|
+
/** The balance of the account or team making the request. */
|
|
656
|
+
interface AccountCredits {
|
|
657
|
+
/** The stored balance. Credits held by requests still running are not taken off. */
|
|
658
|
+
credits: number;
|
|
659
|
+
freeCredits: number;
|
|
660
|
+
[key: string]: unknown;
|
|
538
661
|
}
|
|
539
662
|
/** The account the API key belongs to. */
|
|
540
663
|
declare class Accounts {
|
|
@@ -544,6 +667,10 @@ declare class Accounts {
|
|
|
544
667
|
current(options?: {
|
|
545
668
|
signal?: AbortSignal;
|
|
546
669
|
}): Promise<Record<string, unknown>>;
|
|
670
|
+
/** The current credit balance. */
|
|
671
|
+
credits(options?: {
|
|
672
|
+
signal?: AbortSignal;
|
|
673
|
+
}): Promise<AccountCredits>;
|
|
547
674
|
}
|
|
548
675
|
|
|
549
676
|
/** An OpenAI-style image part, for the `content` list of a chat message. */
|
|
@@ -592,6 +719,24 @@ declare class SegmindError extends Error {
|
|
|
592
719
|
/** The request never got a response: DNS, TLS, connection reset, or the client's timeout. */
|
|
593
720
|
declare class APIConnectionError extends SegmindError {
|
|
594
721
|
}
|
|
722
|
+
/**
|
|
723
|
+
* The account cannot pay for the request. The gateway reports this at submit, or
|
|
724
|
+
* as a failed job when the balance is positive but below the model's cost, so
|
|
725
|
+
* this one class covers both. `detail` holds the server's message.
|
|
726
|
+
*/
|
|
727
|
+
declare class InsufficientCredits extends SegmindError {
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Too many requests, after the SDK's own retries for calls that are safe to
|
|
731
|
+
* repeat. `retryAfterMs` is set when the server sent `Retry-After` and the
|
|
732
|
+
* runtime could read it: a browser only sees the header if the server exposes it.
|
|
733
|
+
*/
|
|
734
|
+
declare class RateLimited extends SegmindError {
|
|
735
|
+
readonly retryAfterMs: number | undefined;
|
|
736
|
+
constructor(message: string, options?: SegmindErrorOptions & {
|
|
737
|
+
retryAfterMs?: number;
|
|
738
|
+
});
|
|
739
|
+
}
|
|
595
740
|
/** A v2 request reached `FAILED`. The server's error text is in `detail`. */
|
|
596
741
|
declare class InferenceFailed extends SegmindError {
|
|
597
742
|
/** The status body that reported the failure. */
|
|
@@ -607,7 +752,7 @@ declare class InferenceTimeout extends SegmindError {
|
|
|
607
752
|
constructor(requestId: string, elapsedMs: number);
|
|
608
753
|
}
|
|
609
754
|
|
|
610
|
-
declare const VERSION = "0.
|
|
755
|
+
declare const VERSION = "0.3.0";
|
|
611
756
|
|
|
612
757
|
/** `new Segmind().run(...)` with the key from `SEGMIND_API_KEY`. */
|
|
613
758
|
declare const run: (slug: string, params?: Params, options?: RunOptions) => Promise<RunResult>;
|
|
@@ -615,6 +760,8 @@ declare const run: (slug: string, params?: Params, options?: RunOptions) => Prom
|
|
|
615
760
|
declare const runSync: (slug: string, params?: Params, options?: CallOptions) => Promise<Response>;
|
|
616
761
|
/** `new Segmind().submit(...)` with the key from `SEGMIND_API_KEY`. */
|
|
617
762
|
declare const submit: (slug: string, params?: Params, options?: SubmitOptions) => Promise<Job>;
|
|
763
|
+
/** `new Segmind().job(...)` with the key from `SEGMIND_API_KEY`. */
|
|
764
|
+
declare const job: (requestId: string) => Job;
|
|
618
765
|
/** `new Segmind().chat(...)` with the key from `SEGMIND_API_KEY`. */
|
|
619
766
|
declare const chat: (slug: string, params: ChatParams, options?: RunOptions) => Promise<ChatResponse>;
|
|
620
767
|
/** `new Segmind().chatSync(...)` with the key from `SEGMIND_API_KEY`. */
|
|
@@ -622,16 +769,15 @@ declare const chatSync: (slug: string, params: ChatParams, options?: CallOptions
|
|
|
622
769
|
/** `new Segmind().submitChat(...)` with the key from `SEGMIND_API_KEY`. */
|
|
623
770
|
declare const submitChat: (slug: string, params: ChatParams, options?: SubmitOptions) => Promise<Job<ChatResponse>>;
|
|
624
771
|
/** `new Segmind().models` with the key from `SEGMIND_API_KEY`. */
|
|
625
|
-
declare const models:
|
|
626
|
-
list: (options?: {
|
|
627
|
-
signal?: AbortSignal;
|
|
628
|
-
}) => Promise<ModelsListResponse>;
|
|
629
|
-
};
|
|
772
|
+
declare const models: Pick<Models, 'list' | 'listAll'>;
|
|
630
773
|
/** `new Segmind().accounts` with the key from `SEGMIND_API_KEY`. */
|
|
631
774
|
declare const accounts: {
|
|
632
775
|
current: (options?: {
|
|
633
776
|
signal?: AbortSignal;
|
|
634
777
|
}) => Promise<Record<string, unknown>>;
|
|
778
|
+
credits: (options?: {
|
|
779
|
+
signal?: AbortSignal;
|
|
780
|
+
}) => Promise<AccountCredits>;
|
|
635
781
|
};
|
|
636
782
|
/** `new Segmind().files` with the key from `SEGMIND_API_KEY`. */
|
|
637
783
|
declare const files: Pick<Files, 'upload'>;
|
|
@@ -642,5 +788,5 @@ declare const webhooks: Pick<Webhooks, 'get' | 'add' | 'update' | 'delete' | 'lo
|
|
|
642
788
|
/** `new Segmind().pixelflows` with the key from `SEGMIND_API_KEY`. */
|
|
643
789
|
declare const pixelflows: Pick<PixelFlows, 'run' | 'submit' | 'getStatus' | 'poll'>;
|
|
644
790
|
|
|
645
|
-
export { APIConnectionError, Accounts, ChatResponse, DEFAULT_BASE_URL, DEFAULT_CONSOLE_URL, DEFAULT_SPOT_URL, DEFAULT_WAIT_INTERVAL_MS, DEFAULT_WAIT_TIMEOUT_MS, Files, Generations, InferenceFailed, InferenceTimeout, Job, Models, PixelFlows, PixelflowJob, Segmind, SegmindError, VERSION, Webhooks, accounts, chat, chatSync, files, generations, imageUrl, models, pixelflows, run, runSync, submit, submitChat, webhooks };
|
|
646
|
-
export type { CallOptions, ChatMessage, ChatParams, ClientOptions, FileInput, Generation, GenerationsListOptions, HistoryOptions, ImageInput, ImageUrlPart, JobState, JobStatus, ModelInfo,
|
|
791
|
+
export { APIConnectionError, Accounts, ChatResponse, DEFAULT_BASE_URL, DEFAULT_CONSOLE_URL, DEFAULT_SPOT_URL, DEFAULT_WAIT_INTERVAL_MS, DEFAULT_WAIT_TIMEOUT_MS, Files, Generations, InferenceFailed, InferenceTimeout, InsufficientCredits, Job, Models, PixelFlows, PixelflowJob, RateLimited, Segmind, SegmindError, VERSION, Webhooks, accounts, chat, chatSync, files, generations, imageUrl, job, models, pixelflows, run, runSync, submit, submitChat, webhooks };
|
|
792
|
+
export type { AccountCredits, CallOptions, ChatMessage, ChatParams, ClientOptions, FileInput, Generation, GenerationsListOptions, HistoryOptions, ImageInput, ImageUrlPart, Initiator, InitiatorOptions, JobState, JobStatus, ModelInfo, ModelInput, ModelListParams, ModelOutput, ModelSort, ModelsPage, Page, Params, PixelflowStatus, PixelflowSubmitOptions, PixelflowWaitOptions, PollInterval, RequestRecord, RunOptions, RunResult, SubmitOptions, SubmitResponse, TokenProvider, UploadOptions, UploadedFile, WaitOptions, Webhook, WebhookEventType };
|