@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.
@@ -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(
@@ -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(
@@ -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
  }
@@ -10258,6 +10276,10 @@ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10258
10276
  inputs: ChatCompletionsInput;
10259
10277
  postProcessedOutputs: ChatCompletionsOutput;
10260
10278
  }
10279
+ declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10280
+ inputs: ChatCompletionsInput;
10281
+ postProcessedOutputs: ChatCompletionsOutput;
10282
+ }
10261
10283
  interface AiModels {
10262
10284
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10263
10285
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10413,6 +10435,9 @@ type ChatCompletionsInput = XOR<
10413
10435
  interface InferenceUpstreamError extends Error {}
10414
10436
  interface AiInternalError extends Error {}
10415
10437
  type AiModelListType = Record<string, any>;
10438
+ type AiAsyncBatchResponse = {
10439
+ request_id: string;
10440
+ };
10416
10441
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10417
10442
  aiGatewayLogId: string | null;
10418
10443
  gateway(gatewayId: string): AiGateway;
@@ -10429,29 +10454,52 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10429
10454
  * @param autoragId Instance ID
10430
10455
  */
10431
10456
  autorag(autoragId: string): AutoRAG;
10432
- run<
10433
- Name extends keyof AiModelList,
10434
- Options extends AiOptions,
10435
- InputOptions extends AiModelList[Name]["inputs"],
10436
- >(
10457
+ // Batch request
10458
+ run<Name extends keyof AiModelList>(
10437
10459
  model: Name,
10438
- inputs: InputOptions,
10439
- options?: Options,
10440
- ): Promise<
10441
- Options extends
10442
- | {
10443
- returnRawResponse: true;
10444
- }
10445
- | {
10446
- websocket: true;
10447
- }
10448
- ? Response
10449
- : InputOptions extends {
10450
- stream: true;
10451
- }
10452
- ? ReadableStream
10453
- : AiModelList[Name]["postProcessedOutputs"]
10454
- >;
10460
+ inputs: {
10461
+ requests: AiModelList[Name]["inputs"][];
10462
+ },
10463
+ options: AiOptions & {
10464
+ queueRequest: true;
10465
+ },
10466
+ ): Promise<AiAsyncBatchResponse>;
10467
+ // Raw response
10468
+ run<Name extends keyof AiModelList>(
10469
+ model: Name,
10470
+ inputs: AiModelList[Name]["inputs"],
10471
+ options: AiOptions & {
10472
+ returnRawResponse: true;
10473
+ },
10474
+ ): Promise<Response>;
10475
+ // WebSocket
10476
+ run<Name extends keyof AiModelList>(
10477
+ model: Name,
10478
+ inputs: AiModelList[Name]["inputs"],
10479
+ options: AiOptions & {
10480
+ websocket: true;
10481
+ },
10482
+ ): Promise<Response>;
10483
+ // Streaming
10484
+ run<Name extends keyof AiModelList>(
10485
+ model: Name,
10486
+ inputs: AiModelList[Name]["inputs"] & {
10487
+ stream: true;
10488
+ },
10489
+ options?: AiOptions,
10490
+ ): Promise<ReadableStream>;
10491
+ // Normal (default) - known model
10492
+ run<Name extends keyof AiModelList>(
10493
+ model: Name,
10494
+ inputs: AiModelList[Name]["inputs"],
10495
+ options?: AiOptions,
10496
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10497
+ // Unknown model (gateway fallback)
10498
+ run(
10499
+ model: string & {},
10500
+ inputs: Record<string, unknown>,
10501
+ options?: AiOptions,
10502
+ ): Promise<Record<string, unknown>>;
10455
10503
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10456
10504
  toMarkdown(): ToMarkdownService;
10457
10505
  toMarkdown(
@@ -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
  }
@@ -10267,6 +10285,10 @@ export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10267
10285
  inputs: ChatCompletionsInput;
10268
10286
  postProcessedOutputs: ChatCompletionsOutput;
10269
10287
  }
10288
+ export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10289
+ inputs: ChatCompletionsInput;
10290
+ postProcessedOutputs: ChatCompletionsOutput;
10291
+ }
10270
10292
  export 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 @@ export type ChatCompletionsInput = XOR<
10422
10444
  export interface InferenceUpstreamError extends Error {}
10423
10445
  export interface AiInternalError extends Error {}
10424
10446
  export type AiModelListType = Record<string, any>;
10447
+ export type AiAsyncBatchResponse = {
10448
+ request_id: string;
10449
+ };
10425
10450
  export declare abstract class Ai<
10426
10451
  AiModelList extends AiModelListType = AiModels,
