@cloudflare/workers-types 4.20260410.1 → 4.20260411.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -478,6 +478,7 @@ export interface ExecutionContext<Props = unknown> {
478
478
  waitUntil(promise: Promise<any>): void;
479
479
  passThroughOnException(): void;
480
480
  readonly props: Props;
481
+ cache?: CacheContext;
481
482
  }
482
483
  export type ExportedHandlerFetchHandler<
483
484
  Env = unknown,
@@ -559,6 +560,23 @@ export interface AlarmInvocationInfo {
559
560
  export interface Cloudflare {
560
561
  readonly compatibilityFlags: Record<string, boolean>;
561
562
  }
563
+ export interface CachePurgeError {
564
+ code: number;
565
+ message: string;
566
+ }
567
+ export interface CachePurgeResult {
568
+ success: boolean;
569
+ zoneTag: string;
570
+ errors: CachePurgeError[];
571
+ }
572
+ export interface CachePurgeOptions {
573
+ tags?: string[];
574
+ pathPrefixes?: string[];
575
+ purgeEverything?: boolean;
576
+ }
577
+ export interface CacheContext {
578
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
579
+ }
562
580
  export declare abstract class ColoLocalActorNamespace {
563
581
  get(actorId: string): Fetcher;
564
582
  }
@@ -10307,6 +10325,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10307
10325
  inputs: ChatCompletionsInput;
10308
10326
  postProcessedOutputs: ChatCompletionsOutput;
10309
10327
  }
