@cloudflare/workers-types 4.20260317.1 → 4.20260331.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.
- package/2021-11-03/index.d.ts +1018 -180
- package/2021-11-03/index.ts +1020 -180
- package/2022-01-31/index.d.ts +1018 -180
- package/2022-01-31/index.ts +1020 -180
- package/2022-03-21/index.d.ts +1018 -180
- package/2022-03-21/index.ts +1020 -180
- package/2022-08-04/index.d.ts +1018 -180
- package/2022-08-04/index.ts +1020 -180
- package/2022-10-31/index.d.ts +1018 -180
- package/2022-10-31/index.ts +1020 -180
- package/2022-11-30/index.d.ts +1018 -180
- package/2022-11-30/index.ts +1020 -180
- package/2023-03-01/index.d.ts +1018 -180
- package/2023-03-01/index.ts +1020 -180
- package/2023-07-01/index.d.ts +1018 -180
- package/2023-07-01/index.ts +1020 -180
- package/experimental/index.d.ts +1089 -181
- package/experimental/index.ts +1091 -181
- package/index.d.ts +1018 -180
- package/index.ts +1020 -180
- package/latest/index.d.ts +1018 -180
- package/latest/index.ts +1020 -180
- package/oldest/index.d.ts +1018 -180
- package/oldest/index.ts +1020 -180
- package/package.json +1 -1
package/2022-11-30/index.d.ts
CHANGED
|
@@ -486,6 +486,11 @@ type ExportedHandlerFetchHandler<
|
|
|
486
486
|
env: Env,
|
|
487
487
|
ctx: ExecutionContext<Props>,
|
|
488
488
|
) => Response | Promise<Response>;
|
|
489
|
+
type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
|
|
490
|
+
socket: Socket,
|
|
491
|
+
env: Env,
|
|
492
|
+
ctx: ExecutionContext<Props>,
|
|
493
|
+
) => void | Promise<void>;
|
|
489
494
|
type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
|
|
490
495
|
events: TraceItem[],
|
|
491
496
|
env: Env,
|
|
@@ -527,6 +532,7 @@ interface ExportedHandler<
|
|
|
527
532
|
Props = unknown,
|
|
528
533
|
> {
|
|
529
534
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
|
|
535
|
+
connect?: ExportedHandlerConnectHandler<Env, Props>;
|
|
530
536
|
tail?: ExportedHandlerTailHandler<Env, Props>;
|
|
531
537
|
trace?: ExportedHandlerTraceHandler<Env, Props>;
|
|
532
538
|
tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
|
|
@@ -546,12 +552,14 @@ declare abstract class Navigator {
|
|
|
546
552
|
interface AlarmInvocationInfo {
|
|
547
553
|
readonly isRetry: boolean;
|
|
548
554
|
readonly retryCount: number;
|
|
555
|
+
readonly scheduledTime: number;
|
|
549
556
|
}
|
|
550
557
|
interface Cloudflare {
|
|
551
558
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
552
559
|
}
|
|
553
560
|
interface DurableObject {
|
|
554
561
|
fetch(request: Request): Response | Promise<Response>;
|
|
562
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
555
563
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
556
564
|
webSocketMessage?(
|
|
557
565
|
ws: WebSocket,
|
|
@@ -569,7 +577,7 @@ type DurableObjectStub<
|
|
|
569
577
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
570
578
|
> = Fetcher<
|
|
571
579
|
T,
|
|
572
|
-
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
580
|
+
"alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
573
581
|
> & {
|
|
574
582
|
readonly id: DurableObjectId;
|
|
575
583
|
readonly name?: string;
|
|
@@ -578,6 +586,7 @@ interface DurableObjectId {
|
|
|
578
586
|
toString(): string;
|
|
579
587
|
equals(other: DurableObjectId): boolean;
|
|
580
588
|
readonly name?: string;
|
|
589
|
+
readonly jurisdiction?: string;
|
|
581
590
|
}
|
|
582
591
|
declare abstract class DurableObjectNamespace<
|
|
583
592
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
@@ -3088,6 +3097,11 @@ interface QueuingStrategyInit {
|
|
|
3088
3097
|
*/
|
|
3089
3098
|
highWaterMark: number;
|
|
3090
3099
|
}
|
|
3100
|
+
interface TracePreviewInfo {
|
|
3101
|
+
id: string;
|
|
3102
|
+
slug: string;
|
|
3103
|
+
name: string;
|
|
3104
|
+
}
|
|
3091
3105
|
interface ScriptVersion {
|
|
3092
3106
|
id?: string;
|
|
3093
3107
|
tag?: string;
|
|
@@ -3102,6 +3116,7 @@ interface TraceItem {
|
|
|
3102
3116
|
| (
|
|
3103
3117
|
| TraceItemFetchEventInfo
|
|
3104
3118
|
| TraceItemJsRpcEventInfo
|
|
3119
|
+
| TraceItemConnectEventInfo
|
|
3105
3120
|
| TraceItemScheduledEventInfo
|
|
3106
3121
|
| TraceItemAlarmEventInfo
|
|
3107
3122
|
| TraceItemQueueEventInfo
|
|
@@ -3120,6 +3135,8 @@ interface TraceItem {
|
|
|
3120
3135
|
readonly scriptVersion?: ScriptVersion;
|
|
3121
3136
|
readonly dispatchNamespace?: string;
|
|
3122
3137
|
readonly scriptTags?: string[];
|
|
3138
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3139
|
+
readonly preview?: TracePreviewInfo;
|
|
3123
3140
|
readonly durableObjectId?: string;
|
|
3124
3141
|
readonly outcome: string;
|
|
3125
3142
|
readonly executionModel: string;
|
|
@@ -3130,6 +3147,7 @@ interface TraceItem {
|
|
|
3130
3147
|
interface TraceItemAlarmEventInfo {
|
|
3131
3148
|
readonly scheduledTime: Date;
|
|
3132
3149
|
}
|
|
3150
|
+
interface TraceItemConnectEventInfo {}
|
|
3133
3151
|
interface TraceItemCustomEventInfo {}
|
|
3134
3152
|
interface TraceItemScheduledEventInfo {
|
|
3135
3153
|
readonly scheduledTime: number;
|
|
@@ -3750,7 +3768,7 @@ interface ContainerStartupOptions {
|
|
|
3750
3768
|
entrypoint?: string[];
|
|
3751
3769
|
enableInternet: boolean;
|
|
3752
3770
|
env?: Record<string, string>;
|
|
3753
|
-
|
|
3771
|
+
labels?: Record<string, string>;
|
|
3754
3772
|
}
|
|
3755
3773
|
/**
|
|
3756
3774
|
* The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
|
|
@@ -3877,11 +3895,10 @@ declare abstract class Performance {
|
|
|
3877
3895
|
*/
|
|
3878
3896
|
toJSON(): object;
|
|
3879
3897
|
}
|
|
3880
|
-
// AI Search
|
|
3898
|
+
// ============ AI Search Error Interfaces ============
|
|
3881
3899
|
interface AiSearchInternalError extends Error {}
|
|
3882
3900
|
interface AiSearchNotFoundError extends Error {}
|
|
3883
|
-
|
|
3884
|
-
// AI Search V2 Request Types
|
|
3901
|
+
// ============ AI Search Request Types ============
|
|
3885
3902
|
type AiSearchSearchRequest = {
|
|
3886
3903
|
messages: Array<{
|
|
3887
3904
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3906,9 +3923,8 @@ type AiSearchSearchRequest = {
|
|
|
3906
3923
|
[key: string]: unknown;
|
|
3907
3924
|
};
|
|
3908
3925
|
reranking?: {
|
|
3909
|
-
/** Enable reranking (default false) */
|
|
3910
3926
|
enabled?: boolean;
|
|
3911
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3927
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3912
3928
|
/** Match threshold (0-1, default 0.4) */
|
|
3913
3929
|
match_threshold?: number;
|
|
3914
3930
|
[key: string]: unknown;
|
|
@@ -3920,6 +3936,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3920
3936
|
messages: Array<{
|
|
3921
3937
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3922
3938
|
content: string | null;
|
|
3939
|
+
[key: string]: unknown;
|
|
3923
3940
|
}>;
|
|
3924
3941
|
model?: string;
|
|
3925
3942
|
stream?: boolean;
|
|
@@ -3940,7 +3957,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3940
3957
|
};
|
|
3941
3958
|
reranking?: {
|
|
3942
3959
|
enabled?: boolean;
|
|
3943
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3960
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3944
3961
|
match_threshold?: number;
|
|
3945
3962
|
[key: string]: unknown;
|
|
3946
3963
|
};
|
|
@@ -3948,7 +3965,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3948
3965
|
};
|
|
3949
3966
|
[key: string]: unknown;
|
|
3950
3967
|
};
|
|
3951
|
-
// AI Search
|
|
3968
|
+
// ============ AI Search Response Types ============
|
|
3952
3969
|
type AiSearchSearchResponse = {
|
|
3953
3970
|
search_query: string;
|
|
3954
3971
|
chunks: Array<{
|
|
@@ -3967,26 +3984,65 @@ type AiSearchSearchResponse = {
|
|
|
3967
3984
|
keyword_score?: number;
|
|
3968
3985
|
/** Vector similarity score (0-1) */
|
|
3969
3986
|
vector_score?: number;
|
|
3987
|
+
[key: string]: unknown;
|
|
3988
|
+
};
|
|
3989
|
+
}>;
|
|
3990
|
+
};
|
|
3991
|
+
type AiSearchChatCompletionsResponse = {
|
|
3992
|
+
id?: string;
|
|
3993
|
+
object?: string;
|
|
3994
|
+
model?: string;
|
|
3995
|
+
choices: Array<{
|
|
3996
|
+
index?: number;
|
|
3997
|
+
message: {
|
|
3998
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3999
|
+
content: string | null;
|
|
4000
|
+
[key: string]: unknown;
|
|
3970
4001
|
};
|
|
4002
|
+
[key: string]: unknown;
|
|
3971
4003
|
}>;
|
|
4004
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4005
|
+
[key: string]: unknown;
|
|
3972
4006
|
};
|
|
3973
|
-
type
|
|
4007
|
+
type AiSearchStatsResponse = {
|
|
4008
|
+
queued?: number;
|
|
4009
|
+
running?: number;
|
|
4010
|
+
completed?: number;
|
|
4011
|
+
error?: number;
|
|
4012
|
+
skipped?: number;
|
|
4013
|
+
outdated?: number;
|
|
4014
|
+
last_activity?: string;
|
|
4015
|
+
};
|
|
4016
|
+
// ============ AI Search Instance Info Types ============
|
|
4017
|
+
type AiSearchInstanceInfo = {
|
|
3974
4018
|
id: string;
|
|
3975
|
-
|
|
3976
|
-
account_id?: string;
|
|
3977
|
-
account_tag?: string;
|
|
3978
|
-
/** Whether the instance is enabled (default true) */
|
|
3979
|
-
enable?: boolean;
|
|
3980
|
-
type?: "r2" | "web-crawler";
|
|
4019
|
+
type?: "r2" | "web-crawler" | string;
|
|
3981
4020
|
source?: string;
|
|
4021
|
+
paused?: boolean;
|
|
4022
|
+
status?: string;
|
|
4023
|
+
namespace?: string;
|
|
4024
|
+
created_at?: string;
|
|
4025
|
+
modified_at?: string;
|
|
3982
4026
|
[key: string]: unknown;
|
|
3983
|
-
}
|
|
4027
|
+
};
|
|
4028
|
+
type AiSearchListResponse = {
|
|
4029
|
+
result: AiSearchInstanceInfo[];
|
|
4030
|
+
result_info?: {
|
|
4031
|
+
count: number;
|
|
4032
|
+
page: number;
|
|
4033
|
+
per_page: number;
|
|
4034
|
+
total_count: number;
|
|
4035
|
+
};
|
|
4036
|
+
};
|
|
4037
|
+
// ============ AI Search Config Types ============
|
|
3984
4038
|
type AiSearchConfig = {
|
|
3985
4039
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3986
4040
|
id: string;
|
|
3987
|
-
type
|
|
3988
|
-
|
|
3989
|
-
|
|
4041
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4042
|
+
type?: "r2" | "web-crawler" | string;
|
|
4043
|
+
/** Source URL (required for web-crawler type). */
|
|
4044
|
+
source?: string;
|
|
4045
|
+
source_params?: unknown;
|
|
3990
4046
|
/** Token ID (UUID format) */
|
|
3991
4047
|
token_id?: string;
|
|
3992
4048
|
ai_gateway_id?: string;
|
|
@@ -3996,54 +4052,307 @@ type AiSearchConfig = {
|
|
|
3996
4052
|
reranking?: boolean;
|
|
3997
4053
|
embedding_model?: string;
|
|
3998
4054
|
ai_search_model?: string;
|
|
4055
|
+
[key: string]: unknown;
|
|
3999
4056
|
};
|
|
4000
|
-
|
|
4057
|
+
// ============ AI Search Item Types ============
|
|
4058
|
+
type AiSearchItemInfo = {
|
|
4001
4059
|
id: string;
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4060
|
+
key: string;
|
|
4061
|
+
status:
|
|
4062
|
+
| "completed"
|
|
4063
|
+
| "error"
|
|
4064
|
+
| "skipped"
|
|
4065
|
+
| "queued"
|
|
4066
|
+
| "processing"
|
|
4067
|
+
| "outdated";
|
|
4068
|
+
metadata?: Record<string, unknown>;
|
|
4005
4069
|
[key: string]: unknown;
|
|
4006
4070
|
};
|
|
4007
|
-
|
|
4008
|
-
|
|
4071
|
+
type AiSearchItemContentResult = {
|
|
4072
|
+
body: ReadableStream;
|
|
4073
|
+
contentType: string;
|
|
4074
|
+
filename: string;
|
|
4075
|
+
size: number;
|
|
4076
|
+
};
|
|
4077
|
+
type AiSearchUploadItemOptions = {
|
|
4078
|
+
metadata?: Record<string, unknown>;
|
|
4079
|
+
};
|
|
4080
|
+
type AiSearchListItemsParams = {
|
|
4081
|
+
page?: number;
|
|
4082
|
+
per_page?: number;
|
|
4083
|
+
};
|
|
4084
|
+
type AiSearchListItemsResponse = {
|
|
4085
|
+
result: AiSearchItemInfo[];
|
|
4086
|
+
result_info?: {
|
|
4087
|
+
count: number;
|
|
4088
|
+
page: number;
|
|
4089
|
+
per_page: number;
|
|
4090
|
+
total_count: number;
|
|
4091
|
+
};
|
|
4092
|
+
};
|
|
4093
|
+
// ============ AI Search Job Types ============
|
|
4094
|
+
type AiSearchJobInfo = {
|
|
4095
|
+
id: string;
|
|
4096
|
+
source: "user" | "schedule";
|
|
4097
|
+
description?: string;
|
|
4098
|
+
last_seen_at?: string;
|
|
4099
|
+
started_at?: string;
|
|
4100
|
+
ended_at?: string;
|
|
4101
|
+
end_reason?: string;
|
|
4102
|
+
};
|
|
4103
|
+
type AiSearchJobLog = {
|
|
4104
|
+
id: number;
|
|
4105
|
+
message: string;
|
|
4106
|
+
message_type: number;
|
|
4107
|
+
created_at: number;
|
|
4108
|
+
};
|
|
4109
|
+
type AiSearchCreateJobParams = {
|
|
4110
|
+
description?: string;
|
|
4111
|
+
};
|
|
4112
|
+
type AiSearchListJobsParams = {
|
|
4113
|
+
page?: number;
|
|
4114
|
+
per_page?: number;
|
|
4115
|
+
};
|
|
4116
|
+
type AiSearchListJobsResponse = {
|
|
4117
|
+
result: AiSearchJobInfo[];
|
|
4118
|
+
result_info?: {
|
|
4119
|
+
count: number;
|
|
4120
|
+
page: number;
|
|
4121
|
+
per_page: number;
|
|
4122
|
+
total_count: number;
|
|
4123
|
+
};
|
|
4124
|
+
};
|
|
4125
|
+
type AiSearchJobLogsParams = {
|
|
4126
|
+
page?: number;
|
|
4127
|
+
per_page?: number;
|
|
4128
|
+
};
|
|
4129
|
+
type AiSearchJobLogsResponse = {
|
|
4130
|
+
result: AiSearchJobLog[];
|
|
4131
|
+
result_info?: {
|
|
4132
|
+
count: number;
|
|
4133
|
+
page: number;
|
|
4134
|
+
per_page: number;
|
|
4135
|
+
total_count: number;
|
|
4136
|
+
};
|
|
4137
|
+
};
|
|
4138
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4139
|
+
/**
|
|
4140
|
+
* Single item service for an AI Search instance.
|
|
4141
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4142
|
+
*/
|
|
4143
|
+
declare abstract class AiSearchItem {
|
|
4144
|
+
/** Get metadata about this item. */
|
|
4145
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4146
|
+
/**
|
|
4147
|
+
* Download the item's content.
|
|
4148
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4149
|
+
*/
|
|
4150
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4151
|
+
}
|
|
4152
|
+
/**
|
|
4153
|
+
* Items collection service for an AI Search instance.
|
|
4154
|
+
* Provides list, upload, and access to individual items.
|
|
4155
|
+
*/
|
|
4156
|
+
declare abstract class AiSearchItems {
|
|
4157
|
+
/** List items in this instance. */
|
|
4158
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4159
|
+
/**
|
|
4160
|
+
* Upload a file as an item.
|
|
4161
|
+
* @param name Filename for the uploaded item.
|
|
4162
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4163
|
+
* @param options Optional metadata to attach to the item.
|
|
4164
|
+
* @returns The created item info.
|
|
4165
|
+
*/
|
|
4166
|
+
upload(
|
|
4167
|
+
name: string,
|
|
4168
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4169
|
+
options?: AiSearchUploadItemOptions,
|
|
4170
|
+
): Promise<AiSearchItemInfo>;
|
|
4171
|
+
/**
|
|
4172
|
+
* Upload a file and poll until processing completes.
|
|
4173
|
+
* @param name Filename for the uploaded item.
|
|
4174
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4175
|
+
* @param options Optional metadata to attach to the item.
|
|
4176
|
+
* @returns The item info after processing completes (or timeout).
|
|
4177
|
+
*/
|
|
4178
|
+
uploadAndPoll(
|
|
4179
|
+
name: string,
|
|
4180
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4181
|
+
options?: AiSearchUploadItemOptions,
|
|
4182
|
+
): Promise<AiSearchItemInfo>;
|
|
4183
|
+
/**
|
|
4184
|
+
* Get an item by ID.
|
|
4185
|
+
* @param itemId The item identifier.
|
|
4186
|
+
* @returns Item service for info, delete, and download operations.
|
|
4187
|
+
*/
|
|
4188
|
+
get(itemId: string): AiSearchItem;
|
|
4189
|
+
/** Delete this item from the instance.
|
|
4190
|
+
* @param itemId The item identifier.
|
|
4191
|
+
*/
|
|
4192
|
+
delete(itemId: string): Promise<void>;
|
|
4193
|
+
}
|
|
4194
|
+
/**
|
|
4195
|
+
* Single job service for an AI Search instance.
|
|
4196
|
+
* Provides info and logs for a specific job.
|
|
4197
|
+
*/
|
|
4198
|
+
declare abstract class AiSearchJob {
|
|
4199
|
+
/** Get metadata about this job. */
|
|
4200
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4201
|
+
/** Get logs for this job. */
|
|
4202
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4203
|
+
}
|
|
4204
|
+
/**
|
|
4205
|
+
* Jobs collection service for an AI Search instance.
|
|
4206
|
+
* Provides list, create, and access to individual jobs.
|
|
4207
|
+
*/
|
|
4208
|
+
declare abstract class AiSearchJobs {
|
|
4209
|
+
/** List jobs for this instance. */
|
|
4210
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4211
|
+
/**
|
|
4212
|
+
* Create a new indexing job.
|
|
4213
|
+
* @param params Optional job parameters.
|
|
4214
|
+
* @returns The created job info.
|
|
4215
|
+
*/
|
|
4216
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4217
|
+
/**
|
|
4218
|
+
* Get a job by ID.
|
|
4219
|
+
* @param jobId The job identifier.
|
|
4220
|
+
* @returns Job service for info and logs operations.
|
|
4221
|
+
*/
|
|
4222
|
+
get(jobId: string): AiSearchJob;
|
|
4223
|
+
}
|
|
4224
|
+
// ============ AI Search Binding Classes ============
|
|
4225
|
+
/**
|
|
4226
|
+
* Instance-level AI Search service.
|
|
4227
|
+
*
|
|
4228
|
+
* Used as:
|
|
4229
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4230
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4231
|
+
*
|
|
4232
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4233
|
+
*
|
|
4234
|
+
* @example
|
|
4235
|
+
* ```ts
|
|
4236
|
+
* // Via namespace binding
|
|
4237
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4238
|
+
* const results = await instance.search({
|
|
4239
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4240
|
+
* });
|
|
4241
|
+
*
|
|
4242
|
+
* // Via single instance binding
|
|
4243
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4244
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4245
|
+
* });
|
|
4246
|
+
* ```
|
|
4247
|
+
*/
|
|
4248
|
+
declare abstract class AiSearchInstance {
|
|
4009
4249
|
/**
|
|
4010
4250
|
* Search the AI Search instance for relevant chunks.
|
|
4011
|
-
* @param params Search request with messages and AI search options
|
|
4012
|
-
* @returns Search response with matching chunks
|
|
4251
|
+
* @param params Search request with messages and optional AI search options.
|
|
4252
|
+
* @returns Search response with matching chunks and search query.
|
|
4013
4253
|
*/
|
|
4014
4254
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4255
|
+
/**
|
|
4256
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4257
|
+
* @param params Chat completions request with stream: true.
|
|
4258
|
+
* @returns ReadableStream of server-sent events.
|
|
4259
|
+
*/
|
|
4260
|
+
chatCompletions(
|
|
4261
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4262
|
+
stream: true;
|
|
4263
|
+
},
|
|
4264
|
+
): Promise<ReadableStream>;
|
|
4015
4265
|
/**
|
|
4016
4266
|
* Generate chat completions with AI Search context.
|
|
4017
|
-
* @param params Chat completions request
|
|
4018
|
-
* @returns
|
|
4267
|
+
* @param params Chat completions request.
|
|
4268
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4019
4269
|
*/
|
|
4020
4270
|
chatCompletions(
|
|
4021
4271
|
params: AiSearchChatCompletionsRequest,
|
|
4022
|
-
): Promise<
|
|
4272
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4023
4273
|
/**
|
|
4024
|
-
*
|
|
4274
|
+
* Update the instance configuration.
|
|
4275
|
+
* @param config Partial configuration to update.
|
|
4276
|
+
* @returns Updated instance info.
|
|
4025
4277
|
*/
|
|
4026
|
-
|
|
4278
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4279
|
+
/** Get metadata about this instance. */
|
|
4280
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4281
|
+
/**
|
|
4282
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4283
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4284
|
+
*/
|
|
4285
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4286
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4287
|
+
get items(): AiSearchItems;
|
|
4288
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4289
|
+
get jobs(): AiSearchJobs;
|
|
4027
4290
|
}
|
|
4028
|
-
|
|
4029
|
-
|
|
4291
|
+
/**
|
|
4292
|
+
* Namespace-level AI Search service.
|
|
4293
|
+
*
|
|
4294
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4295
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4296
|
+
*
|
|
4297
|
+
* @example
|
|
4298
|
+
* ```ts
|
|
4299
|
+
* // Access an instance within the namespace
|
|
4300
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4301
|
+
* const results = await blog.search({
|
|
4302
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4303
|
+
* });
|
|
4304
|
+
*
|
|
4305
|
+
* // List all instances in the namespace
|
|
4306
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4307
|
+
*
|
|
4308
|
+
* // Create a new instance with built-in storage
|
|
4309
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4310
|
+
* id: "tenant-123",
|
|
4311
|
+
* });
|
|
4312
|
+
*
|
|
4313
|
+
* // Upload items into the instance
|
|
4314
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4315
|
+
*
|
|
4316
|
+
* // Delete an instance
|
|
4317
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4318
|
+
* ```
|
|
4319
|
+
*/
|
|
4320
|
+
declare abstract class AiSearchNamespace {
|
|
4030
4321
|
/**
|
|
4031
|
-
*
|
|
4032
|
-
* @
|
|
4322
|
+
* Get an instance by name within the bound namespace.
|
|
4323
|
+
* @param name Instance name.
|
|
4324
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4325
|
+
*/
|
|
4326
|
+
get(name: string): AiSearchInstance;
|
|
4327
|
+
/**
|
|
4328
|
+
* List all instances in the bound namespace.
|
|
4329
|
+
* @returns Array of instance metadata.
|
|
4033
4330
|
*/
|
|
4034
4331
|
list(): Promise<AiSearchListResponse>;
|
|
4035
4332
|
/**
|
|
4036
|
-
*
|
|
4037
|
-
* @param
|
|
4038
|
-
* @returns Instance service for
|
|
4333
|
+
* Create a new instance within the bound namespace.
|
|
4334
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4335
|
+
* @returns Instance service for the newly created instance.
|
|
4336
|
+
*
|
|
4337
|
+
* @example
|
|
4338
|
+
* ```ts
|
|
4339
|
+
* // Create with built-in storage (upload items manually)
|
|
4340
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4341
|
+
*
|
|
4342
|
+
* // Create with web crawler source
|
|
4343
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4344
|
+
* id: "docs-search",
|
|
4345
|
+
* type: "web-crawler",
|
|
4346
|
+
* source: "https://developers.cloudflare.com",
|
|
4347
|
+
* });
|
|
4348
|
+
* ```
|
|
4039
4349
|
*/
|
|
4040
|
-
|
|
4350
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4041
4351
|
/**
|
|
4042
|
-
*
|
|
4043
|
-
* @param
|
|
4044
|
-
* @returns Instance service for performing operations
|
|
4352
|
+
* Delete an instance from the bound namespace.
|
|
4353
|
+
* @param name Instance name to delete.
|
|
4045
4354
|
*/
|
|
4046
|
-
|
|
4355
|
+
delete(name: string): Promise<void>;
|
|
4047
4356
|
}
|
|
4048
4357
|
type AiImageClassificationInput = {
|
|
4049
4358
|
image: number[];
|
|
@@ -4319,6 +4628,400 @@ declare abstract class BaseAiTranslation {
|
|
|
4319
4628
|
inputs: AiTranslationInput;
|
|
4320
4629
|
postProcessedOutputs: AiTranslationOutput;
|
|
4321
4630
|
}
|
|
4631
|
+
/**
|
|
4632
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4633
|
+
*/
|
|
4634
|
+
type ChatCompletionContentPartText = {
|
|
4635
|
+
type: "text";
|
|
4636
|
+
text: string;
|
|
4637
|
+
};
|
|
4638
|
+
type ChatCompletionContentPartImage = {
|
|
4639
|
+
type: "image_url";
|
|
4640
|
+
image_url: {
|
|
4641
|
+
url: string;
|
|
4642
|
+
detail?: "auto" | "low" | "high";
|
|
4643
|
+
};
|
|
4644
|
+
};
|
|
4645
|
+
type ChatCompletionContentPartInputAudio = {
|
|
4646
|
+
type: "input_audio";
|
|
4647
|
+
input_audio: {
|
|
4648
|
+
/** Base64 encoded audio data. */
|
|
4649
|
+
data: string;
|
|
4650
|
+
format: "wav" | "mp3";
|
|
4651
|
+
};
|
|
4652
|
+
};
|
|
4653
|
+
type ChatCompletionContentPartFile = {
|
|
4654
|
+
type: "file";
|
|
4655
|
+
file: {
|
|
4656
|
+
/** Base64 encoded file data. */
|
|
4657
|
+
file_data?: string;
|
|
4658
|
+
/** The ID of an uploaded file. */
|
|
4659
|
+
file_id?: string;
|
|
4660
|
+
filename?: string;
|
|
4661
|
+
};
|
|
4662
|
+
};
|
|
4663
|
+
type ChatCompletionContentPartRefusal = {
|
|
4664
|
+
type: "refusal";
|
|
4665
|
+
refusal: string;
|
|
4666
|
+
};
|
|
4667
|
+
type ChatCompletionContentPart =
|
|
4668
|
+
| ChatCompletionContentPartText
|
|
4669
|
+
| ChatCompletionContentPartImage
|
|
4670
|
+
| ChatCompletionContentPartInputAudio
|
|
4671
|
+
| ChatCompletionContentPartFile;
|
|
4672
|
+
type FunctionDefinition = {
|
|
4673
|
+
name: string;
|
|
4674
|
+
description?: string;
|
|
4675
|
+
parameters?: Record<string, unknown>;
|
|
4676
|
+
strict?: boolean | null;
|
|
4677
|
+
};
|
|
4678
|
+
type ChatCompletionFunctionTool = {
|
|
4679
|
+
type: "function";
|
|
4680
|
+
function: FunctionDefinition;
|
|
4681
|
+
};
|
|
4682
|
+
type ChatCompletionCustomToolGrammarFormat = {
|
|
4683
|
+
type: "grammar";
|
|
4684
|
+
grammar: {
|
|
4685
|
+
definition: string;
|
|
4686
|
+
syntax: "lark" | "regex";
|
|
4687
|
+
};
|
|
4688
|
+
};
|
|
4689
|
+
type ChatCompletionCustomToolTextFormat = {
|
|
4690
|
+
type: "text";
|
|
4691
|
+
};
|
|
4692
|
+
type ChatCompletionCustomToolFormat =
|
|
4693
|
+
| ChatCompletionCustomToolTextFormat
|
|
4694
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4695
|
+
type ChatCompletionCustomTool = {
|
|
4696
|
+
type: "custom";
|
|
4697
|
+
custom: {
|
|
4698
|
+
name: string;
|
|
4699
|
+
description?: string;
|
|
4700
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4701
|
+
};
|
|
4702
|
+
};
|
|
4703
|
+
type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
|
|
4704
|
+
type ChatCompletionMessageFunctionToolCall = {
|
|
4705
|
+
id: string;
|
|
4706
|
+
type: "function";
|
|
4707
|
+
function: {
|
|
4708
|
+
name: string;
|
|
4709
|
+
/** JSON-encoded arguments string. */
|
|
4710
|
+
arguments: string;
|
|
4711
|
+
};
|
|
4712
|
+
};
|
|
4713
|
+
type ChatCompletionMessageCustomToolCall = {
|
|
4714
|
+
id: string;
|
|
4715
|
+
type: "custom";
|
|
4716
|
+
custom: {
|
|
4717
|
+
name: string;
|
|
4718
|
+
input: string;
|
|
4719
|
+
};
|
|
4720
|
+
};
|
|
4721
|
+
type ChatCompletionMessageToolCall =
|
|
4722
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4723
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4724
|
+
type ChatCompletionToolChoiceFunction = {
|
|
4725
|
+
type: "function";
|
|
4726
|
+
function: {
|
|
4727
|
+
name: string;
|
|
4728
|
+
};
|
|
4729
|
+
};
|
|
4730
|
+
type ChatCompletionToolChoiceCustom = {
|
|
4731
|
+
type: "custom";
|
|
4732
|
+
custom: {
|
|
4733
|
+
name: string;
|
|
4734
|
+
};
|
|
4735
|
+
};
|
|
4736
|
+
type ChatCompletionToolChoiceAllowedTools = {
|
|
4737
|
+
type: "allowed_tools";
|
|
4738
|
+
allowed_tools: {
|
|
4739
|
+
mode: "auto" | "required";
|
|
4740
|
+
tools: Array<Record<string, unknown>>;
|
|
4741
|
+
};
|
|
4742
|
+
};
|
|
4743
|
+
type ChatCompletionToolChoiceOption =
|
|
4744
|
+
| "none"
|
|
4745
|
+
| "auto"
|
|
4746
|
+
| "required"
|
|
4747
|
+
| ChatCompletionToolChoiceFunction
|
|
4748
|
+
| ChatCompletionToolChoiceCustom
|
|
4749
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4750
|
+
type DeveloperMessage = {
|
|
4751
|
+
role: "developer";
|
|
4752
|
+
content:
|
|
4753
|
+
| string
|
|
4754
|
+
| Array<{
|
|
4755
|
+
type: "text";
|
|
4756
|
+
text: string;
|
|
4757
|
+
}>;
|
|
4758
|
+
name?: string;
|
|
4759
|
+
};
|
|
4760
|
+
type SystemMessage = {
|
|
4761
|
+
role: "system";
|
|
4762
|
+
content:
|
|
4763
|
+
| string
|
|
4764
|
+
| Array<{
|
|
4765
|
+
type: "text";
|
|
4766
|
+
text: string;
|
|
4767
|
+
}>;
|
|
4768
|
+
name?: string;
|
|
4769
|
+
};
|
|
4770
|
+
/**
|
|
4771
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4772
|
+
*
|
|
4773
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4774
|
+
* inside nested array items does not correctly match different branches for
|
|
4775
|
+
* different array elements, so the schema uses a single merged object.
|
|
4776
|
+
*/
|
|
4777
|
+
type UserMessageContentPart = {
|
|
4778
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4779
|
+
text?: string;
|
|
4780
|
+
image_url?: {
|
|
4781
|
+
url?: string;
|
|
4782
|
+
detail?: "auto" | "low" | "high";
|
|
4783
|
+
};
|
|
4784
|
+
input_audio?: {
|
|
4785
|
+
data?: string;
|
|
4786
|
+
format?: "wav" | "mp3";
|
|
4787
|
+
};
|
|
4788
|
+
file?: {
|
|
4789
|
+
file_data?: string;
|
|
4790
|
+
file_id?: string;
|
|
4791
|
+
filename?: string;
|
|
4792
|
+
};
|
|
4793
|
+
};
|
|
4794
|
+
type UserMessage = {
|
|
4795
|
+
role: "user";
|
|
4796
|
+
content: string | Array<UserMessageContentPart>;
|
|
4797
|
+
name?: string;
|
|
4798
|
+
};
|
|
4799
|
+
type AssistantMessageContentPart = {
|
|
4800
|
+
type: "text" | "refusal";
|
|
4801
|
+
text?: string;
|
|
4802
|
+
refusal?: string;
|
|
4803
|
+
};
|
|
4804
|
+
type AssistantMessage = {
|
|
4805
|
+
role: "assistant";
|
|
4806
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4807
|
+
refusal?: string | null;
|
|
4808
|
+
name?: string;
|
|
4809
|
+
audio?: {
|
|
4810
|
+
id: string;
|
|
4811
|
+
};
|
|
4812
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4813
|
+
function_call?: {
|
|
4814
|
+
name: string;
|
|
4815
|
+
arguments: string;
|
|
4816
|
+
};
|
|
4817
|
+
};
|
|
4818
|
+
type ToolMessage = {
|
|
4819
|
+
role: "tool";
|
|
4820
|
+
content:
|
|
4821
|
+
| string
|
|
4822
|
+
| Array<{
|
|
4823
|
+
type: "text";
|
|
4824
|
+
text: string;
|
|
4825
|
+
}>;
|
|
4826
|
+
tool_call_id: string;
|
|
4827
|
+
};
|
|
4828
|
+
type FunctionMessage = {
|
|
4829
|
+
role: "function";
|
|
4830
|
+
content: string;
|
|
4831
|
+
name: string;
|
|
4832
|
+
};
|
|
4833
|
+
type ChatCompletionMessageParam =
|
|
4834
|
+
| DeveloperMessage
|
|
4835
|
+
| SystemMessage
|
|
4836
|
+
| UserMessage
|
|
4837
|
+
| AssistantMessage
|
|
4838
|
+
| ToolMessage
|
|
4839
|
+
| FunctionMessage;
|
|
4840
|
+
type ChatCompletionsResponseFormatText = {
|
|
4841
|
+
type: "text";
|
|
4842
|
+
};
|
|
4843
|
+
type ChatCompletionsResponseFormatJSONObject = {
|
|
4844
|
+
type: "json_object";
|
|
4845
|
+
};
|
|
4846
|
+
type ResponseFormatJSONSchema = {
|
|
4847
|
+
type: "json_schema";
|
|
4848
|
+
json_schema: {
|
|
4849
|
+
name: string;
|
|
4850
|
+
description?: string;
|
|
4851
|
+
schema?: Record<string, unknown>;
|
|
4852
|
+
strict?: boolean | null;
|
|
4853
|
+
};
|
|
4854
|
+
};
|
|
4855
|
+
type ResponseFormat =
|
|
4856
|
+
| ChatCompletionsResponseFormatText
|
|
4857
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4858
|
+
| ResponseFormatJSONSchema;
|
|
4859
|
+
type ChatCompletionsStreamOptions = {
|
|
4860
|
+
include_usage?: boolean;
|
|
4861
|
+
include_obfuscation?: boolean;
|
|
4862
|
+
};
|
|
4863
|
+
type PredictionContent = {
|
|
4864
|
+
type: "content";
|
|
4865
|
+
content:
|
|
4866
|
+
| string
|
|
4867
|
+
| Array<{
|
|
4868
|
+
type: "text";
|
|
4869
|
+
text: string;
|
|
4870
|
+
}>;
|
|
4871
|
+
};
|
|
4872
|
+
type AudioParams = {
|
|
4873
|
+
voice:
|
|
4874
|
+
| string
|
|
4875
|
+
| {
|
|
4876
|
+
id: string;
|
|
4877
|
+
};
|
|
4878
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4879
|
+
};
|
|
4880
|
+
type WebSearchUserLocation = {
|
|
4881
|
+
type: "approximate";
|
|
4882
|
+
approximate: {
|
|
4883
|
+
city?: string;
|
|
4884
|
+
country?: string;
|
|
4885
|
+
region?: string;
|
|
4886
|
+
timezone?: string;
|
|
4887
|
+
};
|
|
4888
|
+
};
|
|
4889
|
+
type WebSearchOptions = {
|
|
4890
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4891
|
+
user_location?: WebSearchUserLocation;
|
|
4892
|
+
};
|
|
4893
|
+
type ChatTemplateKwargs = {
|
|
4894
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4895
|
+
enable_thinking?: boolean;
|
|
4896
|
+
/** If false, preserves reasoning context between turns. */
|
|
4897
|
+
clear_thinking?: boolean;
|
|
4898
|
+
};
|
|
4899
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4900
|
+
type ChatCompletionsCommonOptions = {
|
|
4901
|
+
model?: string;
|
|
4902
|
+
audio?: AudioParams;
|
|
4903
|
+
frequency_penalty?: number | null;
|
|
4904
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4905
|
+
logprobs?: boolean | null;
|
|
4906
|
+
top_logprobs?: number | null;
|
|
4907
|
+
max_tokens?: number | null;
|
|
4908
|
+
max_completion_tokens?: number | null;
|
|
4909
|
+
metadata?: Record<string, unknown> | null;
|
|
4910
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4911
|
+
n?: number | null;
|
|
4912
|
+
parallel_tool_calls?: boolean;
|
|
4913
|
+
prediction?: PredictionContent;
|
|
4914
|
+
presence_penalty?: number | null;
|
|
4915
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4916
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4917
|
+
response_format?: ResponseFormat;
|
|
4918
|
+
seed?: number | null;
|
|
4919
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4920
|
+
stop?: string | Array<string> | null;
|
|
4921
|
+
store?: boolean | null;
|
|
4922
|
+
stream?: boolean | null;
|
|
4923
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4924
|
+
temperature?: number | null;
|
|
4925
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4926
|
+
tools?: Array<ChatCompletionTool>;
|
|
4927
|
+
top_p?: number | null;
|
|
4928
|
+
user?: string;
|
|
4929
|
+
web_search_options?: WebSearchOptions;
|
|
4930
|
+
function_call?:
|
|
4931
|
+
| "none"
|
|
4932
|
+
| "auto"
|
|
4933
|
+
| {
|
|
4934
|
+
name: string;
|
|
4935
|
+
};
|
|
4936
|
+
functions?: Array<FunctionDefinition>;
|
|
4937
|
+
};
|
|
4938
|
+
type PromptTokensDetails = {
|
|
4939
|
+
cached_tokens?: number;
|
|
4940
|
+
audio_tokens?: number;
|
|
4941
|
+
};
|
|
4942
|
+
type CompletionTokensDetails = {
|
|
4943
|
+
reasoning_tokens?: number;
|
|
4944
|
+
audio_tokens?: number;
|
|
4945
|
+
accepted_prediction_tokens?: number;
|
|
4946
|
+
rejected_prediction_tokens?: number;
|
|
4947
|
+
};
|
|
4948
|
+
type CompletionUsage = {
|
|
4949
|
+
prompt_tokens: number;
|
|
4950
|
+
completion_tokens: number;
|
|
4951
|
+
total_tokens: number;
|
|
4952
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4953
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4954
|
+
};
|
|
4955
|
+
type ChatCompletionTopLogprob = {
|
|
4956
|
+
token: string;
|
|
4957
|
+
logprob: number;
|
|
4958
|
+
bytes: Array<number> | null;
|
|
4959
|
+
};
|
|
4960
|
+
type ChatCompletionTokenLogprob = {
|
|
4961
|
+
token: string;
|
|
4962
|
+
logprob: number;
|
|
4963
|
+
bytes: Array<number> | null;
|
|
4964
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4965
|
+
};
|
|
4966
|
+
type ChatCompletionAudio = {
|
|
4967
|
+
id: string;
|
|
4968
|
+
/** Base64 encoded audio bytes. */
|
|
4969
|
+
data: string;
|
|
4970
|
+
expires_at: number;
|
|
4971
|
+
transcript: string;
|
|
4972
|
+
};
|
|
4973
|
+
type ChatCompletionUrlCitation = {
|
|
4974
|
+
type: "url_citation";
|
|
4975
|
+
url_citation: {
|
|
4976
|
+
url: string;
|
|
4977
|
+
title: string;
|
|
4978
|
+
start_index: number;
|
|
4979
|
+
end_index: number;
|
|
4980
|
+
};
|
|
4981
|
+
};
|
|
4982
|
+
type ChatCompletionResponseMessage = {
|
|
4983
|
+
role: "assistant";
|
|
4984
|
+
content: string | null;
|
|
4985
|
+
refusal: string | null;
|
|
4986
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
4987
|
+
audio?: ChatCompletionAudio;
|
|
4988
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4989
|
+
function_call?: {
|
|
4990
|
+
name: string;
|
|
4991
|
+
arguments: string;
|
|
4992
|
+
} | null;
|
|
4993
|
+
};
|
|
4994
|
+
type ChatCompletionLogprobs = {
|
|
4995
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
4996
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
4997
|
+
};
|
|
4998
|
+
type ChatCompletionChoice = {
|
|
4999
|
+
index: number;
|
|
5000
|
+
message: ChatCompletionResponseMessage;
|
|
5001
|
+
finish_reason:
|
|
5002
|
+
| "stop"
|
|
5003
|
+
| "length"
|
|
5004
|
+
| "tool_calls"
|
|
5005
|
+
| "content_filter"
|
|
5006
|
+
| "function_call";
|
|
5007
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
5008
|
+
};
|
|
5009
|
+
type ChatCompletionsPromptInput = {
|
|
5010
|
+
prompt: string;
|
|
5011
|
+
} & ChatCompletionsCommonOptions;
|
|
5012
|
+
type ChatCompletionsMessagesInput = {
|
|
5013
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
5014
|
+
} & ChatCompletionsCommonOptions;
|
|
5015
|
+
type ChatCompletionsOutput = {
|
|
5016
|
+
id: string;
|
|
5017
|
+
object: string;
|
|
5018
|
+
created: number;
|
|
5019
|
+
model: string;
|
|
5020
|
+
choices: Array<ChatCompletionChoice>;
|
|
5021
|
+
usage?: CompletionUsage;
|
|
5022
|
+
system_fingerprint?: string | null;
|
|
5023
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
5024
|
+
};
|
|
4322
5025
|
/**
|
|
4323
5026
|
* Workers AI support for OpenAI's Responses API
|
|
4324
5027
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4740,6 +5443,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4740
5443
|
type StreamOptions = {
|
|
4741
5444
|
include_obfuscation?: boolean;
|
|
4742
5445
|
};
|
|
5446
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5447
|
+
type Without<T, U> = {
|
|
5448
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5449
|
+
};
|
|
5450
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5451
|
+
type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4743
5452
|
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4744
5453
|
| {
|
|
4745
5454
|
text: string | string[];
|
|
@@ -5032,10 +5741,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5032
5741
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5033
5742
|
}
|
|
5034
5743
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5744
|
+
audio:
|
|
5745
|
+
| string
|
|
5746
|
+
| {
|
|
5747
|
+
body?: object;
|
|
5748
|
+
contentType?: string;
|
|
5749
|
+
};
|
|
5039
5750
|
/**
|
|
5040
5751
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5041
5752
|
*/
|
|
@@ -5053,9 +5764,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5053
5764
|
*/
|
|
5054
5765
|
initial_prompt?: string;
|
|
5055
5766
|
/**
|
|
5056
|
-
* The prefix
|
|
5767
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5057
5768
|
*/
|
|
5058
5769
|
prefix?: string;
|
|
5770
|
+
/**
|
|
5771
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5772
|
+
*/
|
|
5773
|
+
beam_size?: number;
|
|
5774
|
+
/**
|
|
5775
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5776
|
+
*/
|
|
5777
|
+
condition_on_previous_text?: boolean;
|
|
5778
|
+
/**
|
|
5779
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5780
|
+
*/
|
|
5781
|
+
no_speech_threshold?: number;
|
|
5782
|
+
/**
|
|
5783
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5784
|
+
*/
|
|
5785
|
+
compression_ratio_threshold?: number;
|
|
5786
|
+
/**
|
|
5787
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5788
|
+
*/
|
|
5789
|
+
log_prob_threshold?: number;
|
|
5790
|
+
/**
|
|
5791
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5792
|
+
*/
|
|
5793
|
+
hallucination_silence_threshold?: number;
|
|
5059
5794
|
}
|
|
5060
5795
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5061
5796
|
transcription_info?: {
|
|
@@ -5202,11 +5937,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5202
5937
|
truncate_inputs?: boolean;
|
|
5203
5938
|
}
|
|
5204
5939
|
type Ai_Cf_Baai_Bge_M3_Output =
|
|
5205
|
-
|
|
|
5940
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5206
5941
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5207
|
-
|
|
|
5942
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5208
5943
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5209
|
-
interface
|
|
5944
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5210
5945
|
response?: {
|
|
5211
5946
|
/**
|
|
5212
5947
|
* Index of the context in the request
|
|
@@ -5226,7 +5961,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5226
5961
|
*/
|
|
5227
5962
|
pooling?: "mean" | "cls";
|
|
5228
5963
|
}
|
|
5229
|
-
interface
|
|
5964
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5230
5965
|
shape?: number[];
|
|
5231
5966
|
/**
|
|
5232
5967
|
* Embeddings of the requested text values
|
|
@@ -5331,7 +6066,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5331
6066
|
*/
|
|
5332
6067
|
role?: string;
|
|
5333
6068
|
/**
|
|
5334
|
-
* The tool call id.
|
|
6069
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5335
6070
|
*/
|
|
5336
6071
|
tool_call_id?: string;
|
|
5337
6072
|
content?:
|
|
@@ -5586,10 +6321,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5586
6321
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5587
6322
|
*/
|
|
5588
6323
|
role: string;
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
6324
|
+
content:
|
|
6325
|
+
| string
|
|
6326
|
+
| {
|
|
6327
|
+
/**
|
|
6328
|
+
* Type of the content (text)
|
|
6329
|
+
*/
|
|
6330
|
+
type?: string;
|
|
6331
|
+
/**
|
|
6332
|
+
* Text content
|
|
6333
|
+
*/
|
|
6334
|
+
text?: string;
|
|
6335
|
+
}[];
|
|
5593
6336
|
}[];
|
|
5594
6337
|
functions?: {
|
|
5595
6338
|
name: string;
|
|
@@ -6245,7 +6988,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6245
6988
|
*/
|
|
6246
6989
|
role?: string;
|
|
6247
6990
|
/**
|
|
6248
|
-
* The tool call id.
|
|
6991
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6249
6992
|
*/
|
|
6250
6993
|
tool_call_id?: string;
|
|
6251
6994
|
content?:
|
|
@@ -6372,7 +7115,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6372
7115
|
}
|
|
6373
7116
|
)[];
|
|
6374
7117
|
/**
|
|
6375
|
-
* JSON schema that should be
|
|
7118
|
+
* JSON schema that should be fufilled for the response.
|
|
6376
7119
|
*/
|
|
6377
7120
|
guided_json?: object;
|
|
6378
7121
|
/**
|
|
@@ -6646,7 +7389,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6646
7389
|
}
|
|
6647
7390
|
)[];
|
|
6648
7391
|
/**
|
|
6649
|
-
* JSON schema that should be
|
|
7392
|
+
* JSON schema that should be fufilled for the response.
|
|
6650
7393
|
*/
|
|
6651
7394
|
guided_json?: object;
|
|
6652
7395
|
/**
|
|
@@ -6739,7 +7482,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6739
7482
|
*/
|
|
6740
7483
|
prompt: string;
|
|
6741
7484
|
/**
|
|
6742
|
-
* JSON schema that should be
|
|
7485
|
+
* JSON schema that should be fufilled for the response.
|
|
6743
7486
|
*/
|
|
6744
7487
|
guided_json?: object;
|
|
6745
7488
|
/**
|
|
@@ -6903,7 +7646,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6903
7646
|
}
|
|
6904
7647
|
)[];
|
|
6905
7648
|
/**
|
|
6906
|
-
* JSON schema that should be
|
|
7649
|
+
* JSON schema that should be fufilled for the response.
|
|
6907
7650
|
*/
|
|
6908
7651
|
guided_json?: object;
|
|
6909
7652
|
/**
|
|
@@ -7184,7 +7927,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7184
7927
|
)[];
|
|
7185
7928
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7186
7929
|
/**
|
|
7187
|
-
* JSON schema that should be
|
|
7930
|
+
* JSON schema that should be fufilled for the response.
|
|
7188
7931
|
*/
|
|
7189
7932
|
guided_json?: object;
|
|
7190
7933
|
/**
|
|
@@ -7423,7 +8166,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7423
8166
|
)[];
|
|
7424
8167
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7425
8168
|
/**
|
|
7426
|
-
* JSON schema that should be
|
|
8169
|
+
* JSON schema that should be fufilled for the response.
|
|
7427
8170
|
*/
|
|
7428
8171
|
guided_json?: object;
|
|
7429
8172
|
/**
|
|
@@ -7588,10 +8331,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7588
8331
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7589
8332
|
*/
|
|
7590
8333
|
role: string;
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
8334
|
+
content:
|
|
8335
|
+
| string
|
|
8336
|
+
| {
|
|
8337
|
+
/**
|
|
8338
|
+
* Type of the content (text)
|
|
8339
|
+
*/
|
|
8340
|
+
type?: string;
|
|
8341
|
+
/**
|
|
8342
|
+
* Text content
|
|
8343
|
+
*/
|
|
8344
|
+
text?: string;
|
|
8345
|
+
}[];
|
|
7595
8346
|
}[];
|
|
7596
8347
|
functions?: {
|
|
7597
8348
|
name: string;
|
|
@@ -7803,10 +8554,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7803
8554
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7804
8555
|
*/
|
|
7805
8556
|
role: string;
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
8557
|
+
content:
|
|
8558
|
+
| string
|
|
8559
|
+
| {
|
|
8560
|
+
/**
|
|
8561
|
+
* Type of the content (text)
|
|
8562
|
+
*/
|
|
8563
|
+
type?: string;
|
|
8564
|
+
/**
|
|
8565
|
+
* Text content
|
|
8566
|
+
*/
|
|
8567
|
+
text?: string;
|
|
8568
|
+
}[];
|
|
7810
8569
|
}[];
|
|
7811
8570
|
functions?: {
|
|
7812
8571
|
name: string;
|
|
@@ -8374,12 +9133,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8374
9133
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8375
9134
|
}
|
|
8376
9135
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8377
|
-
inputs: ResponsesInput
|
|
8378
|
-
postProcessedOutputs: ResponsesOutput
|
|
9136
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9137
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8379
9138
|
}
|
|
8380
9139
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8381
|
-
inputs: ResponsesInput
|
|
8382
|
-
postProcessedOutputs: ResponsesOutput
|
|
9140
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9141
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8383
9142
|
}
|
|
8384
9143
|
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8385
9144
|
/**
|
|
@@ -8511,7 +9270,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8511
9270
|
*/
|
|
8512
9271
|
text: string | string[];
|
|
8513
9272
|
/**
|
|
8514
|
-
* Target
|
|
9273
|
+
* Target langauge to translate to
|
|
8515
9274
|
*/
|
|
8516
9275
|
target_language:
|
|
8517
9276
|
| "asm_Beng"
|
|
@@ -8627,10 +9386,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8627
9386
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8628
9387
|
*/
|
|
8629
9388
|
role: string;
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
9389
|
+
content:
|
|
9390
|
+
| string
|
|
9391
|
+
| {
|
|
9392
|
+
/**
|
|
9393
|
+
* Type of the content (text)
|
|
9394
|
+
*/
|
|
9395
|
+
type?: string;
|
|
9396
|
+
/**
|
|
9397
|
+
* Text content
|
|
9398
|
+
*/
|
|
9399
|
+
text?: string;
|
|
9400
|
+
}[];
|
|
8634
9401
|
}[];
|
|
8635
9402
|
functions?: {
|
|
8636
9403
|
name: string;
|
|
@@ -8842,10 +9609,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8842
9609
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8843
9610
|
*/
|
|
8844
9611
|
role: string;
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
9612
|
+
content:
|
|
9613
|
+
| string
|
|
9614
|
+
| {
|
|
9615
|
+
/**
|
|
9616
|
+
* Type of the content (text)
|
|
9617
|
+
*/
|
|
9618
|
+
type?: string;
|
|
9619
|
+
/**
|
|
9620
|
+
* Text content
|
|
9621
|
+
*/
|
|
9622
|
+
text?: string;
|
|
9623
|
+
}[];
|
|
8849
9624
|
}[];
|
|
8850
9625
|
functions?: {
|
|
8851
9626
|
name: string;
|
|
@@ -9400,6 +10175,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9400
10175
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9401
10176
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9402
10177
|
}
|
|
10178
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10179
|
+
multipart: {
|
|
10180
|
+
body?: object;
|
|
10181
|
+
contentType?: string;
|
|
10182
|
+
};
|
|
10183
|
+
}
|
|
10184
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10185
|
+
/**
|
|
10186
|
+
* Generated image as Base64 string.
|
|
10187
|
+
*/
|
|
10188
|
+
image?: string;
|
|
10189
|
+
}
|
|
10190
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10191
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10192
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10193
|
+
}
|
|
10194
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10195
|
+
multipart: {
|
|
10196
|
+
body?: object;
|
|
10197
|
+
contentType?: string;
|
|
10198
|
+
};
|
|
10199
|
+
}
|
|
10200
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10201
|
+
/**
|
|
10202
|
+
* Generated image as Base64 string.
|
|
10203
|
+
*/
|
|
10204
|
+
image?: string;
|
|
10205
|
+
}
|
|
10206
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10207
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10208
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10209
|
+
}
|
|
10210
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10211
|
+
multipart: {
|
|
10212
|
+
body?: object;
|
|
10213
|
+
contentType?: string;
|
|
10214
|
+
};
|
|
10215
|
+
}
|
|
10216
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10217
|
+
/**
|
|
10218
|
+
* Generated image as Base64 string.
|
|
10219
|
+
*/
|
|
10220
|
+
image?: string;
|
|
10221
|
+
}
|
|
10222
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10223
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10224
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10225
|
+
}
|
|
10226
|
+
declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10227
|
+
inputs: ChatCompletionsInput;
|
|
10228
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10229
|
+
}
|
|
10230
|
+
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10231
|
+
inputs: ChatCompletionsInput;
|
|
10232
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10233
|
+
}
|
|
10234
|
+
declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10235
|
+
inputs: ChatCompletionsInput;
|
|
10236
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10237
|
+
}
|
|
9403
10238
|
interface AiModels {
|
|
9404
10239
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9405
10240
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9418,7 +10253,6 @@ interface AiModels {
|
|
|
9418
10253
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9419
10254
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9420
10255
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9421
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9422
10256
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9423
10257
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9424
10258
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9485,6 +10319,12 @@ interface AiModels {
|
|
|
9485
10319
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9486
10320
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9487
10321
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10322
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10323
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10324
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10325
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10326
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10327
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9488
10328
|
}
|
|
9489
10329
|
type AiOptions = {
|
|
9490
10330
|
/**
|
|
@@ -9510,6 +10350,7 @@ type AiOptions = {
|
|
|
9510
10350
|
returnRawResponse?: boolean;
|
|
9511
10351
|
prefix?: string;
|
|
9512
10352
|
extraHeaders?: object;
|
|
10353
|
+
signal?: AbortSignal;
|
|
9513
10354
|
};
|
|
9514
10355
|
type AiModelsSearchParams = {
|
|
9515
10356
|
author?: string;
|
|
@@ -9536,6 +10377,16 @@ type AiModelsSearchObject = {
|
|
|
9536
10377
|
value: string;
|
|
9537
10378
|
}[];
|
|
9538
10379
|
};
|
|
10380
|
+
type ChatCompletionsBase = XOR<
|
|
10381
|
+
ChatCompletionsPromptInput,
|
|
10382
|
+
ChatCompletionsMessagesInput
|
|
10383
|
+
>;
|
|
10384
|
+
type ChatCompletionsInput = XOR<
|
|
10385
|
+
ChatCompletionsBase,
|
|
10386
|
+
{
|
|
10387
|
+
requests: ChatCompletionsBase[];
|
|
10388
|
+
}
|
|
10389
|
+
>;
|
|
9539
10390
|
interface InferenceUpstreamError extends Error {}
|
|
9540
10391
|
interface AiInternalError extends Error {}
|
|
9541
10392
|
type AiModelListType = Record<string, any>;
|
|
@@ -9543,46 +10394,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
9543
10394
|
aiGatewayLogId: string | null;
|
|
9544
10395
|
gateway(gatewayId: string): AiGateway;
|
|
9545
10396
|
/**
|
|
9546
|
-
*
|
|
9547
|
-
*
|
|
9548
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9549
|
-
* - Account-level operations: `list()`, `create()`
|
|
9550
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9551
|
-
*
|
|
9552
|
-
* @example
|
|
9553
|
-
* ```typescript
|
|
9554
|
-
* // List all AI Search instances
|
|
9555
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9556
|
-
*
|
|
9557
|
-
* // Search an instance
|
|
9558
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9559
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9560
|
-
* ai_search_options: {
|
|
9561
|
-
* retrieval: { max_num_results: 10 }
|
|
9562
|
-
* }
|
|
9563
|
-
* });
|
|
9564
|
-
*
|
|
9565
|
-
* // Generate chat completions with AI Search context
|
|
9566
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9567
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9568
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9569
|
-
* });
|
|
9570
|
-
* ```
|
|
10397
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10398
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9571
10399
|
*/
|
|
9572
|
-
aiSearch():
|
|
10400
|
+
aiSearch(): AiSearchNamespace;
|
|
9573
10401
|
/**
|
|
9574
10402
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9575
|
-
* Use `
|
|
9576
|
-
*
|
|
9577
|
-
* Migration guide:
|
|
9578
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9579
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9580
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10403
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10404
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9581
10405
|
*
|
|
9582
|
-
*
|
|
9583
|
-
*
|
|
9584
|
-
* @see AiSearchAccountService
|
|
9585
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10406
|
+
* @param autoragId Instance ID
|
|
9586
10407
|
*/
|
|
9587
10408
|
autorag(autoragId: string): AutoRAG;
|
|
9588
10409
|
run<
|
|
@@ -9741,22 +10562,23 @@ declare abstract class AiGateway {
|
|
|
9741
10562
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9742
10563
|
}
|
|
9743
10564
|
/**
|
|
9744
|
-
* @deprecated
|
|
9745
|
-
*
|
|
10565
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10566
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9746
10567
|
*/
|
|
9747
10568
|
interface AutoRAGInternalError extends Error {}
|
|
9748
10569
|
/**
|
|
9749
|
-
* @deprecated
|
|
9750
|
-
*
|
|
10570
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10571
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9751
10572
|
*/
|
|
9752
10573
|
interface AutoRAGNotFoundError extends Error {}
|
|
9753
10574
|
/**
|
|
9754
|
-
* @deprecated
|
|
10575
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10576
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9755
10577
|
*/
|
|
9756
10578
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
9757
10579
|
/**
|
|
9758
|
-
* @deprecated
|
|
9759
|
-
*
|
|
10580
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10581
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9760
10582
|
*/
|
|
9761
10583
|
interface AutoRAGNameNotSetError extends Error {}
|
|
9762
10584
|
type ComparisonFilter = {
|
|
@@ -9769,9 +10591,8 @@ type CompoundFilter = {
|
|
|
9769
10591
|
filters: ComparisonFilter[];
|
|
9770
10592
|
};
|
|
9771
10593
|
/**
|
|
9772
|
-
* @deprecated
|
|
9773
|
-
*
|
|
9774
|
-
* @see AiSearchSearchRequest
|
|
10594
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10595
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9775
10596
|
*/
|
|
9776
10597
|
type AutoRagSearchRequest = {
|
|
9777
10598
|
query: string;
|
|
@@ -9788,18 +10609,16 @@ type AutoRagSearchRequest = {
|
|
|
9788
10609
|
rewrite_query?: boolean;
|
|
9789
10610
|
};
|
|
9790
10611
|
/**
|
|
9791
|
-
* @deprecated
|
|
9792
|
-
*
|
|
9793
|
-
* @see AiSearchChatCompletionsRequest
|
|
10612
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10613
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9794
10614
|
*/
|
|
9795
10615
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9796
10616
|
stream?: boolean;
|
|
9797
10617
|
system_prompt?: string;
|
|
9798
10618
|
};
|
|
9799
10619
|
/**
|
|
9800
|
-
* @deprecated
|
|
9801
|
-
*
|
|
9802
|
-
* @see AiSearchChatCompletionsRequest
|
|
10620
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10621
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9803
10622
|
*/
|
|
9804
10623
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
9805
10624
|
AutoRagAiSearchRequest,
|
|
@@ -9808,9 +10627,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9808
10627
|
stream: true;
|
|
9809
10628
|
};
|
|
9810
10629
|
/**
|
|
9811
|
-
* @deprecated
|
|
9812
|
-
*
|
|
9813
|
-
* @see AiSearchSearchResponse
|
|
10630
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10631
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9814
10632
|
*/
|
|
9815
10633
|
type AutoRagSearchResponse = {
|
|
9816
10634
|
object: "vector_store.search_results.page";
|
|
@@ -9829,9 +10647,8 @@ type AutoRagSearchResponse = {
|
|
|
9829
10647
|
next_page: string | null;
|
|
9830
10648
|
};
|
|
9831
10649
|
/**
|
|
9832
|
-
* @deprecated
|
|
9833
|
-
*
|
|
9834
|
-
* @see AiSearchListResponse
|
|
10650
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10651
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9835
10652
|
*/
|
|
9836
10653
|
type AutoRagListResponse = {
|
|
9837
10654
|
id: string;
|
|
@@ -9843,49 +10660,40 @@ type AutoRagListResponse = {
|
|
|
9843
10660
|
status: string;
|
|
9844
10661
|
}[];
|
|
9845
10662
|
/**
|
|
9846
|
-
* @deprecated
|
|
9847
|
-
*
|
|
10663
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10664
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9848
10665
|
*/
|
|
9849
10666
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9850
10667
|
response: string;
|
|
9851
10668
|
};
|
|
9852
10669
|
/**
|
|
9853
|
-
* @deprecated
|
|
9854
|
-
*
|
|
9855
|
-
*
|
|
9856
|
-
* Migration guide:
|
|
9857
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9858
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9859
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9860
|
-
*
|
|
9861
|
-
* @see AiSearchAccountService
|
|
9862
|
-
* @see AiSearchInstanceService
|
|
10670
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10671
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9863
10672
|
*/
|
|
9864
10673
|
declare abstract class AutoRAG {
|
|
9865
10674
|
/**
|
|
9866
|
-
* @deprecated Use
|
|
9867
|
-
*
|
|
10675
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10676
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9868
10677
|
*/
|
|
9869
10678
|
list(): Promise<AutoRagListResponse>;
|
|
9870
10679
|
/**
|
|
9871
|
-
* @deprecated Use
|
|
9872
|
-
*
|
|
9873
|
-
* @see AiSearchInstanceService.search
|
|
10680
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10681
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9874
10682
|
*/
|
|
9875
10683
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9876
10684
|
/**
|
|
9877
|
-
* @deprecated Use
|
|
9878
|
-
*
|
|
10685
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10686
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9879
10687
|
*/
|
|
9880
10688
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9881
10689
|
/**
|
|
9882
|
-
* @deprecated Use
|
|
9883
|
-
*
|
|
10690
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10691
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9884
10692
|
*/
|
|
9885
10693
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9886
10694
|
/**
|
|
9887
|
-
* @deprecated Use
|
|
9888
|
-
*
|
|
10695
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10696
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9889
10697
|
*/
|
|
9890
10698
|
aiSearch(
|
|
9891
10699
|
params: AutoRagAiSearchRequest,
|
|
@@ -10010,6 +10818,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
10010
10818
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
10011
10819
|
*/
|
|
10012
10820
|
cacheTtlByStatus?: Record<string, number>;
|
|
10821
|
+
/**
|
|
10822
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10823
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10824
|
+
*
|
|
10825
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10826
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10827
|
+
*
|
|
10828
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10829
|
+
*/
|
|
10830
|
+
cacheControl?: string;
|
|
10831
|
+
/**
|
|
10832
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10833
|
+
*/
|
|
10834
|
+
cacheReserveEligible?: boolean;
|
|
10835
|
+
/**
|
|
10836
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10837
|
+
*/
|
|
10838
|
+
respectStrongEtag?: boolean;
|
|
10839
|
+
/**
|
|
10840
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10841
|
+
*/
|
|
10842
|
+
stripEtags?: boolean;
|
|
10843
|
+
/**
|
|
10844
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10845
|
+
*/
|
|
10846
|
+
stripLastModified?: boolean;
|
|
10847
|
+
/**
|
|
10848
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10849
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10850
|
+
*/
|
|
10851
|
+
cacheDeceptionArmor?: boolean;
|
|
10852
|
+
/**
|
|
10853
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10854
|
+
*/
|
|
10855
|
+
cacheReserveMinimumFileSize?: number;
|
|
10013
10856
|
scrapeShield?: boolean;
|
|
10014
10857
|
apps?: boolean;
|
|
10015
10858
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11922,6 +12765,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11922
12765
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11923
12766
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11924
12767
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12768
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11925
12769
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11926
12770
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11927
12771
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11942,6 +12786,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11942
12786
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11943
12787
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11944
12788
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12789
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11945
12790
|
webSocketMessage?(
|
|
11946
12791
|
ws: WebSocket,
|
|
11947
12792
|
message: string | ArrayBuffer,
|
|
@@ -12092,17 +12937,6 @@ interface StreamBinding {
|
|
|
12092
12937
|
* @returns A handle for per-video operations.
|
|
12093
12938
|
*/
|
|
12094
12939
|
video(id: string): StreamVideoHandle;
|
|
12095
|
-
/**
|
|
12096
|
-
* Uploads a new video from a File.
|
|
12097
|
-
* @param file The video file to upload.
|
|
12098
|
-
* @returns The uploaded video details.
|
|
12099
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12100
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12101
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12102
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12103
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12104
|
-
*/
|
|
12105
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12106
12940
|
/**
|
|
12107
12941
|
* Uploads a new video from a provided URL.
|
|
12108
12942
|
* @param url The URL to upload from.
|
|
@@ -12952,6 +13786,9 @@ declare namespace TailStream {
|
|
|
12952
13786
|
readonly type: "fetch";
|
|
12953
13787
|
readonly statusCode: number;
|
|
12954
13788
|
}
|
|
13789
|
+
interface ConnectEventInfo {
|
|
13790
|
+
readonly type: "connect";
|
|
13791
|
+
}
|
|
12955
13792
|
type EventOutcome =
|
|
12956
13793
|
| "ok"
|
|
12957
13794
|
| "canceled"
|
|
@@ -12982,6 +13819,7 @@ declare namespace TailStream {
|
|
|
12982
13819
|
readonly scriptVersion?: ScriptVersion;
|
|
12983
13820
|
readonly info:
|
|
12984
13821
|
| FetchEventInfo
|
|
13822
|
+
| ConnectEventInfo
|
|
12985
13823
|
| JsRpcEventInfo
|
|
12986
13824
|
| ScheduledEventInfo
|
|
12987
13825
|
| AlarmEventInfo
|