@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.
@@ -473,6 +473,7 @@ export interface ExecutionContext<Props = unknown> {
473
473
  waitUntil(promise: Promise<any>): void;
474
474
  passThroughOnException(): void;
475
475
  readonly props: Props;
476
+ cache?: CacheContext;
476
477
  }
477
478
  export type ExportedHandlerFetchHandler<
478
479
  Env = unknown,
@@ -554,6 +555,23 @@ export interface AlarmInvocationInfo {
554
555
  export interface Cloudflare {
555
556
  readonly compatibilityFlags: Record<string, boolean>;
556
557
  }
558
+ export interface CachePurgeError {
559
+ code: number;
560
+ message: string;
561
+ }
562
+ export interface CachePurgeResult {
563
+ success: boolean;
564
+ zoneTag: string;
565
+ errors: CachePurgeError[];
566
+ }
567
+ export interface CachePurgeOptions {
568
+ tags?: string[];
569
+ pathPrefixes?: string[];
570
+ purgeEverything?: boolean;
571
+ }
572
+ export interface CacheContext {
573
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
574
+ }
557
575
  export declare abstract class ColoLocalActorNamespace {
558
576
  get(actorId: string): Fetcher;
559
577
  }
@@ -10275,6 +10293,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10275
10293
  inputs: ChatCompletionsInput;
10276
10294
  postProcessedOutputs: ChatCompletionsOutput;
10277
10295
  }
