@workers-community/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/index.d.ts +1018 -180
- package/index.ts +1020 -180
- package/package.json +1 -1
package/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,
|
|
@@ -3094,6 +3103,11 @@ interface QueuingStrategyInit {
|
|
|
3094
3103
|
*/
|
|
3095
3104
|
highWaterMark: number;
|
|
3096
3105
|
}
|
|
3106
|
+
interface TracePreviewInfo {
|
|
3107
|
+
id: string;
|
|
3108
|
+
slug: string;
|
|
3109
|
+
name: string;
|
|
3110
|
+
}
|
|
3097
3111
|
interface ScriptVersion {
|
|
3098
3112
|
id?: string;
|
|
3099
3113
|
tag?: string;
|
|
@@ -3108,6 +3122,7 @@ interface TraceItem {
|
|
|
3108
3122
|
| (
|
|
3109
3123
|
| TraceItemFetchEventInfo
|
|
3110
3124
|
| TraceItemJsRpcEventInfo
|
|
3125
|
+
| TraceItemConnectEventInfo
|
|
3111
3126
|
| TraceItemScheduledEventInfo
|
|
3112
3127
|
| TraceItemAlarmEventInfo
|
|
3113
3128
|
| TraceItemQueueEventInfo
|
|
@@ -3126,6 +3141,8 @@ interface TraceItem {
|
|
|
3126
3141
|
readonly scriptVersion?: ScriptVersion;
|
|
3127
3142
|
readonly dispatchNamespace?: string;
|
|
3128
3143
|
readonly scriptTags?: string[];
|
|
3144
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3145
|
+
readonly preview?: TracePreviewInfo;
|
|
3129
3146
|
readonly durableObjectId?: string;
|
|
3130
3147
|
readonly outcome: string;
|
|
3131
3148
|
readonly executionModel: string;
|
|
@@ -3136,6 +3153,7 @@ interface TraceItem {
|
|
|
3136
3153
|
interface TraceItemAlarmEventInfo {
|
|
3137
3154
|
readonly scheduledTime: Date;
|
|
3138
3155
|
}
|
|
3156
|
+
interface TraceItemConnectEventInfo {}
|
|
3139
3157
|
interface TraceItemCustomEventInfo {}
|
|
3140
3158
|
interface TraceItemScheduledEventInfo {
|
|
3141
3159
|
readonly scheduledTime: number;
|
|
@@ -3756,7 +3774,7 @@ interface ContainerStartupOptions {
|
|
|
3756
3774
|
entrypoint?: string[];
|
|
3757
3775
|
enableInternet: boolean;
|
|
3758
3776
|
env?: Record<string, string>;
|
|
3759
|
-
|
|
3777
|
+
labels?: Record<string, string>;
|
|
3760
3778
|
}
|
|
3761
3779
|
/**
|
|
3762
3780
|
* 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.
|
|
@@ -3883,11 +3901,10 @@ declare abstract class Performance {
|
|
|
3883
3901
|
*/
|
|
3884
3902
|
toJSON(): object;
|
|
3885
3903
|
}
|
|
3886
|
-
// AI Search
|
|
3904
|
+
// ============ AI Search Error Interfaces ============
|
|
3887
3905
|
interface AiSearchInternalError extends Error {}
|
|
3888
3906
|
interface AiSearchNotFoundError extends Error {}
|
|
3889
|
-
|
|
3890
|
-
// AI Search V2 Request Types
|
|
3907
|
+
// ============ AI Search Request Types ============
|
|
3891
3908
|
type AiSearchSearchRequest = {
|
|
3892
3909
|
messages: Array<{
|
|
3893
3910
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3912,9 +3929,8 @@ type AiSearchSearchRequest = {
|
|
|
3912
3929
|
[key: string]: unknown;
|
|
3913
3930
|
};
|
|
3914
3931
|
reranking?: {
|
|
3915
|
-
/** Enable reranking (default false) */
|
|
3916
3932
|
enabled?: boolean;
|
|
3917
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3933
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3918
3934
|
/** Match threshold (0-1, default 0.4) */
|
|
3919
3935
|
match_threshold?: number;
|
|
3920
3936
|
[key: string]: unknown;
|
|
@@ -3926,6 +3942,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3926
3942
|
messages: Array<{
|
|
3927
3943
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3928
3944
|
content: string | null;
|
|
3945
|
+
[key: string]: unknown;
|
|
3929
3946
|
}>;
|
|
3930
3947
|
model?: string;
|
|
3931
3948
|
stream?: boolean;
|
|
@@ -3946,7 +3963,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3946
3963
|
};
|
|
3947
3964
|
reranking?: {
|
|
3948
3965
|
enabled?: boolean;
|
|
3949
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3966
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3950
3967
|
match_threshold?: number;
|
|
3951
3968
|
[key: string]: unknown;
|
|
3952
3969
|
};
|
|
@@ -3954,7 +3971,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3954
3971
|
};
|
|
3955
3972
|
[key: string]: unknown;
|
|
3956
3973
|
};
|
|
3957
|
-
// AI Search
|
|
3974
|
+
// ============ AI Search Response Types ============
|
|
3958
3975
|
type AiSearchSearchResponse = {
|
|
3959
3976
|
search_query: string;
|
|
3960
3977
|
chunks: Array<{
|
|
@@ -3973,26 +3990,65 @@ type AiSearchSearchResponse = {
|
|
|
3973
3990
|
keyword_score?: number;
|
|
3974
3991
|
/** Vector similarity score (0-1) */
|
|
3975
3992
|
vector_score?: number;
|
|
3993
|
+
[key: string]: unknown;
|
|
3994
|
+
};
|
|
3995
|
+
}>;
|
|
3996
|
+
};
|
|
3997
|
+
type AiSearchChatCompletionsResponse = {
|
|
3998
|
+
id?: string;
|
|
3999
|
+
object?: string;
|
|
4000
|
+
model?: string;
|
|
4001
|
+
choices: Array<{
|
|
4002
|
+
index?: number;
|
|
4003
|
+
message: {
|
|
4004
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4005
|
+
content: string | null;
|
|
4006
|
+
[key: string]: unknown;
|
|
3976
4007
|
};
|
|
4008
|
+
[key: string]: unknown;
|
|
3977
4009
|
}>;
|
|
4010
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4011
|
+
[key: string]: unknown;
|
|
3978
4012
|
};
|
|
3979
|
-
type
|
|
4013
|
+
type AiSearchStatsResponse = {
|
|
4014
|
+
queued?: number;
|
|
4015
|
+
running?: number;
|
|
4016
|
+
completed?: number;
|
|
4017
|
+
error?: number;
|
|
4018
|
+
skipped?: number;
|
|
4019
|
+
outdated?: number;
|
|
4020
|
+
last_activity?: string;
|
|
4021
|
+
};
|
|
4022
|
+
// ============ AI Search Instance Info Types ============
|
|
4023
|
+
type AiSearchInstanceInfo = {
|
|
3980
4024
|
id: string;
|
|
3981
|
-
|
|
3982
|
-
account_id?: string;
|
|
3983
|
-
account_tag?: string;
|
|
3984
|
-
/** Whether the instance is enabled (default true) */
|
|
3985
|
-
enable?: boolean;
|
|
3986
|
-
type?: "r2" | "web-crawler";
|
|
4025
|
+
type?: "r2" | "web-crawler" | string;
|
|
3987
4026
|
source?: string;
|
|
4027
|
+
paused?: boolean;
|
|
4028
|
+
status?: string;
|
|
4029
|
+
namespace?: string;
|
|
4030
|
+
created_at?: string;
|
|
4031
|
+
modified_at?: string;
|
|
3988
4032
|
[key: string]: unknown;
|
|
3989
|
-
}
|
|
4033
|
+
};
|
|
4034
|
+
type AiSearchListResponse = {
|
|
4035
|
+
result: AiSearchInstanceInfo[];
|
|
4036
|
+
result_info?: {
|
|
4037
|
+
count: number;
|
|
4038
|
+
page: number;
|
|
4039
|
+
per_page: number;
|
|
4040
|
+
total_count: number;
|
|
4041
|
+
};
|
|
4042
|
+
};
|
|
4043
|
+
// ============ AI Search Config Types ============
|
|
3990
4044
|
type AiSearchConfig = {
|
|
3991
4045
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3992
4046
|
id: string;
|
|
3993
|
-
type
|
|
3994
|
-
|
|
3995
|
-
|
|
4047
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4048
|
+
type?: "r2" | "web-crawler" | string;
|
|
4049
|
+
/** Source URL (required for web-crawler type). */
|
|
4050
|
+
source?: string;
|
|
4051
|
+
source_params?: unknown;
|
|
3996
4052
|
/** Token ID (UUID format) */
|
|
3997
4053
|
token_id?: string;
|
|
3998
4054
|
ai_gateway_id?: string;
|
|
@@ -4002,54 +4058,307 @@ type AiSearchConfig = {
|
|
|
4002
4058
|
reranking?: boolean;
|
|
4003
4059
|
embedding_model?: string;
|
|
4004
4060
|
ai_search_model?: string;
|
|
4061
|
+
[key: string]: unknown;
|
|
4005
4062
|
};
|
|
4006
|
-
|
|
4063
|
+
// ============ AI Search Item Types ============
|
|
4064
|
+
type AiSearchItemInfo = {
|
|
4007
4065
|
id: string;
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4066
|
+
key: string;
|
|
4067
|
+
status:
|
|
4068
|
+
| "completed"
|
|
4069
|
+
| "error"
|
|
4070
|
+
| "skipped"
|
|
4071
|
+
| "queued"
|
|
4072
|
+
| "processing"
|
|
4073
|
+
| "outdated";
|
|
4074
|
+
metadata?: Record<string, unknown>;
|
|
4011
4075
|
[key: string]: unknown;
|
|
4012
4076
|
};
|
|
4013
|
-
|
|
4014
|
-
|
|
4077
|
+
type AiSearchItemContentResult = {
|
|
4078
|
+
body: ReadableStream;
|
|
4079
|
+
contentType: string;
|
|
4080
|
+
filename: string;
|
|
4081
|
+
size: number;
|
|
4082
|
+
};
|
|
4083
|
+
type AiSearchUploadItemOptions = {
|
|
4084
|
+
metadata?: Record<string, unknown>;
|
|
4085
|
+
};
|
|
4086
|
+
type AiSearchListItemsParams = {
|
|
4087
|
+
page?: number;
|
|
4088
|
+
per_page?: number;
|
|
4089
|
+
};
|
|
4090
|
+
type AiSearchListItemsResponse = {
|
|
4091
|
+
result: AiSearchItemInfo[];
|
|
4092
|
+
result_info?: {
|
|
4093
|
+
count: number;
|
|
4094
|
+
page: number;
|
|
4095
|
+
per_page: number;
|
|
4096
|
+
total_count: number;
|
|
4097
|
+
};
|
|
4098
|
+
};
|
|
4099
|
+
// ============ AI Search Job Types ============
|
|
4100
|
+
type AiSearchJobInfo = {
|
|
4101
|
+
id: string;
|
|
4102
|
+
source: "user" | "schedule";
|
|
4103
|
+
description?: string;
|
|
4104
|
+
last_seen_at?: string;
|
|
4105
|
+
started_at?: string;
|
|
4106
|
+
ended_at?: string;
|
|
4107
|
+
end_reason?: string;
|
|
4108
|
+
};
|
|
4109
|
+
type AiSearchJobLog = {
|
|
4110
|
+
id: number;
|
|
4111
|
+
message: string;
|
|
4112
|
+
message_type: number;
|
|
4113
|
+
created_at: number;
|
|
4114
|
+
};
|
|
4115
|
+
type AiSearchCreateJobParams = {
|
|
4116
|
+
description?: string;
|
|
4117
|
+
};
|
|
4118
|
+
type AiSearchListJobsParams = {
|
|
4119
|
+
page?: number;
|
|
4120
|
+
per_page?: number;
|
|
4121
|
+
};
|
|
4122
|
+
type AiSearchListJobsResponse = {
|
|
4123
|
+
result: AiSearchJobInfo[];
|
|
4124
|
+
result_info?: {
|
|
4125
|
+
count: number;
|
|
4126
|
+
page: number;
|
|
4127
|
+
per_page: number;
|
|
4128
|
+
total_count: number;
|
|
4129
|
+
};
|
|
4130
|
+
};
|
|
4131
|
+
type AiSearchJobLogsParams = {
|
|
4132
|
+
page?: number;
|
|
4133
|
+
per_page?: number;
|
|
4134
|
+
};
|
|
4135
|
+
type AiSearchJobLogsResponse = {
|
|
4136
|
+
result: AiSearchJobLog[];
|
|
4137
|
+
result_info?: {
|
|
4138
|
+
count: number;
|
|
4139
|
+
page: number;
|
|
4140
|
+
per_page: number;
|
|
4141
|
+
total_count: number;
|
|
4142
|
+
};
|
|
4143
|
+
};
|
|
4144
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4145
|
+
/**
|
|
4146
|
+
* Single item service for an AI Search instance.
|
|
4147
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4148
|
+
*/
|
|
4149
|
+
declare abstract class AiSearchItem {
|
|
4150
|
+
/** Get metadata about this item. */
|
|
4151
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4152
|
+
/**
|
|
4153
|
+
* Download the item's content.
|
|
4154
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4155
|
+
*/
|
|
4156
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Items collection service for an AI Search instance.
|
|
4160
|
+
* Provides list, upload, and access to individual items.
|
|
4161
|
+
*/
|
|
4162
|
+
declare abstract class AiSearchItems {
|
|
4163
|
+
/** List items in this instance. */
|
|
4164
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4165
|
+
/**
|
|
4166
|
+
* Upload a file as an item.
|
|
4167
|
+
* @param name Filename for the uploaded item.
|
|
4168
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4169
|
+
* @param options Optional metadata to attach to the item.
|
|
4170
|
+
* @returns The created item info.
|
|
4171
|
+
*/
|
|
4172
|
+
upload(
|
|
4173
|
+
name: string,
|
|
4174
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4175
|
+
options?: AiSearchUploadItemOptions,
|
|
4176
|
+
): Promise<AiSearchItemInfo>;
|
|
4177
|
+
/**
|
|
4178
|
+
* Upload a file and poll until processing completes.
|
|
4179
|
+
* @param name Filename for the uploaded item.
|
|
4180
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4181
|
+
* @param options Optional metadata to attach to the item.
|
|
4182
|
+
* @returns The item info after processing completes (or timeout).
|
|
4183
|
+
*/
|
|
4184
|
+
uploadAndPoll(
|
|
4185
|
+
name: string,
|
|
4186
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4187
|
+
options?: AiSearchUploadItemOptions,
|
|
4188
|
+
): Promise<AiSearchItemInfo>;
|
|
4189
|
+
/**
|
|
4190
|
+
* Get an item by ID.
|
|
4191
|
+
* @param itemId The item identifier.
|
|
4192
|
+
* @returns Item service for info, delete, and download operations.
|
|
4193
|
+
*/
|
|
4194
|
+
get(itemId: string): AiSearchItem;
|
|
4195
|
+
/** Delete this item from the instance.
|
|
4196
|
+
* @param itemId The item identifier.
|
|
4197
|
+
*/
|
|
4198
|
+
delete(itemId: string): Promise<void>;
|
|
4199
|
+
}
|
|
4200
|
+
/**
|
|
4201
|
+
* Single job service for an AI Search instance.
|
|
4202
|
+
* Provides info and logs for a specific job.
|
|
4203
|
+
*/
|
|
4204
|
+
declare abstract class AiSearchJob {
|
|
4205
|
+
/** Get metadata about this job. */
|
|
4206
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4207
|
+
/** Get logs for this job. */
|
|
4208
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4209
|
+
}
|
|
4210
|
+
/**
|
|
4211
|
+
* Jobs collection service for an AI Search instance.
|
|
4212
|
+
* Provides list, create, and access to individual jobs.
|
|
4213
|
+
*/
|
|
4214
|
+
declare abstract class AiSearchJobs {
|
|
4215
|
+
/** List jobs for this instance. */
|
|
4216
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4217
|
+
/**
|
|
4218
|
+
* Create a new indexing job.
|
|
4219
|
+
* @param params Optional job parameters.
|
|
4220
|
+
* @returns The created job info.
|
|
4221
|
+
*/
|
|
4222
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4223
|
+
/**
|
|
4224
|
+
* Get a job by ID.
|
|
4225
|
+
* @param jobId The job identifier.
|
|
4226
|
+
* @returns Job service for info and logs operations.
|
|
4227
|
+
*/
|
|
4228
|
+
get(jobId: string): AiSearchJob;
|
|
4229
|
+
}
|
|
4230
|
+
// ============ AI Search Binding Classes ============
|
|
4231
|
+
/**
|
|
4232
|
+
* Instance-level AI Search service.
|
|
4233
|
+
*
|
|
4234
|
+
* Used as:
|
|
4235
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4236
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4237
|
+
*
|
|
4238
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4239
|
+
*
|
|
4240
|
+
* @example
|
|
4241
|
+
* ```ts
|
|
4242
|
+
* // Via namespace binding
|
|
4243
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4244
|
+
* const results = await instance.search({
|
|
4245
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4246
|
+
* });
|
|
4247
|
+
*
|
|
4248
|
+
* // Via single instance binding
|
|
4249
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4250
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4251
|
+
* });
|
|
4252
|
+
* ```
|
|
4253
|
+
*/
|
|
4254
|
+
declare abstract class AiSearchInstance {
|
|
4015
4255
|
/**
|
|
4016
4256
|
* Search the AI Search instance for relevant chunks.
|
|
4017
|
-
* @param params Search request with messages and AI search options
|
|
4018
|
-
* @returns Search response with matching chunks
|
|
4257
|
+
* @param params Search request with messages and optional AI search options.
|
|
4258
|
+
* @returns Search response with matching chunks and search query.
|
|
4019
4259
|
*/
|
|
4020
4260
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4261
|
+
/**
|
|
4262
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4263
|
+
* @param params Chat completions request with stream: true.
|
|
4264
|
+
* @returns ReadableStream of server-sent events.
|
|
4265
|
+
*/
|
|
4266
|
+
chatCompletions(
|
|
4267
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4268
|
+
stream: true;
|
|
4269
|
+
},
|
|
4270
|
+
): Promise<ReadableStream>;
|
|
4021
4271
|
/**
|
|
4022
4272
|
* Generate chat completions with AI Search context.
|
|
4023
|
-
* @param params Chat completions request
|
|
4024
|
-
* @returns
|
|
4273
|
+
* @param params Chat completions request.
|
|
4274
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4025
4275
|
*/
|
|
4026
4276
|
chatCompletions(
|
|
4027
4277
|
params: AiSearchChatCompletionsRequest,
|
|
4028
|
-
): Promise<
|
|
4278
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4029
4279
|
/**
|
|
4030
|
-
*
|
|
4280
|
+
* Update the instance configuration.
|
|
4281
|
+
* @param config Partial configuration to update.
|
|
4282
|
+
* @returns Updated instance info.
|
|
4031
4283
|
*/
|
|
4032
|
-
|
|
4284
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4285
|
+
/** Get metadata about this instance. */
|
|
4286
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4287
|
+
/**
|
|
4288
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4289
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4290
|
+
*/
|
|
4291
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4292
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4293
|
+
get items(): AiSearchItems;
|
|
4294
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4295
|
+
get jobs(): AiSearchJobs;
|
|
4033
4296
|
}
|
|
4034
|
-
|
|
4035
|
-
|
|
4297
|
+
/**
|
|
4298
|
+
* Namespace-level AI Search service.
|
|
4299
|
+
*
|
|
4300
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4301
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4302
|
+
*
|
|
4303
|
+
* @example
|
|
4304
|
+
* ```ts
|
|
4305
|
+
* // Access an instance within the namespace
|
|
4306
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4307
|
+
* const results = await blog.search({
|
|
4308
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4309
|
+
* });
|
|
4310
|
+
*
|
|
4311
|
+
* // List all instances in the namespace
|
|
4312
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4313
|
+
*
|
|
4314
|
+
* // Create a new instance with built-in storage
|
|
4315
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4316
|
+
* id: "tenant-123",
|
|
4317
|
+
* });
|
|
4318
|
+
*
|
|
4319
|
+
* // Upload items into the instance
|
|
4320
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4321
|
+
*
|
|
4322
|
+
* // Delete an instance
|
|
4323
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4324
|
+
* ```
|
|
4325
|
+
*/
|
|
4326
|
+
declare abstract class AiSearchNamespace {
|
|
4036
4327
|
/**
|
|
4037
|
-
*
|
|
4038
|
-
* @
|
|
4328
|
+
* Get an instance by name within the bound namespace.
|
|
4329
|
+
* @param name Instance name.
|
|
4330
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4331
|
+
*/
|
|
4332
|
+
get(name: string): AiSearchInstance;
|
|
4333
|
+
/**
|
|
4334
|
+
* List all instances in the bound namespace.
|
|
4335
|
+
* @returns Array of instance metadata.
|
|
4039
4336
|
*/
|
|
4040
4337
|
list(): Promise<AiSearchListResponse>;
|
|
4041
4338
|
/**
|
|
4042
|
-
*
|
|
4043
|
-
* @param
|
|
4044
|
-
* @returns Instance service for
|
|
4339
|
+
* Create a new instance within the bound namespace.
|
|
4340
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4341
|
+
* @returns Instance service for the newly created instance.
|
|
4342
|
+
*
|
|
4343
|
+
* @example
|
|
4344
|
+
* ```ts
|
|
4345
|
+
* // Create with built-in storage (upload items manually)
|
|
4346
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4347
|
+
*
|
|
4348
|
+
* // Create with web crawler source
|
|
4349
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4350
|
+
* id: "docs-search",
|
|
4351
|
+
* type: "web-crawler",
|
|
4352
|
+
* source: "https://developers.cloudflare.com",
|
|
4353
|
+
* });
|
|
4354
|
+
* ```
|
|
4045
4355
|
*/
|
|
4046
|
-
|
|
4356
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4047
4357
|
/**
|
|
4048
|
-
*
|
|
4049
|
-
* @param
|
|
4050
|
-
* @returns Instance service for performing operations
|
|
4358
|
+
* Delete an instance from the bound namespace.
|
|
4359
|
+
* @param name Instance name to delete.
|
|
4051
4360
|
*/
|
|
4052
|
-
|
|
4361
|
+
delete(name: string): Promise<void>;
|
|
4053
4362
|
}
|
|
4054
4363
|
type AiImageClassificationInput = {
|
|
4055
4364
|
image: number[];
|
|
@@ -4325,6 +4634,400 @@ declare abstract class BaseAiTranslation {
|
|
|
4325
4634
|
inputs: AiTranslationInput;
|
|
4326
4635
|
postProcessedOutputs: AiTranslationOutput;
|
|
4327
4636
|
}
|
|
4637
|
+
/**
|
|
4638
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4639
|
+
*/
|
|
4640
|
+
type ChatCompletionContentPartText = {
|
|
4641
|
+
type: "text";
|
|
4642
|
+
text: string;
|
|
4643
|
+
};
|
|
4644
|
+
type ChatCompletionContentPartImage = {
|
|
4645
|
+
type: "image_url";
|
|
4646
|
+
image_url: {
|
|
4647
|
+
url: string;
|
|
4648
|
+
detail?: "auto" | "low" | "high";
|
|
4649
|
+
};
|
|
4650
|
+
};
|
|
4651
|
+
type ChatCompletionContentPartInputAudio = {
|
|
4652
|
+
type: "input_audio";
|
|
4653
|
+
input_audio: {
|
|
4654
|
+
/** Base64 encoded audio data. */
|
|
4655
|
+
data: string;
|
|
4656
|
+
format: "wav" | "mp3";
|
|
4657
|
+
};
|
|
4658
|
+
};
|
|
4659
|
+
type ChatCompletionContentPartFile = {
|
|
4660
|
+
type: "file";
|
|
4661
|
+
file: {
|
|
4662
|
+
/** Base64 encoded file data. */
|
|
4663
|
+
file_data?: string;
|
|
4664
|
+
/** The ID of an uploaded file. */
|
|
4665
|
+
file_id?: string;
|
|
4666
|
+
filename?: string;
|
|
4667
|
+
};
|
|
4668
|
+
};
|
|
4669
|
+
type ChatCompletionContentPartRefusal = {
|
|
4670
|
+
type: "refusal";
|
|
4671
|
+
refusal: string;
|
|
4672
|
+
};
|
|
4673
|
+
type ChatCompletionContentPart =
|
|
4674
|
+
| ChatCompletionContentPartText
|
|
4675
|
+
| ChatCompletionContentPartImage
|
|
4676
|
+
| ChatCompletionContentPartInputAudio
|
|
4677
|
+
| ChatCompletionContentPartFile;
|
|
4678
|
+
type FunctionDefinition = {
|
|
4679
|
+
name: string;
|
|
4680
|
+
description?: string;
|
|
4681
|
+
parameters?: Record<string, unknown>;
|
|
4682
|
+
strict?: boolean | null;
|
|
4683
|
+
};
|
|
4684
|
+
type ChatCompletionFunctionTool = {
|
|
4685
|
+
type: "function";
|
|
4686
|
+
function: FunctionDefinition;
|
|
4687
|
+
};
|
|
4688
|
+
type ChatCompletionCustomToolGrammarFormat = {
|
|
4689
|
+
type: "grammar";
|
|
4690
|
+
grammar: {
|
|
4691
|
+
definition: string;
|
|
4692
|
+
syntax: "lark" | "regex";
|
|
4693
|
+
};
|
|
4694
|
+
};
|
|
4695
|
+
type ChatCompletionCustomToolTextFormat = {
|
|
4696
|
+
type: "text";
|
|
4697
|
+
};
|
|
4698
|
+
type ChatCompletionCustomToolFormat =
|
|
4699
|
+
| ChatCompletionCustomToolTextFormat
|
|
4700
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4701
|
+
type ChatCompletionCustomTool = {
|
|
4702
|
+
type: "custom";
|
|
4703
|
+
custom: {
|
|
4704
|
+
name: string;
|
|
4705
|
+
description?: string;
|
|
4706
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4707
|
+
};
|
|
4708
|
+
};
|
|
4709
|
+
type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
|
|
4710
|
+
type ChatCompletionMessageFunctionToolCall = {
|
|
4711
|
+
id: string;
|
|
4712
|
+
type: "function";
|
|
4713
|
+
function: {
|
|
4714
|
+
name: string;
|
|
4715
|
+
/** JSON-encoded arguments string. */
|
|
4716
|
+
arguments: string;
|
|
4717
|
+
};
|
|
4718
|
+
};
|
|
4719
|
+
type ChatCompletionMessageCustomToolCall = {
|
|
4720
|
+
id: string;
|
|
4721
|
+
type: "custom";
|
|
4722
|
+
custom: {
|
|
4723
|
+
name: string;
|
|
4724
|
+
input: string;
|
|
4725
|
+
};
|
|
4726
|
+
};
|
|
4727
|
+
type ChatCompletionMessageToolCall =
|
|
4728
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4729
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4730
|
+
type ChatCompletionToolChoiceFunction = {
|
|
4731
|
+
type: "function";
|
|
4732
|
+
function: {
|
|
4733
|
+
name: string;
|
|
4734
|
+
};
|
|
4735
|
+
};
|
|
4736
|
+
type ChatCompletionToolChoiceCustom = {
|
|
4737
|
+
type: "custom";
|
|
4738
|
+
custom: {
|
|
4739
|
+
name: string;
|
|
4740
|
+
};
|
|
4741
|
+
};
|
|
4742
|
+
type ChatCompletionToolChoiceAllowedTools = {
|
|
4743
|
+
type: "allowed_tools";
|
|
4744
|
+
allowed_tools: {
|
|
4745
|
+
mode: "auto" | "required";
|
|
4746
|
+
tools: Array<Record<string, unknown>>;
|
|
4747
|
+
};
|
|
4748
|
+
};
|
|
4749
|
+
type ChatCompletionToolChoiceOption =
|
|
4750
|
+
| "none"
|
|
4751
|
+
| "auto"
|
|
4752
|
+
| "required"
|
|
4753
|
+
| ChatCompletionToolChoiceFunction
|
|
4754
|
+
| ChatCompletionToolChoiceCustom
|
|
4755
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4756
|
+
type DeveloperMessage = {
|
|
4757
|
+
role: "developer";
|
|
4758
|
+
content:
|
|
4759
|
+
| string
|
|
4760
|
+
| Array<{
|
|
4761
|
+
type: "text";
|
|
4762
|
+
text: string;
|
|
4763
|
+
}>;
|
|
4764
|
+
name?: string;
|
|
4765
|
+
};
|
|
4766
|
+
type SystemMessage = {
|
|
4767
|
+
role: "system";
|
|
4768
|
+
content:
|
|
4769
|
+
| string
|
|
4770
|
+
| Array<{
|
|
4771
|
+
type: "text";
|
|
4772
|
+
text: string;
|
|
4773
|
+
}>;
|
|
4774
|
+
name?: string;
|
|
4775
|
+
};
|
|
4776
|
+
/**
|
|
4777
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4778
|
+
*
|
|
4779
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4780
|
+
* inside nested array items does not correctly match different branches for
|
|
4781
|
+
* different array elements, so the schema uses a single merged object.
|
|
4782
|
+
*/
|
|
4783
|
+
type UserMessageContentPart = {
|
|
4784
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4785
|
+
text?: string;
|
|
4786
|
+
image_url?: {
|
|
4787
|
+
url?: string;
|
|
4788
|
+
detail?: "auto" | "low" | "high";
|
|
4789
|
+
};
|
|
4790
|
+
input_audio?: {
|
|
4791
|
+
data?: string;
|
|
4792
|
+
format?: "wav" | "mp3";
|
|
4793
|
+
};
|
|
4794
|
+
file?: {
|
|
4795
|
+
file_data?: string;
|
|
4796
|
+
file_id?: string;
|
|
4797
|
+
filename?: string;
|
|
4798
|
+
};
|
|
4799
|
+
};
|
|
4800
|
+
type UserMessage = {
|
|
4801
|
+
role: "user";
|
|
4802
|
+
content: string | Array<UserMessageContentPart>;
|
|
4803
|
+
name?: string;
|
|
4804
|
+
};
|
|
4805
|
+
type AssistantMessageContentPart = {
|
|
4806
|
+
type: "text" | "refusal";
|
|
4807
|
+
text?: string;
|
|
4808
|
+
refusal?: string;
|
|
4809
|
+
};
|
|
4810
|
+
type AssistantMessage = {
|
|
4811
|
+
role: "assistant";
|
|
4812
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4813
|
+
refusal?: string | null;
|
|
4814
|
+
name?: string;
|
|
4815
|
+
audio?: {
|
|
4816
|
+
id: string;
|
|
4817
|
+
};
|
|
4818
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4819
|
+
function_call?: {
|
|
4820
|
+
name: string;
|
|
4821
|
+
arguments: string;
|
|
4822
|
+
};
|
|
4823
|
+
};
|
|
4824
|
+
type ToolMessage = {
|
|
4825
|
+
role: "tool";
|
|
4826
|
+
content:
|
|
4827
|
+
| string
|
|
4828
|
+
| Array<{
|
|
4829
|
+
type: "text";
|
|
4830
|
+
text: string;
|
|
4831
|
+
}>;
|
|
4832
|
+
tool_call_id: string;
|
|
4833
|
+
};
|
|
4834
|
+
type FunctionMessage = {
|
|
4835
|
+
role: "function";
|
|
4836
|
+
content: string;
|
|
4837
|
+
name: string;
|
|
4838
|
+
};
|
|
4839
|
+
type ChatCompletionMessageParam =
|
|
4840
|
+
| DeveloperMessage
|
|
4841
|
+
| SystemMessage
|
|
4842
|
+
| UserMessage
|
|
4843
|
+
| AssistantMessage
|
|
4844
|
+
| ToolMessage
|
|
4845
|
+
| FunctionMessage;
|
|
4846
|
+
type ChatCompletionsResponseFormatText = {
|
|
4847
|
+
type: "text";
|
|
4848
|
+
};
|
|
4849
|
+
type ChatCompletionsResponseFormatJSONObject = {
|
|
4850
|
+
type: "json_object";
|
|
4851
|
+
};
|
|
4852
|
+
type ResponseFormatJSONSchema = {
|
|
4853
|
+
type: "json_schema";
|
|
4854
|
+
json_schema: {
|
|
4855
|
+
name: string;
|
|
4856
|
+
description?: string;
|
|
4857
|
+
schema?: Record<string, unknown>;
|
|
4858
|
+
strict?: boolean | null;
|
|
4859
|
+
};
|
|
4860
|
+
};
|
|
4861
|
+
type ResponseFormat =
|
|
4862
|
+
| ChatCompletionsResponseFormatText
|
|
4863
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4864
|
+
| ResponseFormatJSONSchema;
|
|
4865
|
+
type ChatCompletionsStreamOptions = {
|
|
4866
|
+
include_usage?: boolean;
|
|
4867
|
+
include_obfuscation?: boolean;
|
|
4868
|
+
};
|
|
4869
|
+
type PredictionContent = {
|
|
4870
|
+
type: "content";
|
|
4871
|
+
content:
|
|
4872
|
+
| string
|
|
4873
|
+
| Array<{
|
|
4874
|
+
type: "text";
|
|
4875
|
+
text: string;
|
|
4876
|
+
}>;
|
|
4877
|
+
};
|
|
4878
|
+
type AudioParams = {
|
|
4879
|
+
voice:
|
|
4880
|
+
| string
|
|
4881
|
+
| {
|
|
4882
|
+
id: string;
|
|
4883
|
+
};
|
|
4884
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4885
|
+
};
|
|
4886
|
+
type WebSearchUserLocation = {
|
|
4887
|
+
type: "approximate";
|
|
4888
|
+
approximate: {
|
|
4889
|
+
city?: string;
|
|
4890
|
+
country?: string;
|
|
4891
|
+
region?: string;
|
|
4892
|
+
timezone?: string;
|
|
4893
|
+
};
|
|
4894
|
+
};
|
|
4895
|
+
type WebSearchOptions = {
|
|
4896
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4897
|
+
user_location?: WebSearchUserLocation;
|
|
4898
|
+
};
|
|
4899
|
+
type ChatTemplateKwargs = {
|
|
4900
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4901
|
+
enable_thinking?: boolean;
|
|
4902
|
+
/** If false, preserves reasoning context between turns. */
|
|
4903
|
+
clear_thinking?: boolean;
|
|
4904
|
+
};
|
|
4905
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4906
|
+
type ChatCompletionsCommonOptions = {
|
|
4907
|
+
model?: string;
|
|
4908
|
+
audio?: AudioParams;
|
|
4909
|
+
frequency_penalty?: number | null;
|
|
4910
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4911
|
+
logprobs?: boolean | null;
|
|
4912
|
+
top_logprobs?: number | null;
|
|
4913
|
+
max_tokens?: number | null;
|
|
4914
|
+
max_completion_tokens?: number | null;
|
|
4915
|
+
metadata?: Record<string, unknown> | null;
|
|
4916
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4917
|
+
n?: number | null;
|
|
4918
|
+
parallel_tool_calls?: boolean;
|
|
4919
|
+
prediction?: PredictionContent;
|
|
4920
|
+
presence_penalty?: number | null;
|
|
4921
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4922
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4923
|
+
response_format?: ResponseFormat;
|
|
4924
|
+
seed?: number | null;
|
|
4925
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4926
|
+
stop?: string | Array<string> | null;
|
|
4927
|
+
store?: boolean | null;
|
|
4928
|
+
stream?: boolean | null;
|
|
4929
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4930
|
+
temperature?: number | null;
|
|
4931
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4932
|
+
tools?: Array<ChatCompletionTool>;
|
|
4933
|
+
top_p?: number | null;
|
|
4934
|
+
user?: string;
|
|
4935
|
+
web_search_options?: WebSearchOptions;
|
|
4936
|
+
function_call?:
|
|
4937
|
+
| "none"
|
|
4938
|
+
| "auto"
|
|
4939
|
+
| {
|
|
4940
|
+
name: string;
|
|
4941
|
+
};
|
|
4942
|
+
functions?: Array<FunctionDefinition>;
|
|
4943
|
+
};
|
|
4944
|
+
type PromptTokensDetails = {
|
|
4945
|
+
cached_tokens?: number;
|
|
4946
|
+
audio_tokens?: number;
|
|
4947
|
+
};
|
|
4948
|
+
type CompletionTokensDetails = {
|
|
4949
|
+
reasoning_tokens?: number;
|
|
4950
|
+
audio_tokens?: number;
|
|
4951
|
+
accepted_prediction_tokens?: number;
|
|
4952
|
+
rejected_prediction_tokens?: number;
|
|
4953
|
+
};
|
|
4954
|
+
type CompletionUsage = {
|
|
4955
|
+
prompt_tokens: number;
|
|
4956
|
+
completion_tokens: number;
|
|
4957
|
+
total_tokens: number;
|
|
4958
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4959
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4960
|
+
};
|
|
4961
|
+
type ChatCompletionTopLogprob = {
|
|
4962
|
+
token: string;
|
|
4963
|
+
logprob: number;
|
|
4964
|
+
bytes: Array<number> | null;
|
|
4965
|
+
};
|
|
4966
|
+
type ChatCompletionTokenLogprob = {
|
|
4967
|
+
token: string;
|
|
4968
|
+
logprob: number;
|
|
4969
|
+
bytes: Array<number> | null;
|
|
4970
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4971
|
+
};
|
|
4972
|
+
type ChatCompletionAudio = {
|
|
4973
|
+
id: string;
|
|
4974
|
+
/** Base64 encoded audio bytes. */
|
|
4975
|
+
data: string;
|
|
4976
|
+
expires_at: number;
|
|
4977
|
+
transcript: string;
|
|
4978
|
+
};
|
|
4979
|
+
type ChatCompletionUrlCitation = {
|
|
4980
|
+
type: "url_citation";
|
|
4981
|
+
url_citation: {
|
|
4982
|
+
url: string;
|
|
4983
|
+
title: string;
|
|
4984
|
+
start_index: number;
|
|
4985
|
+
end_index: number;
|
|
4986
|
+
};
|
|
4987
|
+
};
|
|
4988
|
+
type ChatCompletionResponseMessage = {
|
|
4989
|
+
role: "assistant";
|
|
4990
|
+
content: string | null;
|
|
4991
|
+
refusal: string | null;
|
|
4992
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
4993
|
+
audio?: ChatCompletionAudio;
|
|
4994
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4995
|
+
function_call?: {
|
|
4996
|
+
name: string;
|
|
4997
|
+
arguments: string;
|
|
4998
|
+
} | null;
|
|
4999
|
+
};
|
|
5000
|
+
type ChatCompletionLogprobs = {
|
|
5001
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
5002
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
5003
|
+
};
|
|
5004
|
+
type ChatCompletionChoice = {
|
|
5005
|
+
index: number;
|
|
5006
|
+
message: ChatCompletionResponseMessage;
|
|
5007
|
+
finish_reason:
|
|
5008
|
+
| "stop"
|
|
5009
|
+
| "length"
|
|
5010
|
+
| "tool_calls"
|
|
5011
|
+
| "content_filter"
|
|
5012
|
+
| "function_call";
|
|
5013
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
5014
|
+
};
|
|
5015
|
+
type ChatCompletionsPromptInput = {
|
|
5016
|
+
prompt: string;
|
|
5017
|
+
} & ChatCompletionsCommonOptions;
|
|
5018
|
+
type ChatCompletionsMessagesInput = {
|
|
5019
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
5020
|
+
} & ChatCompletionsCommonOptions;
|
|
5021
|
+
type ChatCompletionsOutput = {
|
|
5022
|
+
id: string;
|
|
5023
|
+
object: string;
|
|
5024
|
+
created: number;
|
|
5025
|
+
model: string;
|
|
5026
|
+
choices: Array<ChatCompletionChoice>;
|
|
5027
|
+
usage?: CompletionUsage;
|
|
5028
|
+
system_fingerprint?: string | null;
|
|
5029
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
5030
|
+
};
|
|
4328
5031
|
/**
|
|
4329
5032
|
* Workers AI support for OpenAI's Responses API
|
|
4330
5033
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4746,6 +5449,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4746
5449
|
type StreamOptions = {
|
|
4747
5450
|
include_obfuscation?: boolean;
|
|
4748
5451
|
};
|
|
5452
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5453
|
+
type Without<T, U> = {
|
|
5454
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5455
|
+
};
|
|
5456
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5457
|
+
type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4749
5458
|
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4750
5459
|
| {
|
|
4751
5460
|
text: string | string[];
|
|
@@ -5038,10 +5747,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5038
5747
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5039
5748
|
}
|
|
5040
5749
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5750
|
+
audio:
|
|
5751
|
+
| string
|
|
5752
|
+
| {
|
|
5753
|
+
body?: object;
|
|
5754
|
+
contentType?: string;
|
|
5755
|
+
};
|
|
5045
5756
|
/**
|
|
5046
5757
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5047
5758
|
*/
|
|
@@ -5059,9 +5770,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5059
5770
|
*/
|
|
5060
5771
|
initial_prompt?: string;
|
|
5061
5772
|
/**
|
|
5062
|
-
* The prefix
|
|
5773
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5063
5774
|
*/
|
|
5064
5775
|
prefix?: string;
|
|
5776
|
+
/**
|
|
5777
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5778
|
+
*/
|
|
5779
|
+
beam_size?: number;
|
|
5780
|
+
/**
|
|
5781
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5782
|
+
*/
|
|
5783
|
+
condition_on_previous_text?: boolean;
|
|
5784
|
+
/**
|
|
5785
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5786
|
+
*/
|
|
5787
|
+
no_speech_threshold?: number;
|
|
5788
|
+
/**
|
|
5789
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5790
|
+
*/
|
|
5791
|
+
compression_ratio_threshold?: number;
|
|
5792
|
+
/**
|
|
5793
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5794
|
+
*/
|
|
5795
|
+
log_prob_threshold?: number;
|
|
5796
|
+
/**
|
|
5797
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5798
|
+
*/
|
|
5799
|
+
hallucination_silence_threshold?: number;
|
|
5065
5800
|
}
|
|
5066
5801
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5067
5802
|
transcription_info?: {
|
|
@@ -5208,11 +5943,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5208
5943
|
truncate_inputs?: boolean;
|
|
5209
5944
|
}
|
|
5210
5945
|
type Ai_Cf_Baai_Bge_M3_Output =
|
|
5211
|
-
|
|
|
5946
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5212
5947
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5213
|
-
|
|
|
5948
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5214
5949
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5215
|
-
interface
|
|
5950
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5216
5951
|
response?: {
|
|
5217
5952
|
/**
|
|
5218
5953
|
* Index of the context in the request
|
|
@@ -5232,7 +5967,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5232
5967
|
*/
|
|
5233
5968
|
pooling?: "mean" | "cls";
|
|
5234
5969
|
}
|
|
5235
|
-
interface
|
|
5970
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5236
5971
|
shape?: number[];
|
|
5237
5972
|
/**
|
|
5238
5973
|
* Embeddings of the requested text values
|
|
@@ -5337,7 +6072,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5337
6072
|
*/
|
|
5338
6073
|
role?: string;
|
|
5339
6074
|
/**
|
|
5340
|
-
* The tool call id.
|
|
6075
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5341
6076
|
*/
|
|
5342
6077
|
tool_call_id?: string;
|
|
5343
6078
|
content?:
|
|
@@ -5592,10 +6327,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5592
6327
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5593
6328
|
*/
|
|
5594
6329
|
role: string;
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
6330
|
+
content:
|
|
6331
|
+
| string
|
|
6332
|
+
| {
|
|
6333
|
+
/**
|
|
6334
|
+
* Type of the content (text)
|
|
6335
|
+
*/
|
|
6336
|
+
type?: string;
|
|
6337
|
+
/**
|
|
6338
|
+
* Text content
|
|
6339
|
+
*/
|
|
6340
|
+
text?: string;
|
|
6341
|
+
}[];
|
|
5599
6342
|
}[];
|
|
5600
6343
|
functions?: {
|
|
5601
6344
|
name: string;
|
|
@@ -6251,7 +6994,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6251
6994
|
*/
|
|
6252
6995
|
role?: string;
|
|
6253
6996
|
/**
|
|
6254
|
-
* The tool call id.
|
|
6997
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6255
6998
|
*/
|
|
6256
6999
|
tool_call_id?: string;
|
|
6257
7000
|
content?:
|
|
@@ -6378,7 +7121,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6378
7121
|
}
|
|
6379
7122
|
)[];
|
|
6380
7123
|
/**
|
|
6381
|
-
* JSON schema that should be
|
|
7124
|
+
* JSON schema that should be fufilled for the response.
|
|
6382
7125
|
*/
|
|
6383
7126
|
guided_json?: object;
|
|
6384
7127
|
/**
|
|
@@ -6652,7 +7395,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6652
7395
|
}
|
|
6653
7396
|
)[];
|
|
6654
7397
|
/**
|
|
6655
|
-
* JSON schema that should be
|
|
7398
|
+
* JSON schema that should be fufilled for the response.
|
|
6656
7399
|
*/
|
|
6657
7400
|
guided_json?: object;
|
|
6658
7401
|
/**
|
|
@@ -6745,7 +7488,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6745
7488
|
*/
|
|
6746
7489
|
prompt: string;
|
|
6747
7490
|
/**
|
|
6748
|
-
* JSON schema that should be
|
|
7491
|
+
* JSON schema that should be fufilled for the response.
|
|
6749
7492
|
*/
|
|
6750
7493
|
guided_json?: object;
|
|
6751
7494
|
/**
|
|
@@ -6909,7 +7652,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6909
7652
|
}
|
|
6910
7653
|
)[];
|
|
6911
7654
|
/**
|
|
6912
|
-
* JSON schema that should be
|
|
7655
|
+
* JSON schema that should be fufilled for the response.
|
|
6913
7656
|
*/
|
|
6914
7657
|
guided_json?: object;
|
|
6915
7658
|
/**
|
|
@@ -7190,7 +7933,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7190
7933
|
)[];
|
|
7191
7934
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7192
7935
|
/**
|
|
7193
|
-
* JSON schema that should be
|
|
7936
|
+
* JSON schema that should be fufilled for the response.
|
|
7194
7937
|
*/
|
|
7195
7938
|
guided_json?: object;
|
|
7196
7939
|
/**
|
|
@@ -7429,7 +8172,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7429
8172
|
)[];
|
|
7430
8173
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7431
8174
|
/**
|
|
7432
|
-
* JSON schema that should be
|
|
8175
|
+
* JSON schema that should be fufilled for the response.
|
|
7433
8176
|
*/
|
|
7434
8177
|
guided_json?: object;
|
|
7435
8178
|
/**
|
|
@@ -7594,10 +8337,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7594
8337
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7595
8338
|
*/
|
|
7596
8339
|
role: string;
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
8340
|
+
content:
|
|
8341
|
+
| string
|
|
8342
|
+
| {
|
|
8343
|
+
/**
|
|
8344
|
+
* Type of the content (text)
|
|
8345
|
+
*/
|
|
8346
|
+
type?: string;
|
|
8347
|
+
/**
|
|
8348
|
+
* Text content
|
|
8349
|
+
*/
|
|
8350
|
+
text?: string;
|
|
8351
|
+
}[];
|
|
7601
8352
|
}[];
|
|
7602
8353
|
functions?: {
|
|
7603
8354
|
name: string;
|
|
@@ -7809,10 +8560,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7809
8560
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7810
8561
|
*/
|
|
7811
8562
|
role: string;
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
8563
|
+
content:
|
|
8564
|
+
| string
|
|
8565
|
+
| {
|
|
8566
|
+
/**
|
|
8567
|
+
* Type of the content (text)
|
|
8568
|
+
*/
|
|
8569
|
+
type?: string;
|
|
8570
|
+
/**
|
|
8571
|
+
* Text content
|
|
8572
|
+
*/
|
|
8573
|
+
text?: string;
|
|
8574
|
+
}[];
|
|
7816
8575
|
}[];
|
|
7817
8576
|
functions?: {
|
|
7818
8577
|
name: string;
|
|
@@ -8380,12 +9139,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8380
9139
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8381
9140
|
}
|
|
8382
9141
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8383
|
-
inputs: ResponsesInput
|
|
8384
|
-
postProcessedOutputs: ResponsesOutput
|
|
9142
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9143
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8385
9144
|
}
|
|
8386
9145
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8387
|
-
inputs: ResponsesInput
|
|
8388
|
-
postProcessedOutputs: ResponsesOutput
|
|
9146
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9147
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8389
9148
|
}
|
|
8390
9149
|
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8391
9150
|
/**
|
|
@@ -8517,7 +9276,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8517
9276
|
*/
|
|
8518
9277
|
text: string | string[];
|
|
8519
9278
|
/**
|
|
8520
|
-
* Target
|
|
9279
|
+
* Target langauge to translate to
|
|
8521
9280
|
*/
|
|
8522
9281
|
target_language:
|
|
8523
9282
|
| "asm_Beng"
|
|
@@ -8633,10 +9392,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8633
9392
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8634
9393
|
*/
|
|
8635
9394
|
role: string;
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
9395
|
+
content:
|
|
9396
|
+
| string
|
|
9397
|
+
| {
|
|
9398
|
+
/**
|
|
9399
|
+
* Type of the content (text)
|
|
9400
|
+
*/
|
|
9401
|
+
type?: string;
|
|
9402
|
+
/**
|
|
9403
|
+
* Text content
|
|
9404
|
+
*/
|
|
9405
|
+
text?: string;
|
|
9406
|
+
}[];
|
|
8640
9407
|
}[];
|
|
8641
9408
|
functions?: {
|
|
8642
9409
|
name: string;
|
|
@@ -8848,10 +9615,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8848
9615
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8849
9616
|
*/
|
|
8850
9617
|
role: string;
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
9618
|
+
content:
|
|
9619
|
+
| string
|
|
9620
|
+
| {
|
|
9621
|
+
/**
|
|
9622
|
+
* Type of the content (text)
|
|
9623
|
+
*/
|
|
9624
|
+
type?: string;
|
|
9625
|
+
/**
|
|
9626
|
+
* Text content
|
|
9627
|
+
*/
|
|
9628
|
+
text?: string;
|
|
9629
|
+
}[];
|
|
8855
9630
|
}[];
|
|
8856
9631
|
functions?: {
|
|
8857
9632
|
name: string;
|
|
@@ -9406,6 +10181,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9406
10181
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9407
10182
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9408
10183
|
}
|
|
10184
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10185
|
+
multipart: {
|
|
10186
|
+
body?: object;
|
|
10187
|
+
contentType?: string;
|
|
10188
|
+
};
|
|
10189
|
+
}
|
|
10190
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10191
|
+
/**
|
|
10192
|
+
* Generated image as Base64 string.
|
|
10193
|
+
*/
|
|
10194
|
+
image?: string;
|
|
10195
|
+
}
|
|
10196
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10197
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10198
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10199
|
+
}
|
|
10200
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10201
|
+
multipart: {
|
|
10202
|
+
body?: object;
|
|
10203
|
+
contentType?: string;
|
|
10204
|
+
};
|
|
10205
|
+
}
|
|
10206
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10207
|
+
/**
|
|
10208
|
+
* Generated image as Base64 string.
|
|
10209
|
+
*/
|
|
10210
|
+
image?: string;
|
|
10211
|
+
}
|
|
10212
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10213
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10214
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10215
|
+
}
|
|
10216
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10217
|
+
multipart: {
|
|
10218
|
+
body?: object;
|
|
10219
|
+
contentType?: string;
|
|
10220
|
+
};
|
|
10221
|
+
}
|
|
10222
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10223
|
+
/**
|
|
10224
|
+
* Generated image as Base64 string.
|
|
10225
|
+
*/
|
|
10226
|
+
image?: string;
|
|
10227
|
+
}
|
|
10228
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10229
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10230
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10231
|
+
}
|
|
10232
|
+
declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10233
|
+
inputs: ChatCompletionsInput;
|
|
10234
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10235
|
+
}
|
|
10236
|
+
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10237
|
+
inputs: ChatCompletionsInput;
|
|
10238
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10239
|
+
}
|
|
10240
|
+
declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10241
|
+
inputs: ChatCompletionsInput;
|
|
10242
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10243
|
+
}
|
|
9409
10244
|
interface AiModels {
|
|
9410
10245
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9411
10246
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9424,7 +10259,6 @@ interface AiModels {
|
|
|
9424
10259
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9425
10260
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9426
10261
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9427
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9428
10262
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9429
10263
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9430
10264
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9491,6 +10325,12 @@ interface AiModels {
|
|
|
9491
10325
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9492
10326
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9493
10327
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10328
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10329
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10330
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10331
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10332
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10333
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9494
10334
|
}
|
|
9495
10335
|
type AiOptions = {
|
|
9496
10336
|
/**
|
|
@@ -9516,6 +10356,7 @@ type AiOptions = {
|
|
|
9516
10356
|
returnRawResponse?: boolean;
|
|
9517
10357
|
prefix?: string;
|
|
9518
10358
|
extraHeaders?: object;
|
|
10359
|
+
signal?: AbortSignal;
|
|
9519
10360
|
};
|
|
9520
10361
|
type AiModelsSearchParams = {
|
|
9521
10362
|
author?: string;
|
|
@@ -9542,6 +10383,16 @@ type AiModelsSearchObject = {
|
|
|
9542
10383
|
value: string;
|
|
9543
10384
|
}[];
|
|
9544
10385
|
};
|
|
10386
|
+
type ChatCompletionsBase = XOR<
|
|
10387
|
+
ChatCompletionsPromptInput,
|
|
10388
|
+
ChatCompletionsMessagesInput
|
|
10389
|
+
>;
|
|
10390
|
+
type ChatCompletionsInput = XOR<
|
|
10391
|
+
ChatCompletionsBase,
|
|
10392
|
+
{
|
|
10393
|
+
requests: ChatCompletionsBase[];
|
|
10394
|
+
}
|
|
10395
|
+
>;
|
|
9545
10396
|
interface InferenceUpstreamError extends Error {}
|
|
9546
10397
|
interface AiInternalError extends Error {}
|
|
9547
10398
|
type AiModelListType = Record<string, any>;
|
|
@@ -9549,46 +10400,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
9549
10400
|
aiGatewayLogId: string | null;
|
|
9550
10401
|
gateway(gatewayId: string): AiGateway;
|
|
9551
10402
|
/**
|
|
9552
|
-
*
|
|
9553
|
-
*
|
|
9554
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9555
|
-
* - Account-level operations: `list()`, `create()`
|
|
9556
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9557
|
-
*
|
|
9558
|
-
* @example
|
|
9559
|
-
* ```typescript
|
|
9560
|
-
* // List all AI Search instances
|
|
9561
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9562
|
-
*
|
|
9563
|
-
* // Search an instance
|
|
9564
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9565
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9566
|
-
* ai_search_options: {
|
|
9567
|
-
* retrieval: { max_num_results: 10 }
|
|
9568
|
-
* }
|
|
9569
|
-
* });
|
|
9570
|
-
*
|
|
9571
|
-
* // Generate chat completions with AI Search context
|
|
9572
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9573
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9574
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9575
|
-
* });
|
|
9576
|
-
* ```
|
|
10403
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10404
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9577
10405
|
*/
|
|
9578
|
-
aiSearch():
|
|
10406
|
+
aiSearch(): AiSearchNamespace;
|
|
9579
10407
|
/**
|
|
9580
10408
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9581
|
-
* Use `
|
|
9582
|
-
*
|
|
9583
|
-
* Migration guide:
|
|
9584
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9585
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9586
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10409
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10410
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9587
10411
|
*
|
|
9588
|
-
*
|
|
9589
|
-
*
|
|
9590
|
-
* @see AiSearchAccountService
|
|
9591
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10412
|
+
* @param autoragId Instance ID
|
|
9592
10413
|
*/
|
|
9593
10414
|
autorag(autoragId: string): AutoRAG;
|
|
9594
10415
|
run<
|
|
@@ -9747,22 +10568,23 @@ declare abstract class AiGateway {
|
|
|
9747
10568
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9748
10569
|
}
|
|
9749
10570
|
/**
|
|
9750
|
-
* @deprecated
|
|
9751
|
-
*
|
|
10571
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10572
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9752
10573
|
*/
|
|
9753
10574
|
interface AutoRAGInternalError extends Error {}
|
|
9754
10575
|
/**
|
|
9755
|
-
* @deprecated
|
|
9756
|
-
*
|
|
10576
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10577
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9757
10578
|
*/
|
|
9758
10579
|
interface AutoRAGNotFoundError extends Error {}
|
|
9759
10580
|
/**
|
|
9760
|
-
* @deprecated
|
|
10581
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10582
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9761
10583
|
*/
|
|
9762
10584
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
9763
10585
|
/**
|
|
9764
|
-
* @deprecated
|
|
9765
|
-
*
|
|
10586
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10587
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9766
10588
|
*/
|
|
9767
10589
|
interface AutoRAGNameNotSetError extends Error {}
|
|
9768
10590
|
type ComparisonFilter = {
|
|
@@ -9775,9 +10597,8 @@ type CompoundFilter = {
|
|
|
9775
10597
|
filters: ComparisonFilter[];
|
|
9776
10598
|
};
|
|
9777
10599
|
/**
|
|
9778
|
-
* @deprecated
|
|
9779
|
-
*
|
|
9780
|
-
* @see AiSearchSearchRequest
|
|
10600
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10601
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9781
10602
|
*/
|
|
9782
10603
|
type AutoRagSearchRequest = {
|
|
9783
10604
|
query: string;
|
|
@@ -9794,18 +10615,16 @@ type AutoRagSearchRequest = {
|
|
|
9794
10615
|
rewrite_query?: boolean;
|
|
9795
10616
|
};
|
|
9796
10617
|
/**
|
|
9797
|
-
* @deprecated
|
|
9798
|
-
*
|
|
9799
|
-
* @see AiSearchChatCompletionsRequest
|
|
10618
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10619
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9800
10620
|
*/
|
|
9801
10621
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9802
10622
|
stream?: boolean;
|
|
9803
10623
|
system_prompt?: string;
|
|
9804
10624
|
};
|
|
9805
10625
|
/**
|
|
9806
|
-
* @deprecated
|
|
9807
|
-
*
|
|
9808
|
-
* @see AiSearchChatCompletionsRequest
|
|
10626
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10627
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9809
10628
|
*/
|
|
9810
10629
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
9811
10630
|
AutoRagAiSearchRequest,
|
|
@@ -9814,9 +10633,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9814
10633
|
stream: true;
|
|
9815
10634
|
};
|
|
9816
10635
|
/**
|
|
9817
|
-
* @deprecated
|
|
9818
|
-
*
|
|
9819
|
-
* @see AiSearchSearchResponse
|
|
10636
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10637
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9820
10638
|
*/
|
|
9821
10639
|
type AutoRagSearchResponse = {
|
|
9822
10640
|
object: "vector_store.search_results.page";
|
|
@@ -9835,9 +10653,8 @@ type AutoRagSearchResponse = {
|
|
|
9835
10653
|
next_page: string | null;
|
|
9836
10654
|
};
|
|
9837
10655
|
/**
|
|
9838
|
-
* @deprecated
|
|
9839
|
-
*
|
|
9840
|
-
* @see AiSearchListResponse
|
|
10656
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10657
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9841
10658
|
*/
|
|
9842
10659
|
type AutoRagListResponse = {
|
|
9843
10660
|
id: string;
|
|
@@ -9849,49 +10666,40 @@ type AutoRagListResponse = {
|
|
|
9849
10666
|
status: string;
|
|
9850
10667
|
}[];
|
|
9851
10668
|
/**
|
|
9852
|
-
* @deprecated
|
|
9853
|
-
*
|
|
10669
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10670
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9854
10671
|
*/
|
|
9855
10672
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9856
10673
|
response: string;
|
|
9857
10674
|
};
|
|
9858
10675
|
/**
|
|
9859
|
-
* @deprecated
|
|
9860
|
-
*
|
|
9861
|
-
*
|
|
9862
|
-
* Migration guide:
|
|
9863
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9864
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9865
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9866
|
-
*
|
|
9867
|
-
* @see AiSearchAccountService
|
|
9868
|
-
* @see AiSearchInstanceService
|
|
10676
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10677
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9869
10678
|
*/
|
|
9870
10679
|
declare abstract class AutoRAG {
|
|
9871
10680
|
/**
|
|
9872
|
-
* @deprecated Use
|
|
9873
|
-
*
|
|
10681
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10682
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9874
10683
|
*/
|
|
9875
10684
|
list(): Promise<AutoRagListResponse>;
|
|
9876
10685
|
/**
|
|
9877
|
-
* @deprecated Use
|
|
9878
|
-
*
|
|
9879
|
-
* @see AiSearchInstanceService.search
|
|
10686
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10687
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9880
10688
|
*/
|
|
9881
10689
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9882
10690
|
/**
|
|
9883
|
-
* @deprecated Use
|
|
9884
|
-
*
|
|
10691
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10692
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9885
10693
|
*/
|
|
9886
10694
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9887
10695
|
/**
|
|
9888
|
-
* @deprecated Use
|
|
9889
|
-
*
|
|
10696
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10697
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9890
10698
|
*/
|
|
9891
10699
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9892
10700
|
/**
|
|
9893
|
-
* @deprecated Use
|
|
9894
|
-
*
|
|
10701
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10702
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9895
10703
|
*/
|
|
9896
10704
|
aiSearch(
|
|
9897
10705
|
params: AutoRagAiSearchRequest,
|
|
@@ -10016,6 +10824,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
10016
10824
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
10017
10825
|
*/
|
|
10018
10826
|
cacheTtlByStatus?: Record<string, number>;
|
|
10827
|
+
/**
|
|
10828
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10829
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10830
|
+
*
|
|
10831
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10832
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10833
|
+
*
|
|
10834
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10835
|
+
*/
|
|
10836
|
+
cacheControl?: string;
|
|
10837
|
+
/**
|
|
10838
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10839
|
+
*/
|
|
10840
|
+
cacheReserveEligible?: boolean;
|
|
10841
|
+
/**
|
|
10842
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10843
|
+
*/
|
|
10844
|
+
respectStrongEtag?: boolean;
|
|
10845
|
+
/**
|
|
10846
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10847
|
+
*/
|
|
10848
|
+
stripEtags?: boolean;
|
|
10849
|
+
/**
|
|
10850
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10851
|
+
*/
|
|
10852
|
+
stripLastModified?: boolean;
|
|
10853
|
+
/**
|
|
10854
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10855
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10856
|
+
*/
|
|
10857
|
+
cacheDeceptionArmor?: boolean;
|
|
10858
|
+
/**
|
|
10859
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10860
|
+
*/
|
|
10861
|
+
cacheReserveMinimumFileSize?: number;
|
|
10019
10862
|
scrapeShield?: boolean;
|
|
10020
10863
|
apps?: boolean;
|
|
10021
10864
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11928,6 +12771,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11928
12771
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11929
12772
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11930
12773
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12774
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11931
12775
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11932
12776
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11933
12777
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11948,6 +12792,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11948
12792
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11949
12793
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11950
12794
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12795
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11951
12796
|
webSocketMessage?(
|
|
11952
12797
|
ws: WebSocket,
|
|
11953
12798
|
message: string | ArrayBuffer,
|
|
@@ -12098,17 +12943,6 @@ interface StreamBinding {
|
|
|
12098
12943
|
* @returns A handle for per-video operations.
|
|
12099
12944
|
*/
|
|
12100
12945
|
video(id: string): StreamVideoHandle;
|
|
12101
|
-
/**
|
|
12102
|
-
* Uploads a new video from a File.
|
|
12103
|
-
* @param file The video file to upload.
|
|
12104
|
-
* @returns The uploaded video details.
|
|
12105
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12106
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12107
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12108
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12109
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12110
|
-
*/
|
|
12111
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12112
12946
|
/**
|
|
12113
12947
|
* Uploads a new video from a provided URL.
|
|
12114
12948
|
* @param url The URL to upload from.
|
|
@@ -12958,6 +13792,9 @@ declare namespace TailStream {
|
|
|
12958
13792
|
readonly type: "fetch";
|
|
12959
13793
|
readonly statusCode: number;
|
|
12960
13794
|
}
|
|
13795
|
+
interface ConnectEventInfo {
|
|
13796
|
+
readonly type: "connect";
|
|
13797
|
+
}
|
|
12961
13798
|
type EventOutcome =
|
|
12962
13799
|
| "ok"
|
|
12963
13800
|
| "canceled"
|
|
@@ -12988,6 +13825,7 @@ declare namespace TailStream {
|
|
|
12988
13825
|
readonly scriptVersion?: ScriptVersion;
|
|
12989
13826
|
readonly info:
|
|
12990
13827
|
| FetchEventInfo
|
|
13828
|
+
| ConnectEventInfo
|
|
12991
13829
|
| JsRpcEventInfo
|
|
12992
13830
|
| ScheduledEventInfo
|
|
12993
13831
|
| AlarmEventInfo
|