@superlinked/sie-sdk 0.6.20 → 0.6.21

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/index.d.cts CHANGED
@@ -256,6 +256,15 @@ interface DocumentInput {
256
256
  /** Document format hint: "pdf", "docx", "html", etc. */
257
257
  format?: string;
258
258
  }
259
+ /** Encoded audio bytes and optional decoder metadata. */
260
+ interface AudioInput {
261
+ /** Encoded audio bytes (WAV, MP3, FLAC, etc.) */
262
+ data: Uint8Array;
263
+ /** Audio container/codec format hint */
264
+ format?: string;
265
+ /** Source sample rate in Hz, when known */
266
+ sampleRate?: number;
267
+ }
259
268
  /**
260
269
  * A single item to encode, score, or extract from.
261
270
  *
@@ -291,6 +300,11 @@ interface Item {
291
300
  /** Arbitrary metadata (passed through to results) */
292
301
  metadata?: Record<string, unknown>;
293
302
  }
303
+ /** An item accepted by extract(), including optional encoded audio. */
304
+ interface ExtractItem extends Item {
305
+ /** Encoded audio for speech extraction, optionally with decoder metadata. */
306
+ audio?: AudioInput | Uint8Array;
307
+ }
294
308
  /**
295
309
  * Sparse vector result with non-zero indices and values.
296
310
  * Used by SPLADE-type models.
@@ -310,6 +324,23 @@ interface TimingInfo {
310
324
  tokenizationMs?: number;
311
325
  inferenceMs?: number;
312
326
  }
327
+ /** Authoritative units settled for one completed HTTP request. */
328
+ interface RequestUsage {
329
+ inputTokens?: number;
330
+ pairs?: number;
331
+ images?: number;
332
+ pages?: number;
333
+ outputTokens?: number;
334
+ audioMs?: number;
335
+ }
336
+ /** Optional gateway metadata from the successful terminal response. */
337
+ interface RequestMetadata {
338
+ id?: string;
339
+ /** Worker-origin immutable release/runtime identity digest. */
340
+ executionIdentitySha256?: string;
341
+ usage?: RequestUsage;
342
+ creditsDebited?: number;
343
+ }
313
344
  /**
314
345
  * Result of encoding a single item.
315
346
  *
@@ -327,6 +358,8 @@ interface EncodeResult {
327
358
  multivector?: Float32Array[];
328
359
  /** Server-side timing breakdown */
329
360
  timing?: TimingInfo;
361
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
362
+ request?: RequestMetadata;
330
363
  }
331
364
  /**
332
365
  * Model dimension information.
@@ -397,6 +430,12 @@ interface ScoreEntry {
397
430
  /** Position in sorted order (0 = most relevant) */
398
431
  rank: number;
399
432
  }
433
+ interface ScoreUsage {
434
+ /** Post-truncation input tokens processed */
435
+ inputTokens: number;
436
+ /** Images processed across query-document pairs */
437
+ images?: number;
438
+ }
400
439
  /**
401
440
  * Result of scoring items against a query.
402
441
  */
@@ -407,6 +446,10 @@ interface ScoreResult {
407
446
  queryId?: string;
408
447
  /** Score entries, sorted by relevance (descending) */
409
448
  scores: ScoreEntry[];
449
+ /** Authoritative usage when emitted by the score adapter */
450
+ usage?: ScoreUsage;
451
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
452
+ request?: RequestMetadata;
410
453
  }
411
454
  /**
412
455
  * A single extracted entity (NER span).
@@ -458,6 +501,13 @@ interface DetectedObject {
458
501
  /** Bounding box [x, y, width, height] */
459
502
  bbox: number[];
460
503
  }
504
+ /** Stable per-item extraction failure. */
505
+ interface ExtractItemError {
506
+ /** Stable extraction error code */
507
+ code: string;
508
+ /** Sanitized extraction error message */
509
+ message: string;
510
+ }
461
511
  /**
462
512
  * Result of extraction for a single item.
463
513
  */
@@ -472,6 +522,12 @@ interface ExtractResult {
472
522
  classifications: Classification[];
473
523
  /** List of detected objects */
474
524
  objects: DetectedObject[];
525
+ /** Additional structured extraction data */
526
+ data?: Record<string, unknown>;
527
+ /** Stable per-item failure when extraction did not complete */
528
+ error?: ExtractItemError;
529
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
530
+ request?: RequestMetadata;
475
531
  }