10296
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10297
+ inputs: ChatCompletionsInput;
10298
+ postProcessedOutputs: ChatCompletionsOutput;
10299
+ }
10278
10300
  export interface AiModels {
10279
10301
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10280
10302
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10430,6 +10452,9 @@ export type ChatCompletionsInput = XOR<
10430
10452
  export interface InferenceUpstreamError extends Error {}
10431
10453
  export interface AiInternalError extends Error {}
10432
10454
  export type AiModelListType = Record<string, any>;
10455
+ export type AiAsyncBatchResponse = {
10456
+ request_id: string;
10457
+ };
10433
10458
  export declare abstract class Ai<
10434
10459
  AiModelList extends AiModelListType = AiModels,
10435
10460
  > {
@@ -10448,29 +10473,52 @@ export declare abstract class Ai<
10448
10473
  * @param autoragId Instance ID
10449
10474
  */
10450
10475
  autorag(autoragId: string): AutoRAG;
10451
- run<
10452
- Name extends keyof AiModelList,
10453
- Options extends AiOptions,
10454
- InputOptions extends AiModelList[Name]["inputs"],
10455
- >(
10476
+ // Batch request
10477
+ run<Name extends keyof AiModelList>(
10456
10478
  model: Name,
10457
- inputs: InputOptions,
10458
- options?: Options,
10459
- ): Promise<
10460
- Options extends
10461
- | {
10462
- returnRawResponse: true;
10463
- }
10464
- | {
10465
- websocket: true;
10466
- }
10467
- ? Response
10468
- : InputOptions extends {
10469
- stream: true;
10470
- }
10471
- ? ReadableStream
10472
- : AiModelList[Name]["postProcessedOutputs"]
10473
- >;
10479
+ inputs: {
10480
+ requests: AiModelList[Name]["inputs"][];
10481
+ },
10482
+ options: AiOptions & {
10483
+ queueRequest: true;
10484
+ },
10485
+ ): Promise<AiAsyncBatchResponse>;
10486
+ // Raw response
10487
+ run<Name extends keyof AiModelList>(
10488
+ model: Name,
10489
+ inputs: AiModelList[Name]["inputs"],
10490
+ options: AiOptions & {
10491
+ returnRawResponse: true;
10492
+ },
10493
+ ): Promise<Response>;
10494
+ // WebSocket
10495
+ run<Name extends keyof AiModelList>(
10496
+ model: Name,
10497
+ inputs: AiModelList[Name]["inputs"],
10498
+ options: AiOptions & {
10499
+ websocket: true;
10500
+ },
10501
+ ): Promise<Response>;
10502
+ // Streaming
10503
+ run<Name extends keyof AiModelList>(
10504
+ model: Name,
10505
+ inputs: AiModelList[Name]["inputs"] & {
10506
+ stream: true;
10507
+ },
10508
+ options?: AiOptions,
10509
+ ): Promise<ReadableStream>;
10510
+ // Normal (default) - known model
10511
+ run<Name extends keyof AiModelList>(
10512
+ model: Name,
10513
+ inputs: AiModelList[Name]["inputs"],
10514
+ options?: AiOptions,
10515
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10516
+ // Unknown model (gateway fallback)
10517
+ run(
10518
+ model: string & {},
10519
+ inputs: Record<string, unknown>,
10520
+ options?: AiOptions,
10521
+ ): Promise<Record<string, unknown>>;
10474
10522
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10475
10523
  toMarkdown(): ToMarkdownService;
10476
10524
  toMarkdown(
@@ -471,6 +471,7 @@ interface ExecutionContext<Props = unknown> {
471
471
  waitUntil(promise: Promise<any>): void;
472
472
  passThroughOnException(): void;
473
473
  readonly props: Props;
474
+ cache?: CacheContext;
474
475
  }
475
476
  type ExportedHandlerFetchHandler<
476
477
  Env = unknown,
@@ -552,6 +553,23 @@ interface AlarmInvocationInfo {
552
553
  interface Cloudflare {
553
554
  readonly compatibilityFlags: Record<string, boolean>;
554
555
  }
556
+ interface CachePurgeError {
557
+ code: number;
558
+ message: string;
559
+ }
560
+ interface CachePurgeResult {
561
+ success: boolean;
562
+ zoneTag: string;
563
+ errors: CachePurgeError[];
564
+ }
565
+ interface CachePurgeOptions {
566
+ tags?: string[];
567
+ pathPrefixes?: string[];
568
+ purgeEverything?: boolean;
569
+ }
570
+ interface CacheContext {
571
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
572
+ }
555
573
  declare abstract class ColoLocalActorNamespace {
556
574
  get(actorId: string): Fetcher;
557
575
  }
@@ -10267,6 +10285,10 @@ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10267
10285
  inputs: ChatCompletionsInput;
10268
10286
  postProcessedOutputs: ChatCompletionsOutput;
10269
10287
  }
10288
+ declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10289
+ inputs: ChatCompletionsInput;
10290
+ postProcessedOutputs: ChatCompletionsOutput;
10291
+ }
10270
10292
  interface AiModels {
10271
10293
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10272
10294
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10422,6 +10444,9 @@ type ChatCompletionsInput = XOR<
10422
10444
  interface InferenceUpstreamError extends Error {}
10423
10445
  interface AiInternalError extends Error {}
10424
10446
  type AiModelListType = Record<string, any>;
10447
+ type AiAsyncBatchResponse = {
10448
+ request_id: string;
10449
+ };
10425
10450
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10426
10451
  aiGatewayLogId: string | null;
10427
10452
  gateway(gatewayId: string): AiGateway;
@@ -10438,29 +10463,52 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10438
10463
  * @param autoragId Instance ID
10439
10464
  */
10440
10465
  autorag(autoragId: string): AutoRAG;
10441
- run<
10442
- Name extends keyof AiModelList,
10443
- Options extends AiOptions,
10444
- InputOptions extends AiModelList[Name]["inputs"],
10445
- >(
10466
+ // Batch request
10467
+ run<Name extends keyof AiModelList>(
10446
10468
  model: Name,
10447
- inputs: InputOptions,
10448
- options?: Options,
10449
- ): Promise<
10450
- Options extends
10451
- | {
10452
- returnRawResponse: true;
10453
- }
10454
- | {
10455
- websocket: true;
10456
- }
10457
- ? Response
10458
- : InputOptions extends {
10459
- stream: true;
10460
- }
10461
- ? ReadableStream
10462
- : AiModelList[Name]["postProcessedOutputs"]
10463
- >;
10469
+ inputs: {
10470
+ requests: AiModelList[Name]["inputs"][];
10471
+ },
10472
+ options: AiOptions & {
10473
+ queueRequest: true;
10474
+ },
10475
+ ): Promise<AiAsyncBatchResponse>;
10476
+ // Raw response
10477
+ run<Name extends keyof AiModelList>(
10478
+ model: Name,
10479
+ inputs: AiModelList[Name]["inputs"],
10480
+ options: AiOptions & {
10481
+ returnRawResponse: true;
10482
+ },
10483
+ ): Promise<Response>;
10484
+ // WebSocket
10485
+ run<Name extends keyof AiModelList>(
10486
+ model: Name,
10487
+ inputs: AiModelList[Name]["inputs"],
10488
+ options: AiOptions & {
10489
+ websocket: true;
10490
+ },
10491
+ ): Promise<Response>;
10492
+ // Streaming
10493
+ run<Name extends keyof AiModelList>(
10494
+ model: Name,
10495
+ inputs: AiModelList[Name]["inputs"] & {
10496
+ stream: true;
10497
+ },
10498
+ options?: AiOptions,
10499
+ ): Promise<ReadableStream>;
10500
+ // Normal (default) - known model
10501
+ run<Name extends keyof AiModelList>(
10502
+ model: Name,
10503
+ inputs: AiModelList[Name]["inputs"],
10504
+ options?: AiOptions,
10505
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10506
+ // Unknown model (gateway fallback)
10507
+ run(
10508
+ model: string & {},
10509
+ inputs: Record<string, unknown>,
10510
+ options?: AiOptions,
10511
+ ): Promise<Record<string, unknown>>;
10464
10512
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10465
10513
  toMarkdown(): ToMarkdownService;
10466
10514
  toMarkdown(
@@ -473,6 +473,7 @@ export interface ExecutionContext<Props = unknown> {
473
473
  waitUntil(promise: Promise<any>): void;
474
474
  passThroughOnException(): void;
475
475
  readonly props: Props;
476
+ cache?: CacheContext;
476
477
  }
477
478
  export type ExportedHandlerFetchHandler<
478
479
  Env = unknown,
@@ -554,6 +555,23 @@ export interface AlarmInvocationInfo {
554
555
  export interface Cloudflare {
555
556
  readonly compatibilityFlags: Record<string, boolean>;
556
557
  }
558
+ export interface CachePurgeError {
559
+ code: number;
560
+ message: string;
561
+ }
562
+ export interface CachePurgeResult {
563
+ success: boolean;
564
+ zoneTag: string;
565
+ errors: CachePurgeError[];
566
+ }
567
+ export interface CachePurgeOptions {
568
+ tags?: string[];
569
+ pathPrefixes?: string[];
570
+ purgeEverything?: boolean;
571
+ }
572
+ export interface CacheContext {
573
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
574
+ }
557
575
  export declare abstract class ColoLocalActorNamespace {
558
576
  get(actorId: string): Fetcher;
559
577
  }
@@ -10276,6 +10294,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10276
10294
  inputs: ChatCompletionsInput;
10277
10295
  postProcessedOutputs: ChatCompletionsOutput;
10278
10296
  }
10297
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10298
+ inputs: ChatCompletionsInput;
10299
+ postProcessedOutputs: ChatCompletionsOutput;
10300
+ }
10279
10301
  export interface AiModels {
10280
10302
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10281
10303
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10431,6 +10453,9 @@ export type ChatCompletionsInput = XOR<
10431
10453
  export interface InferenceUpstreamError extends Error {}
10432
10454
  export interface AiInternalError extends Error {}
10433
10455
  export type AiModelListType = Record<string, any>;
10456
+ export type AiAsyncBatchResponse = {
10457
+ request_id: string;
10458
+ };
10434
10459
  export declare abstract class Ai<
10435
10460
  AiModelList extends AiModelListType = AiModels,
10436
10461
  > {
@@ -10449,29 +10474,52 @@ export declare abstract class Ai<
10449
10474
  * @param autoragId Instance ID
10450
10475
  */
10451
10476
  autorag(autoragId: string): AutoRAG;
10452
- run<
10453
- Name extends keyof AiModelList,
10454
- Options extends AiOptions,
10455
- InputOptions extends AiModelList[Name]["inputs"],
10456
- >(
10477
+ // Batch request
10478
+ run<Name extends keyof AiModelList>(
10457
10479
  model: Name,
10458
- inputs: InputOptions,
10459
- options?: Options,
10460
- ): Promise<
10461
- Options extends
10462
- | {
10463
- returnRawResponse: true;
10464
- }
10465
- | {
10466
- websocket: true;
10467
- }
10468
- ? Response
10469
- : InputOptions extends {
10470
- stream: true;
10471
- }
10472
- ? ReadableStream
10473
- : AiModelList[Name]["postProcessedOutputs"]
10474
- >;
10480
+ inputs: {
10481
+ requests: AiModelList[Name]["inputs"][];
10482
+ },
10483
+ options: AiOptions & {
10484
+ queueRequest: true;
10485
+ },
10486
+ ): Promise<AiAsyncBatchResponse>;
10487
+ // Raw response
10488
+ run<Name extends keyof AiModelList>(
10489
+ model: Name,
10490
+ inputs: AiModelList[Name]["inputs"],
10491
+ options: AiOptions & {
10492
+ returnRawResponse: true;
10493
+ },
10494
+ ): Promise<Response>;
10495
+ // WebSocket
10496
+ run<Name extends keyof AiModelList>(
10497
+ model: Name,
10498
+ inputs: AiModelList[Name]["inputs"],
10499
+ options: AiOptions & {
10500
+ websocket: true;
10501
+ },
10502
+ ): Promise<Response>;
10503
+ // Streaming
10504
+ run<Name extends keyof AiModelList>(
10505
+ model: Name,
10506
+ inputs: AiModelList[Name]["inputs"] & {
10507
+ stream: true;
10508
+ },
10509
+ options?: AiOptions,
10510
+ ): Promise<ReadableStream>;
10511
+ // Normal (default) - known model
10512
+ run<Name extends keyof AiModelList>(
10513
+ model: Name,
10514
+ inputs: AiModelList[Name]["inputs"],
10515
+ options?: AiOptions,
10516
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10517
+ // Unknown model (gateway fallback)
10518
+ run(
10519
+ model: string & {},
10520
+ inputs: Record<string, unknown>,
10521
+ options?: AiOptions,
10522
+ ): Promise<Record<string, unknown>>;
10475
10523
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10476
10524
  toMarkdown(): ToMarkdownService;
10477
10525
  toMarkdown(
@@ -471,6 +471,7 @@ interface ExecutionContext<Props = unknown> {
471
471
  waitUntil(promise: Promise<any>): void;
472
472
  passThroughOnException(): void;
473
473
  readonly props: Props;
474
+ cache?: CacheContext;
474
475
  }
475
476
  type ExportedHandlerFetchHandler<
476
477
  Env = unknown,
@@ -552,6 +553,23 @@ interface AlarmInvocationInfo {
552
553
  interface Cloudflare {
553
554
  readonly compatibilityFlags: Record<string, boolean>;
554
555
  }
556
+ interface CachePurgeError {
557
+ code: number;
558
+ message: string;
559
+ }
560
+ interface CachePurgeResult {
561
+ success: boolean;
562
+ zoneTag: string;
563
+ errors: CachePurgeError[];
564
+ }
565
+ interface CachePurgeOptions {
566
+ tags?: string[];
567
+ pathPrefixes?: string[];
568
+ purgeEverything?: boolean;
569
+ }
570
+ interface CacheContext {
571
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
572
+ }
555
573
  declare abstract class ColoLocalActorNamespace {
556
574
  get(actorId: string): Fetcher;
557
575
  }
@@ -10287,6 +10305,10 @@ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10287
10305
  inputs: ChatCompletionsInput;
10288
10306
  postProcessedOutputs: ChatCompletionsOutput;
10289
10307
  }
10308
+ declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10309
+ inputs: ChatCompletionsInput;
10310
+ postProcessedOutputs: ChatCompletionsOutput;
10311
+ }
10290
10312
  interface AiModels {
10291
10313
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10292
10314
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10442,6 +10464,9 @@ type ChatCompletionsInput = XOR<
10442
10464
  interface InferenceUpstreamError extends Error {}
10443
10465
  interface AiInternalError extends Error {}
10444
10466
  type AiModelListType = Record<string, any>;
10467
+ type AiAsyncBatchResponse = {
10468
+ request_id: string;
10469
+ };
10445
10470
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10446
10471
  aiGatewayLogId: string | null;
10447
10472
  gateway(gatewayId: string): AiGateway;
@@ -10458,29 +10483,52 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10458
10483
  * @param autoragId Instance ID
10459
10484
  */
10460
10485
  autorag(autoragId: string): AutoRAG;
10461
- run<
10462
- Name extends keyof AiModelList,
10463
- Options extends AiOptions,
10464
- InputOptions extends AiModelList[Name]["inputs"],
10465
- >(
10486
+ // Batch request
10487
+ run<Name extends keyof AiModelList>(
10466
10488
  model: Name,
10467
- inputs: InputOptions,
10468
- options?: Options,
10469
- ): Promise<
10470
- Options extends
10471
- | {
10472
- returnRawResponse: true;
10473
- }
10474
- | {
10475
- websocket: true;
10476
- }
10477
- ? Response
10478
- : InputOptions extends {
10479
- stream: true;
10480
- }
10481
- ? ReadableStream
10482
- : AiModelList[Name]["postProcessedOutputs"]
10483
- >;
10489
+ inputs: {
10490
+ requests: AiModelList[Name]["inputs"][];
10491
+ },
10492
+ options: AiOptions & {
10493
+ queueRequest: true;
10494
+ },
10495
+ ): Promise<AiAsyncBatchResponse>;
10496
+ // Raw response
10497
+ run<Name extends keyof AiModelList>(
10498
+ model: Name,
10499
+ inputs: AiModelList[Name]["inputs"],
10500
+ options: AiOptions & {
10501
+ returnRawResponse: true;
10502
+ },
10503
+ ): Promise<Response>;
10504
+ // WebSocket
10505
+ run<Name extends keyof AiModelList>(
10506
+ model: Name,
10507
+ inputs: AiModelList[Name]["inputs"],
10508
+ options: AiOptions & {
10509
+ websocket: true;
10510
+ },
10511
+ ): Promise<Response>;
10512
+ // Streaming
10513
+ run<Name extends keyof AiModelList>(
10514
+ model: Name,
10515
+ inputs: AiModelList[Name]["inputs"] & {
10516
+ stream: true;
10517
+ },
10518
+ options?: AiOptions,
10519
+ ): Promise<ReadableStream>;
10520
+ // Normal (default) - known model
10521
+ run<Name extends keyof AiModelList>(
10522
+ model: Name,
10523
+ inputs: AiModelList[Name]["inputs"],
10524
+ options?: AiOptions,
10525
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10526
+ // Unknown model (gateway fallback)
10527
+ run(
10528
+ model: string & {},
10529
+ inputs: Record<string, unknown>,
10530
+ options?: AiOptions,
10531
+ ): Promise<Record<string, unknown>>;
10484
10532
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10485
10533
  toMarkdown(): ToMarkdownService;
10486
10534
  toMarkdown(
@@ -473,6 +473,7 @@ export interface ExecutionContext<Props = unknown> {
473
473
  waitUntil(promise: Promise<any>): void;
474
474
  passThroughOnException(): void;
475
475
  readonly props: Props;
476
+ cache?: CacheContext;
476
477
  }
477
478
  export type ExportedHandlerFetchHandler<
478
479
  Env = unknown,
@@ -554,6 +555,23 @@ export interface AlarmInvocationInfo {
554
555
  export interface Cloudflare {
555
556
  readonly compatibilityFlags: Record<string, boolean>;
556
557
  }
558
+ export interface CachePurgeError {
559
+ code: number;
560
+ message: string;
561
+ }
562
+ export interface CachePurgeResult {
563
+ success: boolean;
564
+ zoneTag: string;
565
+ errors: CachePurgeError[];
566
+ }
567
+ export interface CachePurgeOptions {
568
+ tags?: string[];
569
+ pathPrefixes?: string[];
570
+ purgeEverything?: boolean;
571
+ }
572
+ export interface CacheContext {
573
+ purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
574
+ }
557
575
  export declare abstract class ColoLocalActorNamespace {
558
576
  get(actorId: string): Fetcher;
559
577
  }
@@ -10296,6 +10314,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10296
10314
  inputs: ChatCompletionsInput;
10297
10315
  postProcessedOutputs: ChatCompletionsOutput;
10298
10316
  }
10317
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10318
+ inputs: ChatCompletionsInput;
10319
+ postProcessedOutputs: ChatCompletionsOutput;
10320
+ }
10299
10321
  export interface AiModels {
10300
10322
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10301
10323
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10451,6 +10473,9 @@ export type ChatCompletionsInput = XOR<
10451
10473
  export interface InferenceUpstreamError extends Error {}
10452
10474
  export interface AiInternalError extends Error {}
10453
10475
  export type AiModelListType = Record<string, any>;
10476
+ export type AiAsyncBatchResponse = {
10477
+ request_id: string;
10478
+ };
10454
10479
  export declare abstract class Ai<
10455
10480
  AiModelList extends AiModelListType = AiModels,
10456
10481
  > {
@@ -10469,29 +10494,52 @@ export declare abstract class Ai<
10469
10494
  * @param autoragId Instance ID
10470
10495
  */
10471
10496
  autorag(autoragId: string): AutoRAG;
10472
- run<
10473
- Name extends keyof AiModelList,
10474
- Options extends AiOptions,
10475
- InputOptions extends AiModelList[Name]["inputs"],
10476
- >(
10497
+ // Batch request
10498
+ run<Name extends keyof AiModelList>(
10477
10499
  model: Name,
10478
- inputs: InputOptions,
10479
- options?: Options,
10480
- ): Promise<
10481
- Options extends
10482
- | {
10483
- returnRawResponse: true;
10484
- }
10485
- | {
10486
- websocket: true;
10487
- }
10488
- ? Response
10489
- : InputOptions extends {
10490
- stream: true;
10491
- }
10492
- ? ReadableStream
10493
- : AiModelList[Name]["postProcessedOutputs"]
10494
- >;
10500
+ inputs: {
10501
+ requests: AiModelList[Name]["inputs"][];
10502
+ },
10503
+ options: AiOptions & {
10504
+ queueRequest: true;
10505
+ },
10506
+ ): Promise<AiAsyncBatchResponse>;
10507
+ // Raw response
10508
+ run<Name extends keyof AiModelList>(
10509
+ model: Name,
10510
+ inputs: AiModelList[Name]["inputs"],
10511
+ options: AiOptions & {
10512
+ returnRawResponse: true;
10513
+ },
10514
+ ): Promise<Response>;
10515
+ // WebSocket
10516
+ run<Name extends keyof AiModelList>(
10517
+ model: Name,
10518
+ inputs: AiModelList[Name]["inputs"],
10519
+ options: AiOptions & {
10520
+ websocket: true;
10521
+ },
10522
+ ): Promise<Response>;
10523
+ // Streaming
10524
+ run<Name extends keyof AiModelList>(
10525
+ model: Name,
10526
+ inputs: AiModelList[Name]["inputs"] & {
10527
+ stream: true;
10528
+ },
10529
+ options?: AiOptions,
10530
+ ): Promise<ReadableStream>;
10531
+ // Normal (default) - known model
10532
+ run<Name extends keyof AiModelList>(
10533
+ model: Name,
10534
+ inputs: AiModelList[Name]["inputs"],
10535
+ options?: AiOptions,
10536
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10537
+ // Unknown model (gateway fallback)
10538
+ run(
10539
+ model: string & {},
10540
+ inputs: Record<string, unknown>,
10541
+ options?: AiOptions,
10542
+ ): Promise<Record<string, unknown>>;
10495
10543
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10496
10544
  toMarkdown(): ToMarkdownService;
10497
10545
  toMarkdown(