10427
10452
  > {
@@ -10440,29 +10465,52 @@ export declare abstract class Ai<
10440
10465
  * @param autoragId Instance ID
10441
10466
  */
10442
10467
  autorag(autoragId: string): AutoRAG;
10443
- run<
10444
- Name extends keyof AiModelList,
10445
- Options extends AiOptions,
10446
- InputOptions extends AiModelList[Name]["inputs"],
10447
- >(
10468
+ // Batch request
10469
+ run<Name extends keyof AiModelList>(
10448
10470
  model: Name,
10449
- inputs: InputOptions,
10450
- options?: Options,
10451
- ): Promise<
10452
- Options extends
10453
- | {
10454
- returnRawResponse: true;
10455
- }
10456
- | {
10457
- websocket: true;
10458
- }
10459
- ? Response
10460
- : InputOptions extends {
10461
- stream: true;
10462
- }
10463
- ? ReadableStream
10464
- : AiModelList[Name]["postProcessedOutputs"]
10465
- >;
10471
+ inputs: {
10472
+ requests: AiModelList[Name]["inputs"][];
10473
+ },
10474
+ options: AiOptions & {
10475
+ queueRequest: true;
10476
+ },
10477
+ ): Promise<AiAsyncBatchResponse>;
10478
+ // Raw response
10479
+ run<Name extends keyof AiModelList>(
10480
+ model: Name,
10481
+ inputs: AiModelList[Name]["inputs"],
10482
+ options: AiOptions & {
10483
+ returnRawResponse: true;
10484
+ },
10485
+ ): Promise<Response>;
10486
+ // WebSocket
10487
+ run<Name extends keyof AiModelList>(
10488
+ model: Name,
10489
+ inputs: AiModelList[Name]["inputs"],
10490
+ options: AiOptions & {
10491
+ websocket: true;
10492
+ },
10493
+ ): Promise<Response>;
10494
+ // Streaming
10495
+ run<Name extends keyof AiModelList>(
10496
+ model: Name,
10497
+ inputs: AiModelList[Name]["inputs"] & {
10498
+ stream: true;
10499
+ },
10500
+ options?: AiOptions,
10501
+ ): Promise<ReadableStream>;
10502
+ // Normal (default) - known model
10503
+ run<Name extends keyof AiModelList>(
10504
+ model: Name,
10505
+ inputs: AiModelList[Name]["inputs"],
10506
+ options?: AiOptions,
10507
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10508
+ // Unknown model (gateway fallback)
10509
+ run(
10510
+ model: string & {},
10511
+ inputs: Record<string, unknown>,
10512
+ options?: AiOptions,
10513
+ ): Promise<Record<string, unknown>>;
10466
10514
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10467
10515
  toMarkdown(): ToMarkdownService;
10468
10516
  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
  }
@@ -10266,6 +10284,10 @@ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10266
10284
  inputs: ChatCompletionsInput;
10267
10285
  postProcessedOutputs: ChatCompletionsOutput;
10268
10286
  }
10287
+ declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10288
+ inputs: ChatCompletionsInput;
10289
+ postProcessedOutputs: ChatCompletionsOutput;
10290
+ }
10269
10291
  interface AiModels {
10270
10292
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10271
10293
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10421,6 +10443,9 @@ type ChatCompletionsInput = XOR<
10421
10443
  interface InferenceUpstreamError extends Error {}
10422
10444
  interface AiInternalError extends Error {}
10423
10445
  type AiModelListType = Record<string, any>;
10446
+ type AiAsyncBatchResponse = {
10447
+ request_id: string;
10448
+ };
10424
10449
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10425
10450
  aiGatewayLogId: string | null;
10426
10451
  gateway(gatewayId: string): AiGateway;
@@ -10437,29 +10462,52 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10437
10462
  * @param autoragId Instance ID
10438
10463
  */
10439
10464
  autorag(autoragId: string): AutoRAG;
10440
- run<
10441
- Name extends keyof AiModelList,
10442
- Options extends AiOptions,
10443
- InputOptions extends AiModelList[Name]["inputs"],
10444
- >(
10465
+ // Batch request
10466
+ run<Name extends keyof AiModelList>(
10445
10467
  model: Name,
10446
- inputs: InputOptions,
10447
- options?: Options,
10448
- ): Promise<
10449
- Options extends
10450
- | {
10451
- returnRawResponse: true;
10452
- }
10453
- | {
10454
- websocket: true;
10455
- }
10456
- ? Response
10457
- : InputOptions extends {
10458
- stream: true;
10459
- }
10460
- ? ReadableStream
10461
- : AiModelList[Name]["postProcessedOutputs"]
10462
- >;
10468
+ inputs: {
10469
+ requests: AiModelList[Name]["inputs"][];
10470
+ },
10471
+ options: AiOptions & {
10472
+ queueRequest: true;
10473
+ },
10474
+ ): Promise<AiAsyncBatchResponse>;
10475
+ // Raw response
10476
+ run<Name extends keyof AiModelList>(
10477
+ model: Name,
10478
+ inputs: AiModelList[Name]["inputs"],
10479
+ options: AiOptions & {
10480
+ returnRawResponse: true;
10481
+ },
10482
+ ): Promise<Response>;
10483
+ // WebSocket
10484
+ run<Name extends keyof AiModelList>(
10485
+ model: Name,
10486
+ inputs: AiModelList[Name]["inputs"],
10487
+ options: AiOptions & {
10488
+ websocket: true;
10489
+ },
10490
+ ): Promise<Response>;
10491
+ // Streaming
10492
+ run<Name extends keyof AiModelList>(
10493
+ model: Name,
10494
+ inputs: AiModelList[Name]["inputs"] & {
10495
+ stream: true;
10496
+ },
10497
+ options?: AiOptions,
10498
+ ): Promise<ReadableStream>;
10499
+ // Normal (default) - known model
10500
+ run<Name extends keyof AiModelList>(
10501
+ model: Name,
10502
+ inputs: AiModelList[Name]["inputs"],
10503
+ options?: AiOptions,
10504
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10505
+ // Unknown model (gateway fallback)
10506
+ run(
10507
+ model: string & {},
10508
+ inputs: Record<string, unknown>,
10509
+ options?: AiOptions,
10510
+ ): Promise<Record<string, unknown>>;
10463
10511
  models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10464
10512
  toMarkdown(): ToMarkdownService;
10465
10513
  toMarkdown(