10328
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10329
+ inputs: ChatCompletionsInput;
10330
+ postProcessedOutputs: ChatCompletionsOutput;
10331
+ }
10310
10332
  export interface AiModels {
10311
10333
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10312
10334
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10462,6 +10484,9 @@ export type ChatCompletionsInput = XOR<
10462
10484
  export interface InferenceUpstreamError extends Error {}
10463
10485
  export interface AiInternalError extends Error {}
10464
10486
  export type AiModelListType = Record<string, any>;
10487
+ export type AiAsyncBatchResponse = {
10488
+ request_id: string;
10489
+ };
10465
10490
  export declare abstract class Ai<
10466
10491
  AiModelList extends AiModelListType = AiModels,
10467
10492
  > {
@@ -10480,29 +10505,52 @@ export declare abstract class Ai<
10480
10505
  * @param autoragId Instance ID
10481
10506
  */
10482
10507
  autorag(autoragId: string): AutoRAG;
10483
- run<
10484
- Name extends keyof AiModelList,
10485
- Options extends AiOptions,
10486
- InputOptions extends AiModelList[Name]["inputs"],
10487
- >(
10508
+ // Batch request
10509
+ run<Name extends keyof AiModelList>(
10488
10510
  model: Name,
10489
- inputs: InputOptions,
10490
- options?: Options,
10491
- ): Promise<
10492
- Options extends
10493
- | {
10494
- returnRawResponse: true;
10495
- }
10496
- | {
10497
- websocket: true;
10498
- }
10499
- ? Response
10500
- : InputOptions extends {
10501
- stream: true;
10502
- }
10503
- ? ReadableStream
10504
- : AiModelList[Name]["postProcessedOutputs"]
10505
- >;
10511
+ inputs: {
10512
+ requests: AiModelList[Name]["inputs"][];
10513
+ },
10514
+ options: AiOptions & {
10515
+ queueRequest: true;
10516
+ },
10517
+ ): Promise<AiAsyncBatchResponse>;
10518
+ // Raw response
10519
+ run<Name extends keyof AiModelList>(
10520
+ model: Name,
10521
+ inputs: AiModelList[Name]["inputs"],
10522
+ options: AiOptions & {
10523
+ returnRawResponse: true;
10524
+ },
10525
+ ): Promise<Response>;
10526
+ // WebSocket
10527
+ run<Name extends keyof AiModelList>(
10528
+ model: Name,
10529
+ inputs: AiModelList[Name]["inputs"],
10530
+ options: AiOptions & {
10531
+ websocket: true;
10532
+ },
10533
+ ): Promise<Response>;
10534
+ // Streaming
10535
+ run<Name extends keyof AiModelList>(
10536
+ model: Name,
10537
+ inputs: AiModelList[Name]["inputs"] & {
10538
+ stream: true;
10539
+ },
10540
+ options?: AiOptions,
10541
+ ): Promise<ReadableStream>;
10542
+ // Normal (default) - known model
10543
+ run<Name extends keyof AiModelList>(
10544
+ model: Name,
10545
+ inputs: AiModelList[Name]["inputs"],
10546
+ options?: AiOptions,
10547
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10548
+ // Unknown model (gateway fallback)
10549
+ run(
10550
+ model: string & {},
10551
+ inputs: Record<string, unknown>,
10552
+ options?: AiOptions,
10553
+ ): Promise<Record<string, unknown>>;
10506
10554
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10507
10555
  toMarkdown(): ToMarkdownService;
10508
10556
  toMarkdown(
@@ -492,6 +492,7 @@ interface ExecutionContext<Props = unknown> {
492
492
  passThroughOnException(): void;
493
493
  readonly exports: Cloudflare.Exports;
494
494
  readonly props: Props;
495
+ cache?: CacheContext;
495
496
  readonly version?: {
496
497
  readonly metadata?: {
497
498
  readonly id: string;
@@ -585,6 +586,23 @@ interface AlarmInvocationInfo {
585
586
  interface Cloudflare {
586
587
  readonly compatibilityFlags: Record<string, boolean>;
587
588
  }
589
+ interface CachePurgeError {
590
+ code: number;
591
+ message: string;
592
+ }
593
+ interface CachePurgeResult {
594
+ success: boolean;
595
+ zoneTag: string;
596
+ errors: CachePurgeError[];
597
+ }
598
+ interface CachePurgeOptions {
599
+ tags?: string[];
600
+ pathPrefixes?: string[];
601
+ purgeEverything?: boolean;
602
+ }
603
+ interface CacheContext {
604
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
605
+ }
588
606
  declare abstract class ColoLocalActorNamespace {
589
607
  get(actorId: string): Fetcher;
590
608
  }
@@ -11023,6 +11041,10 @@ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
11023
11041
  inputs: ChatCompletionsInput;
11024
11042
  postProcessedOutputs: ChatCompletionsOutput;
11025
11043
  }
11044
+ declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
11045
+ inputs: ChatCompletionsInput;
11046
+ postProcessedOutputs: ChatCompletionsOutput;
11047
+ }
11026
11048
  interface AiModels {
11027
11049
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
11028
11050
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -11178,6 +11200,9 @@ type ChatCompletionsInput = XOR<
11178
11200
  interface InferenceUpstreamError extends Error {}
11179
11201
  interface AiInternalError extends Error {}
11180
11202
  type AiModelListType = Record<string, any>;
11203
+ type AiAsyncBatchResponse = {
11204
+ request_id: string;
11205
+ };
11181
11206
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
11182
11207
  aiGatewayLogId: string | null;
11183
11208
  gateway(gatewayId: string): AiGateway;
@@ -11194,29 +11219,52 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
11194
11219
  * @param autoragId Instance ID
11195
11220
  */
11196
11221
  autorag(autoragId: string): AutoRAG;
11197
- run<
11198
- Name extends keyof AiModelList,
11199
- Options extends AiOptions,
11200
- InputOptions extends AiModelList[Name]["inputs"],
11201
- >(
11222
+ // Batch request
11223
+ run<Name extends keyof AiModelList>(
11202
11224
  model: Name,
11203
- inputs: InputOptions,
11204
- options?: Options,
11205
- ): Promise<
11206
- Options extends
11207
- | {
11208
- returnRawResponse: true;
11209
- }
11210
- | {
11211
- websocket: true;
11212
- }
11213
- ? Response
11214
- : InputOptions extends {
11215
- stream: true;
11216
- }
11217
- ? ReadableStream
11218
- : AiModelList[Name]["postProcessedOutputs"]
11219
- >;
11225
+ inputs: {
11226
+ requests: AiModelList[Name]["inputs"][];
11227
+ },
11228
+ options: AiOptions & {
11229
+ queueRequest: true;
11230
+ },
11231
+ ): Promise<AiAsyncBatchResponse>;
11232
+ // Raw response
11233
+ run<Name extends keyof AiModelList>(
11234
+ model: Name,
11235
+ inputs: AiModelList[Name]["inputs"],
11236
+ options: AiOptions & {
11237
+ returnRawResponse: true;
11238
+ },
11239
+ ): Promise<Response>;
11240
+ // WebSocket
11241
+ run<Name extends keyof AiModelList>(
11242
+ model: Name,
11243
+ inputs: AiModelList[Name]["inputs"],
11244
+ options: AiOptions & {
11245
+ websocket: true;
11246
+ },
11247
+ ): Promise<Response>;
11248
+ // Streaming
11249
+ run<Name extends keyof AiModelList>(
11250
+ model: Name,
11251
+ inputs: AiModelList[Name]["inputs"] & {
11252
+ stream: true;
11253
+ },
11254
+ options?: AiOptions,
11255
+ ): Promise<ReadableStream>;
11256
+ // Normal (default) - known model
11257
+ run<Name extends keyof AiModelList>(
11258
+ model: Name,
11259
+ inputs: AiModelList[Name]["inputs"],
11260
+ options?: AiOptions,
11261
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
11262
+ // Unknown model (gateway fallback)
11263
+ run(
11264
+ model: string & {},
11265
+ inputs: Record<string, unknown>,
11266
+ options?: AiOptions,
11267
+ ): Promise<Record<string, unknown>>;
11220
11268
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
11221
11269
  toMarkdown(): ToMarkdownService;
11222
11270
  toMarkdown(
@@ -494,6 +494,7 @@ export interface ExecutionContext<Props = unknown> {
494
494
  passThroughOnException(): void;
495
495
  readonly exports: Cloudflare.Exports;
496
496
  readonly props: Props;
497
+ cache?: CacheContext;
497
498
  readonly version?: {
498
499
  readonly metadata?: {
499
500
  readonly id: string;
@@ -587,6 +588,23 @@ export interface AlarmInvocationInfo {
587
588
  export interface Cloudflare {
588
589
  readonly compatibilityFlags: Record<string, boolean>;
589
590
  }
591
+ export interface CachePurgeError {
592
+ code: number;
593
+ message: string;
594
+ }
595
+ export interface CachePurgeResult {
596
+ success: boolean;
597
+ zoneTag: string;
598
+ errors: CachePurgeError[];
599
+ }
600
+ export interface CachePurgeOptions {
601
+ tags?: string[];
602
+ pathPrefixes?: string[];
603
+ purgeEverything?: boolean;
604
+ }
605
+ export interface CacheContext {
606
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
607
+ }
590
608
  export declare abstract class ColoLocalActorNamespace {
591
609
  get(actorId: string): Fetcher;
592
610
  }
@@ -11032,6 +11050,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
11032
11050
  inputs: ChatCompletionsInput;
11033
11051
  postProcessedOutputs: ChatCompletionsOutput;
11034
11052
  }
11053
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
11054
+ inputs: ChatCompletionsInput;
11055
+ postProcessedOutputs: ChatCompletionsOutput;
11056
+ }
11035
11057
  export interface AiModels {
11036
11058
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
11037
11059
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -11187,6 +11209,9 @@ export type ChatCompletionsInput = XOR<
11187
11209
  export interface InferenceUpstreamError extends Error {}
11188
11210
  export interface AiInternalError extends Error {}
11189
11211
  export type AiModelListType = Record<string, any>;
11212
+ export type AiAsyncBatchResponse = {
11213
+ request_id: string;
11214
+ };
11190
11215
  export declare abstract class Ai<
11191
11216
  AiModelList extends AiModelListType = AiModels,
11192
11217
  > {
@@ -11205,29 +11230,52 @@ export declare abstract class Ai<
11205
11230
  * @param autoragId Instance ID
11206
11231
  */
11207
11232
  autorag(autoragId: string): AutoRAG;
11208
- run<
11209
- Name extends keyof AiModelList,
11210
- Options extends AiOptions,
11211
- InputOptions extends AiModelList[Name]["inputs"],
11212
- >(
11233
+ // Batch request
11234
+ run<Name extends keyof AiModelList>(
11213
11235
  model: Name,
11214
- inputs: InputOptions,
11215
- options?: Options,
11216
- ): Promise<
11217
- Options extends
11218
- | {
11219
- returnRawResponse: true;
11220
- }
11221
- | {
11222
- websocket: true;
11223
- }
11224
- ? Response
11225
- : InputOptions extends {
11226
- stream: true;
11227
- }
11228
- ? ReadableStream
11229
- : AiModelList[Name]["postProcessedOutputs"]
11230
- >;
11236
+ inputs: {
11237
+ requests: AiModelList[Name]["inputs"][];
11238
+ },
11239
+ options: AiOptions & {
11240
+ queueRequest: true;
11241
+ },
11242
+ ): Promise<AiAsyncBatchResponse>;
11243
+ // Raw response
11244
+ run<Name extends keyof AiModelList>(
11245
+ model: Name,
11246
+ inputs: AiModelList[Name]["inputs"],
11247
+ options: AiOptions & {
11248
+ returnRawResponse: true;
11249
+ },
11250
+ ): Promise<Response>;
11251
+ // WebSocket
11252
+ run<Name extends keyof AiModelList>(
11253
+ model: Name,
11254
+ inputs: AiModelList[Name]["inputs"],
11255
+ options: AiOptions & {
11256
+ websocket: true;
11257
+ },
11258
+ ): Promise<Response>;
11259
+ // Streaming
11260
+ run<Name extends keyof AiModelList>(
11261
+ model: Name,
11262
+ inputs: AiModelList[Name]["inputs"] & {
11263
+ stream: true;
11264
+ },
11265
+ options?: AiOptions,
11266
+ ): Promise<ReadableStream>;
11267
+ // Normal (default) - known model
11268
+ run<Name extends keyof AiModelList>(
11269
+ model: Name,
11270
+ inputs: AiModelList[Name]["inputs"],
11271
+ options?: AiOptions,
11272
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
11273
+ // Unknown model (gateway fallback)
11274
+ run(
11275
+ model: string & {},
11276
+ inputs: Record<string, unknown>,
11277
+ options?: AiOptions,
11278
+ ): Promise<Record<string, unknown>>;
11231
11279
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
11232
11280
  toMarkdown(): ToMarkdownService;
11233
11281
  toMarkdown(
package/index.d.ts CHANGED
@@ -468,6 +468,7 @@ interface ExecutionContext<Props = unknown> {
468
468
  waitUntil(promise: Promise<any>): void;
469
469
  passThroughOnException(): void;
470
470
  readonly props: Props;
471
+ cache?: CacheContext;
471
472
  }
472
473
  type ExportedHandlerFetchHandler<
473
474
  Env = unknown,
@@ -544,6 +545,23 @@ interface AlarmInvocationInfo {
544
545
  interface Cloudflare {
545
546
  readonly compatibilityFlags: Record<string, boolean>;
546
547
  }
548
+ interface CachePurgeError {
549
+ code: number;
550
+ message: string;
551
+ }
552
+ interface CachePurgeResult {
553
+ success: boolean;
554
+ zoneTag: string;
555
+ errors: CachePurgeError[];
556
+ }
557
+ interface CachePurgeOptions {
558
+ tags?: string[];
559
+ pathPrefixes?: string[];
560
+ purgeEverything?: boolean;
561
+ }
562
+ interface CacheContext {
563
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
564
+ }
547
565
  declare abstract class ColoLocalActorNamespace {
548
566
  get(actorId: string): Fetcher;
549
567
  }
@@ -10191,6 +10209,10 @@ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10191
10209
  inputs: ChatCompletionsInput;
10192
10210
  postProcessedOutputs: ChatCompletionsOutput;
10193
10211
  }
10212
+ declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10213
+ inputs: ChatCompletionsInput;
10214
+ postProcessedOutputs: ChatCompletionsOutput;
10215
+ }
10194
10216
  interface AiModels {
10195
10217
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10196
10218
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10346,6 +10368,9 @@ type ChatCompletionsInput = XOR<
10346
10368
  interface InferenceUpstreamError extends Error {}
10347
10369
  interface AiInternalError extends Error {}
10348
10370
  type AiModelListType = Record<string, any>;
10371
+ type AiAsyncBatchResponse = {
10372
+ request_id: string;
10373
+ };
10349
10374
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10350
10375
  aiGatewayLogId: string | null;
10351
10376
  gateway(gatewayId: string): AiGateway;
@@ -10362,29 +10387,52 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10362
10387
  * @param autoragId Instance ID
10363
10388
  */
10364
10389
  autorag(autoragId: string): AutoRAG;
10365
- run<
10366
- Name extends keyof AiModelList,
10367
- Options extends AiOptions,
10368
- InputOptions extends AiModelList[Name]["inputs"],
10369
- >(
10390
+ // Batch request
10391
+ run<Name extends keyof AiModelList>(
10370
10392
  model: Name,
10371
- inputs: InputOptions,
10372
- options?: Options,
10373
- ): Promise<
10374
- Options extends
10375
- | {
10376
- returnRawResponse: true;
10377
- }
10378
- | {
10379
- websocket: true;
10380
- }
10381
- ? Response
10382
- : InputOptions extends {
10383
- stream: true;
10384
- }
10385
- ? ReadableStream
10386
- : AiModelList[Name]["postProcessedOutputs"]
10387
- >;
10393
+ inputs: {
10394
+ requests: AiModelList[Name]["inputs"][];
10395
+ },
10396
+ options: AiOptions & {
10397
+ queueRequest: true;
10398
+ },
10399
+ ): Promise<AiAsyncBatchResponse>;
10400
+ // Raw response
10401
+ run<Name extends keyof AiModelList>(
10402
+ model: Name,
10403
+ inputs: AiModelList[Name]["inputs"],
10404
+ options: AiOptions & {
10405
+ returnRawResponse: true;
10406
+ },
10407
+ ): Promise<Response>;
10408
+ // WebSocket
10409
+ run<Name extends keyof AiModelList>(
10410
+ model: Name,
10411
+ inputs: AiModelList[Name]["inputs"],
10412
+ options: AiOptions & {
10413
+ websocket: true;
10414
+ },
10415
+ ): Promise<Response>;
10416
+ // Streaming
10417
+ run<Name extends keyof AiModelList>(
10418
+ model: Name,
10419
+ inputs: AiModelList[Name]["inputs"] & {
10420
+ stream: true;
10421
+ },
10422
+ options?: AiOptions,
10423
+ ): Promise<ReadableStream>;
10424
+ // Normal (default) - known model
10425
+ run<Name extends keyof AiModelList>(
10426
+ model: Name,
10427
+ inputs: AiModelList[Name]["inputs"],
10428
+ options?: AiOptions,
10429
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10430
+ // Unknown model (gateway fallback)
10431
+ run(
10432
+ model: string & {},
10433
+ inputs: Record<string, unknown>,
10434
+ options?: AiOptions,
10435
+ ): Promise<Record<string, unknown>>;
10388
10436
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10389
10437
  toMarkdown(): ToMarkdownService;
10390
10438
  toMarkdown(
package/index.ts CHANGED
@@ -470,6 +470,7 @@ export interface ExecutionContext<Props = unknown> {
470
470
  waitUntil(promise: Promise<any>): void;
471
471
  passThroughOnException(): void;
472
472
  readonly props: Props;
473
+ cache?: CacheContext;
473
474
  }
474
475
  export type ExportedHandlerFetchHandler<
475
476
  Env = unknown,
@@ -546,6 +547,23 @@ export interface AlarmInvocationInfo {
546
547
  export interface Cloudflare {
547
548
  readonly compatibilityFlags: Record<string, boolean>;
548
549
  }
550
+ export interface CachePurgeError {
551
+ code: number;
552
+ message: string;
553
+ }
554
+ export interface CachePurgeResult {
555
+ success: boolean;
556
+ zoneTag: string;
557
+ errors: CachePurgeError[];
558
+ }
559
+ export interface CachePurgeOptions {
560
+ tags?: string[];
561
+ pathPrefixes?: string[];
562
+ purgeEverything?: boolean;
563
+ }
564
+ export interface CacheContext {
565
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
566
+ }
549
567
  export declare abstract class ColoLocalActorNamespace {
550
568
  get(actorId: string): Fetcher;
551
569
  }
@@ -10200,6 +10218,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10200
10218
  inputs: ChatCompletionsInput;
10201
10219
  postProcessedOutputs: ChatCompletionsOutput;
10202
10220
  }
10221
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10222
+ inputs: ChatCompletionsInput;
10223
+ postProcessedOutputs: ChatCompletionsOutput;
10224
+ }
10203
10225
  export interface AiModels {
10204
10226
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10205
10227
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10355,6 +10377,9 @@ export type ChatCompletionsInput = XOR<
10355
10377
  export interface InferenceUpstreamError extends Error {}
10356
10378
  export interface AiInternalError extends Error {}
10357
10379
  export type AiModelListType = Record<string, any>;
10380
+ export type AiAsyncBatchResponse = {
10381
+ request_id: string;
10382
+ };
10358
10383
  export declare abstract class Ai<
10359
10384
  AiModelList extends AiModelListType = AiModels,
10360
10385
  > {
@@ -10373,29 +10398,52 @@ export declare abstract class Ai<
10373
10398
  * @param autoragId Instance ID
10374
10399
  */
10375
10400
  autorag(autoragId: string): AutoRAG;
10376
- run<
10377
- Name extends keyof AiModelList,
10378
- Options extends AiOptions,
10379
- InputOptions extends AiModelList[Name]["inputs"],
10380
- >(
10401
+ // Batch request
10402
+ run<Name extends keyof AiModelList>(
10381
10403
  model: Name,
10382
- inputs: InputOptions,
10383
- options?: Options,
10384
- ): Promise<
10385
- Options extends
10386
- | {
10387
- returnRawResponse: true;
10388
- }
10389
- | {
10390
- websocket: true;
10391
- }
10392
- ? Response
10393
- : InputOptions extends {
10394
- stream: true;
10395
- }
10396
- ? ReadableStream
10397
- : AiModelList[Name]["postProcessedOutputs"]
10398
- >;
10404
+ inputs: {
10405
+ requests: AiModelList[Name]["inputs"][];
10406
+ },
10407
+ options: AiOptions & {
10408
+ queueRequest: true;
10409
+ },
10410
+ ): Promise<AiAsyncBatchResponse>;
10411
+ // Raw response
10412
+ run<Name extends keyof AiModelList>(
10413
+ model: Name,
10414
+ inputs: AiModelList[Name]["inputs"],
10415
+ options: AiOptions & {
10416
+ returnRawResponse: true;
10417
+ },
10418
+ ): Promise<Response>;
10419
+ // WebSocket
10420
+ run<Name extends keyof AiModelList>(
10421
+ model: Name,
10422
+ inputs: AiModelList[Name]["inputs"],
10423
+ options: AiOptions & {
10424
+ websocket: true;
10425
+ },
10426
+ ): Promise<Response>;
10427
+ // Streaming
10428
+ run<Name extends keyof AiModelList>(
10429
+ model: Name,
10430
+ inputs: AiModelList[Name]["inputs"] & {
10431
+ stream: true;
10432
+ },
10433
+ options?: AiOptions,
10434
+ ): Promise<ReadableStream>;
10435
+ // Normal (default) - known model
10436
+ run<Name extends keyof AiModelList>(
10437
+ model: Name,
10438
+ inputs: AiModelList[Name]["inputs"],
10439
+ options?: AiOptions,
10440
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10441
+ // Unknown model (gateway fallback)
10442
+ run(
10443
+ model: string & {},
10444
+ inputs: Record<string, unknown>,
10445
+ options?: AiOptions,
10446
+ ): Promise<Record<string, unknown>>;
10399
10447
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10400
10448
  toMarkdown(): ToMarkdownService;
10401
10449
  toMarkdown(