476
532
  /**
477
533
  * Information about a worker in the cluster.
@@ -524,8 +580,9 @@ interface CreatePoolOptions {
524
580
  /** Optional bundle filter. When set, only workers running this bundle will be assigned to the pool. */
525
581
  bundle?: string;
526
582
  /**
527
- * Per-pool warm floor (minimum machines kept warm). The gateway publishes
528
- * it as `sie_gateway_pool_warm_floor` for KEDA. Defaults to 0 (scale to zero).
583
+ * Per-pool warm floor (minimum machines kept warm). The gateway emits
584
+ * canonical `sie.gateway.pool.warm_floor` telemetry; the collector exposes
585
+ * `sie_gateway_pool_warm_floor` to KEDA. Defaults to 0 (scale to zero).
529
586
  */
530
587
  minimumWorkerCount?: number;
531
588
  /**
@@ -650,6 +707,10 @@ interface ModelStatus {
650
707
  queue_depth: number;
651
708
  queue_pending_items: number;
652
709
  }
710
+ /**
711
+ * Worker status snapshot. Request-rate and latency telemetry is exported
712
+ * through the configured OTel destination instead of this message.
713
+ */
653
714
  interface WorkerStatusMessage {
654
715
  timestamp: number;
655
716
  name: string;
@@ -661,8 +722,6 @@ interface WorkerStatusMessage {
661
722
  server: ServerInfo;
662
723
  gpus: GPUMetrics[];
663
724
  models: ModelStatus[];
664
- counters: Record<string, Record<string, number>>;
665
- histograms: Record<string, Record<string, Record<string, unknown>>>;
666
725
  }
667
726
  interface ClusterStatusMessage {
668
727
  timestamp: number;
@@ -830,11 +889,45 @@ interface GenerateOptions {
830
889
  topP?: number;
831
890
  /** Optional list of stop strings. */
832
891
  stop?: string[];
892
+ /** OpenAI-compatible frequency penalty in [-2, 2]. */
893
+ frequencyPenalty?: number;
894
+ /** OpenAI-compatible presence penalty in [-2, 2]. */
895
+ presencePenalty?: number;
896
+ /** Native structured-output grammar. */
897
+ grammar?: Record<string, unknown>;
898
+ /**
899
+ * Optional per-request sampling seed. Must be a JavaScript safe integer
900
+ * (-(2^53 - 1) through 2^53 - 1) so JSON serialization preserves it exactly.
901
+ * Reproducibility depends on the active backend and deployment configuration.
902
+ */
903
+ seed?: number;
904
+ /** Token-id-to-bias map. */
905
+ logitBias?: Record<string, number>;
906
+ /** Stable request routing key. */
907
+ routingKey?: string;
908
+ /** Prompt cache affinity key. */
909
+ promptCacheKey?: string;
910
+ /** Opaque privacy-preserving safety identifier. */
911
+ safetyIdentifier?: string;
912
+ /** Served LoRA adapter name. */
913
+ loraAdapter?: string;
914
+ /**
915
+ * Governed generation runtime options forwarded as `options`. Typed native
916
+ * fields still win when both surfaces provide the same sampler control.
917
+ */
918
+ adapterOptions?: Record<string, unknown>;
833
919
  /** GPU type / pool spec, e.g. ``"l4"`` or ``"eval-bench/l4"``. */
834
920
  gpu?: string;
835
921
  /** Auto-retry under provisioning. */
836
922
  waitForCapacity?: boolean;
837
923
  }
924
+ /** Options for streaming native generation. */
925
+ interface StreamGenerateOptions extends GenerateOptions {
926
+ /** Include per-token log probabilities in streamed chunks. */
927
+ logprobs?: boolean;
928
+ /** Number of alternate token log probabilities to return, in [0, 20]. */
929
+ topLogprobs?: number;
930
+ }
838
931
  /** Aggregated generation result. */
839
932
  interface GenerateResult {
840
933
  /** Model id the gateway dispatched to. */
@@ -851,6 +944,8 @@ interface GenerateResult {
851
944
  ttftMs?: number;
852
945
  /** Average time per output token in milliseconds. */
853
946
  tpotMs?: number;
947
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
948
+ request?: RequestMetadata;
854
949
  }
855
950
  /**
856
951
  * A single message in a chat completion request.
@@ -1009,6 +1104,12 @@ interface ChatCompletionRequest {
1009
1104
  * `[-100, 100]` and caps map size.
1010
1105
  */
1011
1106
  logit_bias?: Record<string, number>;
1107
+ /**
1108
+ * Optional per-request sampling seed. Must be a JavaScript safe integer
1109
+ * (`-(2^53 - 1)` through `2^53 - 1`) so the caller's integer is represented
1110
+ * exactly. The SDK throws `RangeError` before network I/O for invalid values.
1111
+ * Reproducibility depends on the active backend and deployment configuration.
1112
+ */
1012
1113
  seed?: number;
1013
1114
  /**
1014
1115
  * OpenAI's free-text end-user identifier. Accepted and logged at debug
@@ -1053,6 +1154,8 @@ interface ChatCompletion {
1053
1154
  system_fingerprint: string | null;
1054
1155
  choices: ChatChoice[];
1055
1156
  usage: ChatUsage;
1157
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
1158
+ request?: RequestMetadata;
1056
1159
  }
1057
1160
  /** Incremental delta emitted on each streaming chunk. */
1058
1161
  interface ChatDelta {
@@ -1131,6 +1234,8 @@ interface GenerateChunk {
1131
1234
  request_id: string;
1132
1235
  seq: number;
1133
1236
  text_delta: string;
1237
+ /** Per-token log probabilities aligned with `text_delta`. */
1238
+ logprobs?: Array<Record<string, unknown>>;
1134
1239
  done: boolean;
1135
1240
  finish_reason?: "stop" | "length" | "cancelled" | "error";
1136
1241
  usage?: ChatUsage;
@@ -1527,10 +1632,10 @@ declare class SIEClient {
1527
1632
  * chunk shape documented in
1528
1633
  * `packages/sie_gateway/src/handlers/sse.rs::build_generate_chunk_event`.
1529
1634
  *
1530
- * The first delta carries `seq: 0` and `text_delta` populated; the
1531
- * terminal chunk has `done: true`, `finish_reason`, and (typically)
1532
- * `usage` + `ttft_ms`. The generator completes on the `data: [DONE]`
1533
- * sentinel.
1635
+ * Delta chunks may carry text, log probabilities, or both; callers must not
1636
+ * assume every non-terminal event has a non-empty `text_delta`. The terminal
1637
+ * chunk has `done: true`, `finish_reason`, and (typically) `usage` +
1638
+ * `ttft_ms`. The generator completes on the `data: [DONE]` sentinel.
1534
1639
  *
1535
1640
  * Error semantics match {@link streamChatCompletions}: pre-stream HTTP
1536
1641
  * errors throw normally, mid-stream `error` chunks throw
@@ -1548,7 +1653,7 @@ declare class SIEClient {
1548
1653
  * }
1549
1654
  * ```
1550
1655
  */
1551
- streamGenerate(model: string, prompt: string, options: GenerateOptions, signal?: AbortSignal): AsyncGenerator<GenerateChunk, void, undefined>;
1656
+ streamGenerate(model: string, prompt: string, options: StreamGenerateOptions, signal?: AbortSignal): AsyncGenerator<GenerateChunk, void, undefined>;
1552
1657
  /**
1553
1658
  * Shared SSE consumption helper for the streaming methods.
1554
1659
  *
@@ -1586,7 +1691,7 @@ declare class SIEClient {
1586
1691
  * @param options - Extract options with labels
1587
1692
  * @returns Extract result with entities
1588
1693
  */
1589
- extract(model: string, item: Item, options: ExtractOptions): Promise<ExtractResult>;
1694
+ extract(model: string, item: ExtractItem, options: ExtractOptions): Promise<ExtractResult>;
1590
1695
  /**
1591
1696
  * Extract entities from multiple items.
1592
1697
  *
@@ -1595,7 +1700,7 @@ declare class SIEClient {
1595
1700
  * @param options - Extract options with labels
1596
1701
  * @returns Array of extract results in same order as input
1597
1702
  */
1598
- extract(model: string, items: Item[], options: ExtractOptions): Promise<ExtractResult[]>;
1703
+ extract(model: string, items: ExtractItem[], options: ExtractOptions): Promise<ExtractResult[]>;
1599
1704
  /**
1600
1705
  * Close the client and cleanup resources.
1601
1706
  *
@@ -1782,7 +1887,7 @@ declare class SIEClient {
1782
1887
  private detectEndpointType;
1783
1888
  }
1784
1889
 
1785
- declare const SDK_VERSION = "0.6.20";
1890
+ declare const SDK_VERSION = "0.6.21";
1786
1891
 
1787
1892
  /**
1788
1893
  * Helpers for converting SIE encode results to plain JavaScript types.
@@ -2127,4 +2232,4 @@ declare function packMessage(data: unknown): Uint8Array;
2127
2232
  */
2128
2233
  declare function unpackMessage<T = unknown>(data: Uint8Array): T;
2129
2234
 
2130
- export { type Batch, type BatchList, type BatchRequestCounts, type BatchesNamespace, type CapacityInfo, type ChatChoice, type ChatChunkChoice, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionRequest, type ChatDelta, type ChatFinishReason, type ChatMessage, type ChatUsage, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type Connection, type ConnectionCreated, type ConnectionRevoked, type ConnectionsNamespace, type CreatePoolOptions, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type FileDeleted, type FileUploadInput, type FilesNamespace, type FinishReason, type GPUMetrics, type GenerateChunk, type GenerateOptions, type GenerateResult, type GenerationUsage, type ImageInput, type ImageWireFormat, InputTooLongError, type Item, type JobChunk, type JobFieldMap, type JobItem, type JobPreflight, type JobResultItem, type JobResults, type JobSource, type JobState, type JobStatus, type JobSubmitResult, type JobsNamespace, LoraLoadingError, type ModelCapabilities, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, ResourceExhaustedError, type ResponseFormat, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type File as SIEFile, SIEStreamError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type SubmitJobOptions, TERMINAL_JOB_STATES, type TimingInfo, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolSpec, type WorkerInfo, type WorkerStatusMessage, buildJobBody, connectionName, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
2235
+ export { type AudioInput, type Batch, type BatchList, type BatchRequestCounts, type BatchesNamespace, type CapacityInfo, type ChatChoice, type ChatChunkChoice, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionRequest, type ChatDelta, type ChatFinishReason, type ChatMessage, type ChatUsage, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type Connection, type ConnectionCreated, type ConnectionRevoked, type ConnectionsNamespace, type CreatePoolOptions, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractItem, type ExtractItemError, type ExtractOptions, type ExtractResult, type FileDeleted, type FileUploadInput, type FilesNamespace, type FinishReason, type GPUMetrics, type GenerateChunk, type GenerateOptions, type GenerateResult, type GenerationUsage, type ImageInput, type ImageWireFormat, InputTooLongError, type Item, type JobChunk, type JobFieldMap, type JobItem, type JobPreflight, type JobResultItem, type JobResults, type JobSource, type JobState, type JobStatus, type JobSubmitResult, type JobsNamespace, LoraLoadingError, type ModelCapabilities, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, ResourceExhaustedError, type ResponseFormat, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type File as SIEFile, SIEStreamError, type ScoreEntry, type ScoreOptions, type ScoreResult, type ScoreUsage, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type StreamGenerateOptions, type SubmitJobOptions, TERMINAL_JOB_STATES, type TimingInfo, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolSpec, type WorkerInfo, type WorkerStatusMessage, buildJobBody, connectionName, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
package/dist/index.d.ts CHANGED
@@ -256,6 +256,15 @@ interface DocumentInput {
256
256
  /** Document format hint: "pdf", "docx", "html", etc. */
257
257
  format?: string;
258
258
  }
259
+ /** Encoded audio bytes and optional decoder metadata. */
260
+ interface AudioInput {
261
+ /** Encoded audio bytes (WAV, MP3, FLAC, etc.) */
262
+ data: Uint8Array;
263
+ /** Audio container/codec format hint */
264
+ format?: string;
265
+ /** Source sample rate in Hz, when known */
266
+ sampleRate?: number;
267
+ }
259
268
  /**
260
269
  * A single item to encode, score, or extract from.
261
270
  *
@@ -291,6 +300,11 @@ interface Item {
291
300
  /** Arbitrary metadata (passed through to results) */
292
301
  metadata?: Record<string, unknown>;
293
302
  }
303
+ /** An item accepted by extract(), including optional encoded audio. */
304
+ interface ExtractItem extends Item {
305
+ /** Encoded audio for speech extraction, optionally with decoder metadata. */
306
+ audio?: AudioInput | Uint8Array;
307
+ }
294
308
  /**
295
309
  * Sparse vector result with non-zero indices and values.
296
310
  * Used by SPLADE-type models.
@@ -310,6 +324,23 @@ interface TimingInfo {
310
324
  tokenizationMs?: number;
311
325
  inferenceMs?: number;
312
326
  }
327
+ /** Authoritative units settled for one completed HTTP request. */
328
+ interface RequestUsage {
329
+ inputTokens?: number;
330
+ pairs?: number;
331
+ images?: number;
332
+ pages?: number;
333
+ outputTokens?: number;
334
+ audioMs?: number;
335
+ }
336
+ /** Optional gateway metadata from the successful terminal response. */
337
+ interface RequestMetadata {
338
+ id?: string;
339
+ /** Worker-origin immutable release/runtime identity digest. */
340
+ executionIdentitySha256?: string;
341
+ usage?: RequestUsage;
342
+ creditsDebited?: number;
343
+ }
313
344
  /**
314
345
  * Result of encoding a single item.
315
346
  *
@@ -327,6 +358,8 @@ interface EncodeResult {
327
358
  multivector?: Float32Array[];
328
359
  /** Server-side timing breakdown */
329
360
  timing?: TimingInfo;
361
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
362
+ request?: RequestMetadata;
330
363
  }
331
364
  /**
332
365
  * Model dimension information.
@@ -397,6 +430,12 @@ interface ScoreEntry {
397
430
  /** Position in sorted order (0 = most relevant) */
398
431
  rank: number;
399
432
  }
433
+ interface ScoreUsage {
434
+ /** Post-truncation input tokens processed */
435
+ inputTokens: number;
436
+ /** Images processed across query-document pairs */
437
+ images?: number;
438
+ }
400
439
  /**
401
440
  * Result of scoring items against a query.
402
441
  */
@@ -407,6 +446,10 @@ interface ScoreResult {
407
446
  queryId?: string;
408
447
  /** Score entries, sorted by relevance (descending) */
409
448
  scores: ScoreEntry[];
449
+ /** Authoritative usage when emitted by the score adapter */
450
+ usage?: ScoreUsage;
451
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
452
+ request?: RequestMetadata;
410
453
  }
411
454
  /**
412
455
  * A single extracted entity (NER span).
@@ -458,6 +501,13 @@ interface DetectedObject {
458
501
  /** Bounding box [x, y, width, height] */
459
502
  bbox: number[];
460
503
  }
504
+ /** Stable per-item extraction failure. */
505
+ interface ExtractItemError {
506
+ /** Stable extraction error code */
507
+ code: string;
508
+ /** Sanitized extraction error message */
509
+ message: string;
510
+ }
461
511
  /**
462
512
  * Result of extraction for a single item.
463
513
  */
@@ -472,6 +522,12 @@ interface ExtractResult {
472
522
  classifications: Classification[];
473
523
  /** List of detected objects */
474
524
  objects: DetectedObject[];
525
+ /** Additional structured extraction data */
526
+ data?: Record<string, unknown>;
527
+ /** Stable per-item failure when extraction did not complete */
528
+ error?: ExtractItemError;
529
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
530
+ request?: RequestMetadata;
475
531
  }
476
532
  /**
477
533
  * Information about a worker in the cluster.
@@ -524,8 +580,9 @@ interface CreatePoolOptions {
524
580
  /** Optional bundle filter. When set, only workers running this bundle will be assigned to the pool. */
525
581
  bundle?: string;
526
582
  /**
527
- * Per-pool warm floor (minimum machines kept warm). The gateway publishes
528
- * it as `sie_gateway_pool_warm_floor` for KEDA. Defaults to 0 (scale to zero).
583
+ * Per-pool warm floor (minimum machines kept warm). The gateway emits
584
+ * canonical `sie.gateway.pool.warm_floor` telemetry; the collector exposes
585
+ * `sie_gateway_pool_warm_floor` to KEDA. Defaults to 0 (scale to zero).
529
586
  */
530
587
  minimumWorkerCount?: number;
531
588
  /**
@@ -650,6 +707,10 @@ interface ModelStatus {
650
707
  queue_depth: number;
651
708
  queue_pending_items: number;
652
709
  }
710
+ /**
711
+ * Worker status snapshot. Request-rate and latency telemetry is exported
712
+ * through the configured OTel destination instead of this message.
713
+ */
653
714
  interface WorkerStatusMessage {
654
715
  timestamp: number;
655
716
  name: string;
@@ -661,8 +722,6 @@ interface WorkerStatusMessage {
661
722
  server: ServerInfo;
662
723
  gpus: GPUMetrics[];
663
724
  models: ModelStatus[];
664
- counters: Record<string, Record<string, number>>;
665
- histograms: Record<string, Record<string, Record<string, unknown>>>;
666
725
  }
667
726
  interface ClusterStatusMessage {
668
727
  timestamp: number;
@@ -830,11 +889,45 @@ interface GenerateOptions {
830
889
  topP?: number;
831
890
  /** Optional list of stop strings. */
832
891
  stop?: string[];
892
+ /** OpenAI-compatible frequency penalty in [-2, 2]. */
893
+ frequencyPenalty?: number;
894
+ /** OpenAI-compatible presence penalty in [-2, 2]. */
895
+ presencePenalty?: number;
896
+ /** Native structured-output grammar. */
897
+ grammar?: Record<string, unknown>;
898
+ /**
899
+ * Optional per-request sampling seed. Must be a JavaScript safe integer
900
+ * (-(2^53 - 1) through 2^53 - 1) so JSON serialization preserves it exactly.
901
+ * Reproducibility depends on the active backend and deployment configuration.
902
+ */
903
+ seed?: number;
904
+ /** Token-id-to-bias map. */
905
+ logitBias?: Record<string, number>;
906
+ /** Stable request routing key. */
907
+ routingKey?: string;
908
+ /** Prompt cache affinity key. */
909
+ promptCacheKey?: string;
910
+ /** Opaque privacy-preserving safety identifier. */
911
+ safetyIdentifier?: string;
912
+ /** Served LoRA adapter name. */
913
+ loraAdapter?: string;
914
+ /**
915
+ * Governed generation runtime options forwarded as `options`. Typed native
916
+ * fields still win when both surfaces provide the same sampler control.
917
+ */
918
+ adapterOptions?: Record<string, unknown>;
833
919
  /** GPU type / pool spec, e.g. ``"l4"`` or ``"eval-bench/l4"``. */
834
920
  gpu?: string;
835
921
  /** Auto-retry under provisioning. */
836
922
  waitForCapacity?: boolean;
837
923
  }
924
+ /** Options for streaming native generation. */
925
+ interface StreamGenerateOptions extends GenerateOptions {
926
+ /** Include per-token log probabilities in streamed chunks. */
927
+ logprobs?: boolean;
928
+ /** Number of alternate token log probabilities to return, in [0, 20]. */
929
+ topLogprobs?: number;
930
+ }
838
931
  /** Aggregated generation result. */
839
932
  interface GenerateResult {
840
933
  /** Model id the gateway dispatched to. */
@@ -851,6 +944,8 @@ interface GenerateResult {
851
944
  ttftMs?: number;
852
945
  /** Average time per output token in milliseconds. */
853
946
  tpotMs?: number;
947
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
948
+ request?: RequestMetadata;
854
949
  }
855
950
  /**
856
951
  * A single message in a chat completion request.
@@ -1009,6 +1104,12 @@ interface ChatCompletionRequest {
1009
1104
  * `[-100, 100]` and caps map size.
1010
1105
  */
1011
1106
  logit_bias?: Record<string, number>;
1107
+ /**
1108
+ * Optional per-request sampling seed. Must be a JavaScript safe integer
1109
+ * (`-(2^53 - 1)` through `2^53 - 1`) so the caller's integer is represented
1110
+ * exactly. The SDK throws `RangeError` before network I/O for invalid values.
1111
+ * Reproducibility depends on the active backend and deployment configuration.
1112
+ */
1012
1113
  seed?: number;
1013
1114
  /**
1014
1115
  * OpenAI's free-text end-user identifier. Accepted and logged at debug
@@ -1053,6 +1154,8 @@ interface ChatCompletion {
1053
1154
  system_fingerprint: string | null;
1054
1155
  choices: ChatChoice[];
1055
1156
  usage: ChatUsage;
1157
+ /** Request-scoped usage and settled debit, when supplied by the gateway. */
1158
+ request?: RequestMetadata;
1056
1159
  }
1057
1160
  /** Incremental delta emitted on each streaming chunk. */
1058
1161
  interface ChatDelta {
@@ -1131,6 +1234,8 @@ interface GenerateChunk {
1131
1234
  request_id: string;
1132
1235
  seq: number;
1133
1236
  text_delta: string;
1237
+ /** Per-token log probabilities aligned with `text_delta`. */
1238
+ logprobs?: Array<Record<string, unknown>>;
1134
1239
  done: boolean;
1135
1240
  finish_reason?: "stop" | "length" | "cancelled" | "error";
1136
1241
  usage?: ChatUsage;
@@ -1527,10 +1632,10 @@ declare class SIEClient {
1527
1632
  * chunk shape documented in
1528
1633
  * `packages/sie_gateway/src/handlers/sse.rs::build_generate_chunk_event`.
1529
1634
  *
1530
- * The first delta carries `seq: 0` and `text_delta` populated; the
1531
- * terminal chunk has `done: true`, `finish_reason`, and (typically)
1532
- * `usage` + `ttft_ms`. The generator completes on the `data: [DONE]`
1533
- * sentinel.
1635
+ * Delta chunks may carry text, log probabilities, or both; callers must not
1636
+ * assume every non-terminal event has a non-empty `text_delta`. The terminal
1637
+ * chunk has `done: true`, `finish_reason`, and (typically) `usage` +
1638
+ * `ttft_ms`. The generator completes on the `data: [DONE]` sentinel.
1534
1639
  *
1535
1640
  * Error semantics match {@link streamChatCompletions}: pre-stream HTTP
1536
1641
  * errors throw normally, mid-stream `error` chunks throw
@@ -1548,7 +1653,7 @@ declare class SIEClient {
1548
1653
  * }
1549
1654
  * ```
1550
1655
  */
1551
- streamGenerate(model: string, prompt: string, options: GenerateOptions, signal?: AbortSignal): AsyncGenerator<GenerateChunk, void, undefined>;
1656
+ streamGenerate(model: string, prompt: string, options: StreamGenerateOptions, signal?: AbortSignal): AsyncGenerator<GenerateChunk, void, undefined>;
1552
1657
  /**
1553
1658
  * Shared SSE consumption helper for the streaming methods.
1554
1659
  *
@@ -1586,7 +1691,7 @@ declare class SIEClient {
1586
1691
  * @param options - Extract options with labels
1587
1692
  * @returns Extract result with entities
1588
1693
  */
1589
- extract(model: string, item: Item, options: ExtractOptions): Promise<ExtractResult>;
1694
+ extract(model: string, item: ExtractItem, options: ExtractOptions): Promise<ExtractResult>;
1590
1695
  /**
1591
1696
  * Extract entities from multiple items.
1592
1697
  *
@@ -1595,7 +1700,7 @@ declare class SIEClient {
1595
1700
  * @param options - Extract options with labels
1596
1701
  * @returns Array of extract results in same order as input
1597
1702
  */
1598
- extract(model: string, items: Item[], options: ExtractOptions): Promise<ExtractResult[]>;
1703
+ extract(model: string, items: ExtractItem[], options: ExtractOptions): Promise<ExtractResult[]>;
1599
1704
  /**
1600
1705
  * Close the client and cleanup resources.
1601
1706
  *
@@ -1782,7 +1887,7 @@ declare class SIEClient {
1782
1887
  private detectEndpointType;
1783
1888
  }
1784
1889
 
1785
- declare const SDK_VERSION = "0.6.20";
1890
+ declare const SDK_VERSION = "0.6.21";
1786
1891
 
1787
1892
  /**
1788
1893
  * Helpers for converting SIE encode results to plain JavaScript types.
@@ -2127,4 +2232,4 @@ declare function packMessage(data: unknown): Uint8Array;
2127
2232
  */
2128
2233
  declare function unpackMessage<T = unknown>(data: Uint8Array): T;
2129
2234
 
2130
- export { type Batch, type BatchList, type BatchRequestCounts, type BatchesNamespace, type CapacityInfo, type ChatChoice, type ChatChunkChoice, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionRequest, type ChatDelta, type ChatFinishReason, type ChatMessage, type ChatUsage, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type Connection, type ConnectionCreated, type ConnectionRevoked, type ConnectionsNamespace, type CreatePoolOptions, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractOptions, type ExtractResult, type FileDeleted, type FileUploadInput, type FilesNamespace, type FinishReason, type GPUMetrics, type GenerateChunk, type GenerateOptions, type GenerateResult, type GenerationUsage, type ImageInput, type ImageWireFormat, InputTooLongError, type Item, type JobChunk, type JobFieldMap, type JobItem, type JobPreflight, type JobResultItem, type JobResults, type JobSource, type JobState, type JobStatus, type JobSubmitResult, type JobsNamespace, LoraLoadingError, type ModelCapabilities, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, ResourceExhaustedError, type ResponseFormat, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type File as SIEFile, SIEStreamError, type ScoreEntry, type ScoreOptions, type ScoreResult, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type SubmitJobOptions, TERMINAL_JOB_STATES, type TimingInfo, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolSpec, type WorkerInfo, type WorkerStatusMessage, buildJobBody, connectionName, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };
2235
+ export { type AudioInput, type Batch, type BatchList, type BatchRequestCounts, type BatchesNamespace, type CapacityInfo, type ChatChoice, type ChatChunkChoice, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionRequest, type ChatDelta, type ChatFinishReason, type ChatMessage, type ChatUsage, type Classification, type ClusterStatusMessage, type ClusterSummary, type ClusterWorkerInfo, type Connection, type ConnectionCreated, type ConnectionRevoked, type ConnectionsNamespace, type CreatePoolOptions, type DType, type DetectedObject, type EncodeOptions, type EncodeResult, type Entity, type ExtractItem, type ExtractItemError, type ExtractOptions, type ExtractResult, type FileDeleted, type FileUploadInput, type FilesNamespace, type FinishReason, type GPUMetrics, type GenerateChunk, type GenerateOptions, type GenerateResult, type GenerationUsage, type ImageInput, type ImageWireFormat, InputTooLongError, type Item, type JobChunk, type JobFieldMap, type JobItem, type JobPreflight, type JobResultItem, type JobResults, type JobSource, type JobState, type JobStatus, type JobSubmitResult, type JobsNamespace, LoraLoadingError, type ModelCapabilities, type ModelConfig, type ModelDims, type ModelInfo, ModelLoadFailedError, ModelLoadingError, type ModelState, type ModelStatus, type ModelSummary, type OutputType, PoolError, type PoolInfo, type PoolSpec, type PoolStatus, ProvisioningError, type Relation, RequestError, ResourceExhaustedError, type ResponseFormat, SDK_VERSION, SIEClient, type SIEClientOptions, SIEConnectionError, SIEError, type File as SIEFile, SIEStreamError, type ScoreEntry, type ScoreOptions, type ScoreResult, type ScoreUsage, ServerError, type ServerInfo, type SparseResult, type SparseVector, type StatusMessage, type StreamGenerateOptions, type SubmitJobOptions, TERMINAL_JOB_STATES, type TimingInfo, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolSpec, type WorkerInfo, type WorkerStatusMessage, buildJobBody, connectionName, denseEmbedding, detectImageFormat, multivectorEmbedding, normalizeSparseVector, packMessage, sparseEmbedding, sparseEmbeddingMap, toFloat32Array, toImageBytes, toImageWireFormat, toNumberArray, unpackMessage };