@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/latest/index.ts
CHANGED
|
@@ -491,6 +491,11 @@ export type ExportedHandlerFetchHandler<
|
|
|
491
491
|
env: Env,
|
|
492
492
|
ctx: ExecutionContext<Props>,
|
|
493
493
|
) => Response | Promise<Response>;
|
|
494
|
+
export type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
|
|
495
|
+
socket: Socket,
|
|
496
|
+
env: Env,
|
|
497
|
+
ctx: ExecutionContext<Props>,
|
|
498
|
+
) => void | Promise<void>;
|
|
494
499
|
export type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
|
|
495
500
|
events: TraceItem[],
|
|
496
501
|
env: Env,
|
|
@@ -532,6 +537,7 @@ export interface ExportedHandler<
|
|
|
532
537
|
Props = unknown,
|
|
533
538
|
> {
|
|
534
539
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
|
|
540
|
+
connect?: ExportedHandlerConnectHandler<Env, Props>;
|
|
535
541
|
tail?: ExportedHandlerTailHandler<Env, Props>;
|
|
536
542
|
trace?: ExportedHandlerTraceHandler<Env, Props>;
|
|
537
543
|
tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
|
|
@@ -553,12 +559,14 @@ export declare abstract class Navigator {
|
|
|
553
559
|
export interface AlarmInvocationInfo {
|
|
554
560
|
readonly isRetry: boolean;
|
|
555
561
|
readonly retryCount: number;
|
|
562
|
+
readonly scheduledTime: number;
|
|
556
563
|
}
|
|
557
564
|
export interface Cloudflare {
|
|
558
565
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
559
566
|
}
|
|
560
567
|
export interface DurableObject {
|
|
561
568
|
fetch(request: Request): Response | Promise<Response>;
|
|
569
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
562
570
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
563
571
|
webSocketMessage?(
|
|
564
572
|
ws: WebSocket,
|
|
@@ -576,7 +584,7 @@ export type DurableObjectStub<
|
|
|
576
584
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
577
585
|
> = Fetcher<
|
|
578
586
|
T,
|
|
579
|
-
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
587
|
+
"alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
580
588
|
> & {
|
|
581
589
|
readonly id: DurableObjectId;
|
|
582
590
|
readonly name?: string;
|
|
@@ -585,6 +593,7 @@ export interface DurableObjectId {
|
|
|
585
593
|
toString(): string;
|
|
586
594
|
equals(other: DurableObjectId): boolean;
|
|
587
595
|
readonly name?: string;
|
|
596
|
+
readonly jurisdiction?: string;
|
|
588
597
|
}
|
|
589
598
|
export declare abstract class DurableObjectNamespace<
|
|
590
599
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
@@ -3112,6 +3121,11 @@ export interface QueuingStrategyInit {
|
|
|
3112
3121
|
*/
|
|
3113
3122
|
highWaterMark: number;
|
|
3114
3123
|
}
|
|
3124
|
+
export interface TracePreviewInfo {
|
|
3125
|
+
id: string;
|
|
3126
|
+
slug: string;
|
|
3127
|
+
name: string;
|
|
3128
|
+
}
|
|
3115
3129
|
export interface ScriptVersion {
|
|
3116
3130
|
id?: string;
|
|
3117
3131
|
tag?: string;
|
|
@@ -3126,6 +3140,7 @@ export interface TraceItem {
|
|
|
3126
3140
|
| (
|
|
3127
3141
|
| TraceItemFetchEventInfo
|
|
3128
3142
|
| TraceItemJsRpcEventInfo
|
|
3143
|
+
| TraceItemConnectEventInfo
|
|
3129
3144
|
| TraceItemScheduledEventInfo
|
|
3130
3145
|
| TraceItemAlarmEventInfo
|
|
3131
3146
|
| TraceItemQueueEventInfo
|
|
@@ -3144,6 +3159,8 @@ export interface TraceItem {
|
|
|
3144
3159
|
readonly scriptVersion?: ScriptVersion;
|
|
3145
3160
|
readonly dispatchNamespace?: string;
|
|
3146
3161
|
readonly scriptTags?: string[];
|
|
3162
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3163
|
+
readonly preview?: TracePreviewInfo;
|
|
3147
3164
|
readonly durableObjectId?: string;
|
|
3148
3165
|
readonly outcome: string;
|
|
3149
3166
|
readonly executionModel: string;
|
|
@@ -3154,6 +3171,7 @@ export interface TraceItem {
|
|
|
3154
3171
|
export interface TraceItemAlarmEventInfo {
|
|
3155
3172
|
readonly scheduledTime: Date;
|
|
3156
3173
|
}
|
|
3174
|
+
export interface TraceItemConnectEventInfo {}
|
|
3157
3175
|
export interface TraceItemCustomEventInfo {}
|
|
3158
3176
|
export interface TraceItemScheduledEventInfo {
|
|
3159
3177
|
readonly scheduledTime: number;
|
|
@@ -3775,7 +3793,7 @@ export interface ContainerStartupOptions {
|
|
|
3775
3793
|
entrypoint?: string[];
|
|
3776
3794
|
enableInternet: boolean;
|
|
3777
3795
|
env?: Record<string, string>;
|
|
3778
|
-
|
|
3796
|
+
labels?: Record<string, string>;
|
|
3779
3797
|
}
|
|
3780
3798
|
/**
|
|
3781
3799
|
* 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.
|
|
@@ -3922,11 +3940,10 @@ export declare abstract class Performance {
|
|
|
3922
3940
|
*/
|
|
3923
3941
|
toJSON(): object;
|
|
3924
3942
|
}
|
|
3925
|
-
// AI Search
|
|
3943
|
+
// ============ AI Search Error Interfaces ============
|
|
3926
3944
|
export interface AiSearchInternalError extends Error {}
|
|
3927
3945
|
export interface AiSearchNotFoundError extends Error {}
|
|
3928
|
-
|
|
3929
|
-
// AI Search V2 Request Types
|
|
3946
|
+
// ============ AI Search Request Types ============
|
|
3930
3947
|
export type AiSearchSearchRequest = {
|
|
3931
3948
|
messages: Array<{
|
|
3932
3949
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3951,9 +3968,8 @@ export type AiSearchSearchRequest = {
|
|
|
3951
3968
|
[key: string]: unknown;
|
|
3952
3969
|
};
|
|
3953
3970
|
reranking?: {
|
|
3954
|
-
/** Enable reranking (default false) */
|
|
3955
3971
|
enabled?: boolean;
|
|
3956
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3972
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3957
3973
|
/** Match threshold (0-1, default 0.4) */
|
|
3958
3974
|
match_threshold?: number;
|
|
3959
3975
|
[key: string]: unknown;
|
|
@@ -3965,6 +3981,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3965
3981
|
messages: Array<{
|
|
3966
3982
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3967
3983
|
content: string | null;
|
|
3984
|
+
[key: string]: unknown;
|
|
3968
3985
|
}>;
|
|
3969
3986
|
model?: string;
|
|
3970
3987
|
stream?: boolean;
|
|
@@ -3985,7 +4002,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3985
4002
|
};
|
|
3986
4003
|
reranking?: {
|
|
3987
4004
|
enabled?: boolean;
|
|
3988
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
4005
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3989
4006
|
match_threshold?: number;
|
|
3990
4007
|
[key: string]: unknown;
|
|
3991
4008
|
};
|
|
@@ -3993,7 +4010,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3993
4010
|
};
|
|
3994
4011
|
[key: string]: unknown;
|
|
3995
4012
|
};
|
|
3996
|
-
// AI Search
|
|
4013
|
+
// ============ AI Search Response Types ============
|
|
3997
4014
|
export type AiSearchSearchResponse = {
|
|
3998
4015
|
search_query: string;
|
|
3999
4016
|
chunks: Array<{
|
|
@@ -4012,26 +4029,65 @@ export type AiSearchSearchResponse = {
|
|
|
4012
4029
|
keyword_score?: number;
|
|
4013
4030
|
/** Vector similarity score (0-1) */
|
|
4014
4031
|
vector_score?: number;
|
|
4032
|
+
[key: string]: unknown;
|
|
4033
|
+
};
|
|
4034
|
+
}>;
|
|
4035
|
+
};
|
|
4036
|
+
export type AiSearchChatCompletionsResponse = {
|
|
4037
|
+
id?: string;
|
|
4038
|
+
object?: string;
|
|
4039
|
+
model?: string;
|
|
4040
|
+
choices: Array<{
|
|
4041
|
+
index?: number;
|
|
4042
|
+
message: {
|
|
4043
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4044
|
+
content: string | null;
|
|
4045
|
+
[key: string]: unknown;
|
|
4015
4046
|
};
|
|
4047
|
+
[key: string]: unknown;
|
|
4016
4048
|
}>;
|
|
4049
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4050
|
+
[key: string]: unknown;
|
|
4017
4051
|
};
|
|
4018
|
-
export type
|
|
4052
|
+
export type AiSearchStatsResponse = {
|
|
4053
|
+
queued?: number;
|
|
4054
|
+
running?: number;
|
|
4055
|
+
completed?: number;
|
|
4056
|
+
error?: number;
|
|
4057
|
+
skipped?: number;
|
|
4058
|
+
outdated?: number;
|
|
4059
|
+
last_activity?: string;
|
|
4060
|
+
};
|
|
4061
|
+
// ============ AI Search Instance Info Types ============
|
|
4062
|
+
export type AiSearchInstanceInfo = {
|
|
4019
4063
|
id: string;
|
|
4020
|
-
|
|
4021
|
-
account_id?: string;
|
|
4022
|
-
account_tag?: string;
|
|
4023
|
-
/** Whether the instance is enabled (default true) */
|
|
4024
|
-
enable?: boolean;
|
|
4025
|
-
type?: "r2" | "web-crawler";
|
|
4064
|
+
type?: "r2" | "web-crawler" | string;
|
|
4026
4065
|
source?: string;
|
|
4066
|
+
paused?: boolean;
|
|
4067
|
+
status?: string;
|
|
4068
|
+
namespace?: string;
|
|
4069
|
+
created_at?: string;
|
|
4070
|
+
modified_at?: string;
|
|
4027
4071
|
[key: string]: unknown;
|
|
4028
|
-
}
|
|
4072
|
+
};
|
|
4073
|
+
export type AiSearchListResponse = {
|
|
4074
|
+
result: AiSearchInstanceInfo[];
|
|
4075
|
+
result_info?: {
|
|
4076
|
+
count: number;
|
|
4077
|
+
page: number;
|
|
4078
|
+
per_page: number;
|
|
4079
|
+
total_count: number;
|
|
4080
|
+
};
|
|
4081
|
+
};
|
|
4082
|
+
// ============ AI Search Config Types ============
|
|
4029
4083
|
export type AiSearchConfig = {
|
|
4030
4084
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
4031
4085
|
id: string;
|
|
4032
|
-
type
|
|
4033
|
-
|
|
4034
|
-
|
|
4086
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4087
|
+
type?: "r2" | "web-crawler" | string;
|
|
4088
|
+
/** Source URL (required for web-crawler type). */
|
|
4089
|
+
source?: string;
|
|
4090
|
+
source_params?: unknown;
|
|
4035
4091
|
/** Token ID (UUID format) */
|
|
4036
4092
|
token_id?: string;
|
|
4037
4093
|
ai_gateway_id?: string;
|
|
@@ -4041,54 +4097,307 @@ export type AiSearchConfig = {
|
|
|
4041
4097
|
reranking?: boolean;
|
|
4042
4098
|
embedding_model?: string;
|
|
4043
4099
|
ai_search_model?: string;
|
|
4100
|
+
[key: string]: unknown;
|
|
4044
4101
|
};
|
|
4045
|
-
|
|
4102
|
+
// ============ AI Search Item Types ============
|
|
4103
|
+
export type AiSearchItemInfo = {
|
|
4046
4104
|
id: string;
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4105
|
+
key: string;
|
|
4106
|
+
status:
|
|
4107
|
+
| "completed"
|
|
4108
|
+
| "error"
|
|
4109
|
+
| "skipped"
|
|
4110
|
+
| "queued"
|
|
4111
|
+
| "processing"
|
|
4112
|
+
| "outdated";
|
|
4113
|
+
metadata?: Record<string, unknown>;
|
|
4050
4114
|
[key: string]: unknown;
|
|
4051
4115
|
};
|
|
4052
|
-
|
|
4053
|
-
|
|
4116
|
+
export type AiSearchItemContentResult = {
|
|
4117
|
+
body: ReadableStream;
|
|
4118
|
+
contentType: string;
|
|
4119
|
+
filename: string;
|
|
4120
|
+
size: number;
|
|
4121
|
+
};
|
|
4122
|
+
export type AiSearchUploadItemOptions = {
|
|
4123
|
+
metadata?: Record<string, unknown>;
|
|
4124
|
+
};
|
|
4125
|
+
export type AiSearchListItemsParams = {
|
|
4126
|
+
page?: number;
|
|
4127
|
+
per_page?: number;
|
|
4128
|
+
};
|
|
4129
|
+
export type AiSearchListItemsResponse = {
|
|
4130
|
+
result: AiSearchItemInfo[];
|
|
4131
|
+
result_info?: {
|
|
4132
|
+
count: number;
|
|
4133
|
+
page: number;
|
|
4134
|
+
per_page: number;
|
|
4135
|
+
total_count: number;
|
|
4136
|
+
};
|
|
4137
|
+
};
|
|
4138
|
+
// ============ AI Search Job Types ============
|
|
4139
|
+
export type AiSearchJobInfo = {
|
|
4140
|
+
id: string;
|
|
4141
|
+
source: "user" | "schedule";
|
|
4142
|
+
description?: string;
|
|
4143
|
+
last_seen_at?: string;
|
|
4144
|
+
started_at?: string;
|
|
4145
|
+
ended_at?: string;
|
|
4146
|
+
end_reason?: string;
|
|
4147
|
+
};
|
|
4148
|
+
export type AiSearchJobLog = {
|
|
4149
|
+
id: number;
|
|
4150
|
+
message: string;
|
|
4151
|
+
message_type: number;
|
|
4152
|
+
created_at: number;
|
|
4153
|
+
};
|
|
4154
|
+
export type AiSearchCreateJobParams = {
|
|
4155
|
+
description?: string;
|
|
4156
|
+
};
|
|
4157
|
+
export type AiSearchListJobsParams = {
|
|
4158
|
+
page?: number;
|
|
4159
|
+
per_page?: number;
|
|
4160
|
+
};
|
|
4161
|
+
export type AiSearchListJobsResponse = {
|
|
4162
|
+
result: AiSearchJobInfo[];
|
|
4163
|
+
result_info?: {
|
|
4164
|
+
count: number;
|
|
4165
|
+
page: number;
|
|
4166
|
+
per_page: number;
|
|
4167
|
+
total_count: number;
|
|
4168
|
+
};
|
|
4169
|
+
};
|
|
4170
|
+
export type AiSearchJobLogsParams = {
|
|
4171
|
+
page?: number;
|
|
4172
|
+
per_page?: number;
|
|
4173
|
+
};
|
|
4174
|
+
export type AiSearchJobLogsResponse = {
|
|
4175
|
+
result: AiSearchJobLog[];
|
|
4176
|
+
result_info?: {
|
|
4177
|
+
count: number;
|
|
4178
|
+
page: number;
|
|
4179
|
+
per_page: number;
|
|
4180
|
+
total_count: number;
|
|
4181
|
+
};
|
|
4182
|
+
};
|
|
4183
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4184
|
+
/**
|
|
4185
|
+
* Single item service for an AI Search instance.
|
|
4186
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4187
|
+
*/
|
|
4188
|
+
export declare abstract class AiSearchItem {
|
|
4189
|
+
/** Get metadata about this item. */
|
|
4190
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4191
|
+
/**
|
|
4192
|
+
* Download the item's content.
|
|
4193
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4194
|
+
*/
|
|
4195
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4196
|
+
}
|
|
4197
|
+
/**
|
|
4198
|
+
* Items collection service for an AI Search instance.
|
|
4199
|
+
* Provides list, upload, and access to individual items.
|
|
4200
|
+
*/
|
|
4201
|
+
export declare abstract class AiSearchItems {
|
|
4202
|
+
/** List items in this instance. */
|
|
4203
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4204
|
+
/**
|
|
4205
|
+
* Upload a file as an item.
|
|
4206
|
+
* @param name Filename for the uploaded item.
|
|
4207
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4208
|
+
* @param options Optional metadata to attach to the item.
|
|
4209
|
+
* @returns The created item info.
|
|
4210
|
+
*/
|
|
4211
|
+
upload(
|
|
4212
|
+
name: string,
|
|
4213
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4214
|
+
options?: AiSearchUploadItemOptions,
|
|
4215
|
+
): Promise<AiSearchItemInfo>;
|
|
4216
|
+
/**
|
|
4217
|
+
* Upload a file and poll until processing completes.
|
|
4218
|
+
* @param name Filename for the uploaded item.
|
|
4219
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4220
|
+
* @param options Optional metadata to attach to the item.
|
|
4221
|
+
* @returns The item info after processing completes (or timeout).
|
|
4222
|
+
*/
|
|
4223
|
+
uploadAndPoll(
|
|
4224
|
+
name: string,
|
|
4225
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4226
|
+
options?: AiSearchUploadItemOptions,
|
|
4227
|
+
): Promise<AiSearchItemInfo>;
|
|
4228
|
+
/**
|
|
4229
|
+
* Get an item by ID.
|
|
4230
|
+
* @param itemId The item identifier.
|
|
4231
|
+
* @returns Item service for info, delete, and download operations.
|
|
4232
|
+
*/
|
|
4233
|
+
get(itemId: string): AiSearchItem;
|
|
4234
|
+
/** Delete this item from the instance.
|
|
4235
|
+
* @param itemId The item identifier.
|
|
4236
|
+
*/
|
|
4237
|
+
delete(itemId: string): Promise<void>;
|
|
4238
|
+
}
|
|
4239
|
+
/**
|
|
4240
|
+
* Single job service for an AI Search instance.
|
|
4241
|
+
* Provides info and logs for a specific job.
|
|
4242
|
+
*/
|
|
4243
|
+
export declare abstract class AiSearchJob {
|
|
4244
|
+
/** Get metadata about this job. */
|
|
4245
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4246
|
+
/** Get logs for this job. */
|
|
4247
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4248
|
+
}
|
|
4249
|
+
/**
|
|
4250
|
+
* Jobs collection service for an AI Search instance.
|
|
4251
|
+
* Provides list, create, and access to individual jobs.
|
|
4252
|
+
*/
|
|
4253
|
+
export declare abstract class AiSearchJobs {
|
|
4254
|
+
/** List jobs for this instance. */
|
|
4255
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4256
|
+
/**
|
|
4257
|
+
* Create a new indexing job.
|
|
4258
|
+
* @param params Optional job parameters.
|
|
4259
|
+
* @returns The created job info.
|
|
4260
|
+
*/
|
|
4261
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4262
|
+
/**
|
|
4263
|
+
* Get a job by ID.
|
|
4264
|
+
* @param jobId The job identifier.
|
|
4265
|
+
* @returns Job service for info and logs operations.
|
|
4266
|
+
*/
|
|
4267
|
+
get(jobId: string): AiSearchJob;
|
|
4268
|
+
}
|
|
4269
|
+
// ============ AI Search Binding Classes ============
|
|
4270
|
+
/**
|
|
4271
|
+
* Instance-level AI Search service.
|
|
4272
|
+
*
|
|
4273
|
+
* Used as:
|
|
4274
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4275
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4276
|
+
*
|
|
4277
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4278
|
+
*
|
|
4279
|
+
* @example
|
|
4280
|
+
* ```ts
|
|
4281
|
+
* // Via namespace binding
|
|
4282
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4283
|
+
* const results = await instance.search({
|
|
4284
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4285
|
+
* });
|
|
4286
|
+
*
|
|
4287
|
+
* // Via single instance binding
|
|
4288
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4289
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4290
|
+
* });
|
|
4291
|
+
* ```
|
|
4292
|
+
*/
|
|
4293
|
+
export declare abstract class AiSearchInstance {
|
|
4054
4294
|
/**
|
|
4055
4295
|
* Search the AI Search instance for relevant chunks.
|
|
4056
|
-
* @param params Search request with messages and AI search options
|
|
4057
|
-
* @returns Search response with matching chunks
|
|
4296
|
+
* @param params Search request with messages and optional AI search options.
|
|
4297
|
+
* @returns Search response with matching chunks and search query.
|
|
4058
4298
|
*/
|
|
4059
4299
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4300
|
+
/**
|
|
4301
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4302
|
+
* @param params Chat completions request with stream: true.
|
|
4303
|
+
* @returns ReadableStream of server-sent events.
|
|
4304
|
+
*/
|
|
4305
|
+
chatCompletions(
|
|
4306
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4307
|
+
stream: true;
|
|
4308
|
+
},
|
|
4309
|
+
): Promise<ReadableStream>;
|
|
4060
4310
|
/**
|
|
4061
4311
|
* Generate chat completions with AI Search context.
|
|
4062
|
-
* @param params Chat completions request
|
|
4063
|
-
* @returns
|
|
4312
|
+
* @param params Chat completions request.
|
|
4313
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4064
4314
|
*/
|
|
4065
4315
|
chatCompletions(
|
|
4066
4316
|
params: AiSearchChatCompletionsRequest,
|
|
4067
|
-
): Promise<
|
|
4317
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4068
4318
|
/**
|
|
4069
|
-
*
|
|
4319
|
+
* Update the instance configuration.
|
|
4320
|
+
* @param config Partial configuration to update.
|
|
4321
|
+
* @returns Updated instance info.
|
|
4070
4322
|
*/
|
|
4071
|
-
|
|
4323
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4324
|
+
/** Get metadata about this instance. */
|
|
4325
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4326
|
+
/**
|
|
4327
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4328
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4329
|
+
*/
|
|
4330
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4331
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4332
|
+
get items(): AiSearchItems;
|
|
4333
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4334
|
+
get jobs(): AiSearchJobs;
|
|
4072
4335
|
}
|
|
4073
|
-
|
|
4074
|
-
|
|
4336
|
+
/**
|
|
4337
|
+
* Namespace-level AI Search service.
|
|
4338
|
+
*
|
|
4339
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4340
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4341
|
+
*
|
|
4342
|
+
* @example
|
|
4343
|
+
* ```ts
|
|
4344
|
+
* // Access an instance within the namespace
|
|
4345
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4346
|
+
* const results = await blog.search({
|
|
4347
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4348
|
+
* });
|
|
4349
|
+
*
|
|
4350
|
+
* // List all instances in the namespace
|
|
4351
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4352
|
+
*
|
|
4353
|
+
* // Create a new instance with built-in storage
|
|
4354
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4355
|
+
* id: "tenant-123",
|
|
4356
|
+
* });
|
|
4357
|
+
*
|
|
4358
|
+
* // Upload items into the instance
|
|
4359
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4360
|
+
*
|
|
4361
|
+
* // Delete an instance
|
|
4362
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4363
|
+
* ```
|
|
4364
|
+
*/
|
|
4365
|
+
export declare abstract class AiSearchNamespace {
|
|
4075
4366
|
/**
|
|
4076
|
-
*
|
|
4077
|
-
* @
|
|
4367
|
+
* Get an instance by name within the bound namespace.
|
|
4368
|
+
* @param name Instance name.
|
|
4369
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4370
|
+
*/
|
|
4371
|
+
get(name: string): AiSearchInstance;
|
|
4372
|
+
/**
|
|
4373
|
+
* List all instances in the bound namespace.
|
|
4374
|
+
* @returns Array of instance metadata.
|
|
4078
4375
|
*/
|
|
4079
4376
|
list(): Promise<AiSearchListResponse>;
|
|
4080
4377
|
/**
|
|
4081
|
-
*
|
|
4082
|
-
* @param
|
|
4083
|
-
* @returns Instance service for
|
|
4378
|
+
* Create a new instance within the bound namespace.
|
|
4379
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4380
|
+
* @returns Instance service for the newly created instance.
|
|
4381
|
+
*
|
|
4382
|
+
* @example
|
|
4383
|
+
* ```ts
|
|
4384
|
+
* // Create with built-in storage (upload items manually)
|
|
4385
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4386
|
+
*
|
|
4387
|
+
* // Create with web crawler source
|
|
4388
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4389
|
+
* id: "docs-search",
|
|
4390
|
+
* type: "web-crawler",
|
|
4391
|
+
* source: "https://developers.cloudflare.com",
|
|
4392
|
+
* });
|
|
4393
|
+
* ```
|
|
4084
4394
|
*/
|
|
4085
|
-
|
|
4395
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4086
4396
|
/**
|
|
4087
|
-
*
|
|
4088
|
-
* @param
|
|
4089
|
-
* @returns Instance service for performing operations
|
|
4397
|
+
* Delete an instance from the bound namespace.
|
|
4398
|
+
* @param name Instance name to delete.
|
|
4090
4399
|
*/
|
|
4091
|
-
|
|
4400
|
+
delete(name: string): Promise<void>;
|
|
4092
4401
|
}
|
|
4093
4402
|
export type AiImageClassificationInput = {
|
|
4094
4403
|
image: number[];
|
|
@@ -4364,6 +4673,402 @@ export declare abstract class BaseAiTranslation {
|
|
|
4364
4673
|
inputs: AiTranslationInput;
|
|
4365
4674
|
postProcessedOutputs: AiTranslationOutput;
|
|
4366
4675
|
}
|
|
4676
|
+
/**
|
|
4677
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4678
|
+
*/
|
|
4679
|
+
export type ChatCompletionContentPartText = {
|
|
4680
|
+
type: "text";
|
|
4681
|
+
text: string;
|
|
4682
|
+
};
|
|
4683
|
+
export type ChatCompletionContentPartImage = {
|
|
4684
|
+
type: "image_url";
|
|
4685
|
+
image_url: {
|
|
4686
|
+
url: string;
|
|
4687
|
+
detail?: "auto" | "low" | "high";
|
|
4688
|
+
};
|
|
4689
|
+
};
|
|
4690
|
+
export type ChatCompletionContentPartInputAudio = {
|
|
4691
|
+
type: "input_audio";
|
|
4692
|
+
input_audio: {
|
|
4693
|
+
/** Base64 encoded audio data. */
|
|
4694
|
+
data: string;
|
|
4695
|
+
format: "wav" | "mp3";
|
|
4696
|
+
};
|
|
4697
|
+
};
|
|
4698
|
+
export type ChatCompletionContentPartFile = {
|
|
4699
|
+
type: "file";
|
|
4700
|
+
file: {
|
|
4701
|
+
/** Base64 encoded file data. */
|
|
4702
|
+
file_data?: string;
|
|
4703
|
+
/** The ID of an uploaded file. */
|
|
4704
|
+
file_id?: string;
|
|
4705
|
+
filename?: string;
|
|
4706
|
+
};
|
|
4707
|
+
};
|
|
4708
|
+
export type ChatCompletionContentPartRefusal = {
|
|
4709
|
+
type: "refusal";
|
|
4710
|
+
refusal: string;
|
|
4711
|
+
};
|
|
4712
|
+
export type ChatCompletionContentPart =
|
|
4713
|
+
| ChatCompletionContentPartText
|
|
4714
|
+
| ChatCompletionContentPartImage
|
|
4715
|
+
| ChatCompletionContentPartInputAudio
|
|
4716
|
+
| ChatCompletionContentPartFile;
|
|
4717
|
+
export type FunctionDefinition = {
|
|
4718
|
+
name: string;
|
|
4719
|
+
description?: string;
|
|
4720
|
+
parameters?: Record<string, unknown>;
|
|
4721
|
+
strict?: boolean | null;
|
|
4722
|
+
};
|
|
4723
|
+
export type ChatCompletionFunctionTool = {
|
|
4724
|
+
type: "function";
|
|
4725
|
+
function: FunctionDefinition;
|
|
4726
|
+
};
|
|
4727
|
+
export type ChatCompletionCustomToolGrammarFormat = {
|
|
4728
|
+
type: "grammar";
|
|
4729
|
+
grammar: {
|
|
4730
|
+
definition: string;
|
|
4731
|
+
syntax: "lark" | "regex";
|
|
4732
|
+
};
|
|
4733
|
+
};
|
|
4734
|
+
export type ChatCompletionCustomToolTextFormat = {
|
|
4735
|
+
type: "text";
|
|
4736
|
+
};
|
|
4737
|
+
export type ChatCompletionCustomToolFormat =
|
|
4738
|
+
| ChatCompletionCustomToolTextFormat
|
|
4739
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4740
|
+
export type ChatCompletionCustomTool = {
|
|
4741
|
+
type: "custom";
|
|
4742
|
+
custom: {
|
|
4743
|
+
name: string;
|
|
4744
|
+
description?: string;
|
|
4745
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4746
|
+
};
|
|
4747
|
+
};
|
|
4748
|
+
export type ChatCompletionTool =
|
|
4749
|
+
| ChatCompletionFunctionTool
|
|
4750
|
+
| ChatCompletionCustomTool;
|
|
4751
|
+
export type ChatCompletionMessageFunctionToolCall = {
|
|
4752
|
+
id: string;
|
|
4753
|
+
type: "function";
|
|
4754
|
+
function: {
|
|
4755
|
+
name: string;
|
|
4756
|
+
/** JSON-encoded arguments string. */
|
|
4757
|
+
arguments: string;
|
|
4758
|
+
};
|
|
4759
|
+
};
|
|
4760
|
+
export type ChatCompletionMessageCustomToolCall = {
|
|
4761
|
+
id: string;
|
|
4762
|
+
type: "custom";
|
|
4763
|
+
custom: {
|
|
4764
|
+
name: string;
|
|
4765
|
+
input: string;
|
|
4766
|
+
};
|
|
4767
|
+
};
|
|
4768
|
+
export type ChatCompletionMessageToolCall =
|
|
4769
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4770
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4771
|
+
export type ChatCompletionToolChoiceFunction = {
|
|
4772
|
+
type: "function";
|
|
4773
|
+
function: {
|
|
4774
|
+
name: string;
|
|
4775
|
+
};
|
|
4776
|
+
};
|
|
4777
|
+
export type ChatCompletionToolChoiceCustom = {
|
|
4778
|
+
type: "custom";
|
|
4779
|
+
custom: {
|
|
4780
|
+
name: string;
|
|
4781
|
+
};
|
|
4782
|
+
};
|
|
4783
|
+
export type ChatCompletionToolChoiceAllowedTools = {
|
|
4784
|
+
type: "allowed_tools";
|
|
4785
|
+
allowed_tools: {
|
|
4786
|
+
mode: "auto" | "required";
|
|
4787
|
+
tools: Array<Record<string, unknown>>;
|
|
4788
|
+
};
|
|
4789
|
+
};
|
|
4790
|
+
export type ChatCompletionToolChoiceOption =
|
|
4791
|
+
| "none"
|
|
4792
|
+
| "auto"
|
|
4793
|
+
| "required"
|
|
4794
|
+
| ChatCompletionToolChoiceFunction
|
|
4795
|
+
| ChatCompletionToolChoiceCustom
|
|
4796
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4797
|
+
export type DeveloperMessage = {
|
|
4798
|
+
role: "developer";
|
|
4799
|
+
content:
|
|
4800
|
+
| string
|
|
4801
|
+
| Array<{
|
|
4802
|
+
type: "text";
|
|
4803
|
+
text: string;
|
|
4804
|
+
}>;
|
|
4805
|
+
name?: string;
|
|
4806
|
+
};
|
|
4807
|
+
export type SystemMessage = {
|
|
4808
|
+
role: "system";
|
|
4809
|
+
content:
|
|
4810
|
+
| string
|
|
4811
|
+
| Array<{
|
|
4812
|
+
type: "text";
|
|
4813
|
+
text: string;
|
|
4814
|
+
}>;
|
|
4815
|
+
name?: string;
|
|
4816
|
+
};
|
|
4817
|
+
/**
|
|
4818
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4819
|
+
*
|
|
4820
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4821
|
+
* inside nested array items does not correctly match different branches for
|
|
4822
|
+
* different array elements, so the schema uses a single merged object.
|
|
4823
|
+
*/
|
|
4824
|
+
export type UserMessageContentPart = {
|
|
4825
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4826
|
+
text?: string;
|
|
4827
|
+
image_url?: {
|
|
4828
|
+
url?: string;
|
|
4829
|
+
detail?: "auto" | "low" | "high";
|
|
4830
|
+
};
|
|
4831
|
+
input_audio?: {
|
|
4832
|
+
data?: string;
|
|
4833
|
+
format?: "wav" | "mp3";
|
|
4834
|
+
};
|
|
4835
|
+
file?: {
|
|
4836
|
+
file_data?: string;
|
|
4837
|
+
file_id?: string;
|
|
4838
|
+
filename?: string;
|
|
4839
|
+
};
|
|
4840
|
+
};
|
|
4841
|
+
export type UserMessage = {
|
|
4842
|
+
role: "user";
|
|
4843
|
+
content: string | Array<UserMessageContentPart>;
|
|
4844
|
+
name?: string;
|
|
4845
|
+
};
|
|
4846
|
+
export type AssistantMessageContentPart = {
|
|
4847
|
+
type: "text" | "refusal";
|
|
4848
|
+
text?: string;
|
|
4849
|
+
refusal?: string;
|
|
4850
|
+
};
|
|
4851
|
+
export type AssistantMessage = {
|
|
4852
|
+
role: "assistant";
|
|
4853
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4854
|
+
refusal?: string | null;
|
|
4855
|
+
name?: string;
|
|
4856
|
+
audio?: {
|
|
4857
|
+
id: string;
|
|
4858
|
+
};
|
|
4859
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4860
|
+
function_call?: {
|
|
4861
|
+
name: string;
|
|
4862
|
+
arguments: string;
|
|
4863
|
+
};
|
|
4864
|
+
};
|
|
4865
|
+
export type ToolMessage = {
|
|
4866
|
+
role: "tool";
|
|
4867
|
+
content:
|
|
4868
|
+
| string
|
|
4869
|
+
| Array<{
|
|
4870
|
+
type: "text";
|
|
4871
|
+
text: string;
|
|
4872
|
+
}>;
|
|
4873
|
+
tool_call_id: string;
|
|
4874
|
+
};
|
|
4875
|
+
export type FunctionMessage = {
|
|
4876
|
+
role: "function";
|
|
4877
|
+
content: string;
|
|
4878
|
+
name: string;
|
|
4879
|
+
};
|
|
4880
|
+
export type ChatCompletionMessageParam =
|
|
4881
|
+
| DeveloperMessage
|
|
4882
|
+
| SystemMessage
|
|
4883
|
+
| UserMessage
|
|
4884
|
+
| AssistantMessage
|
|
4885
|
+
| ToolMessage
|
|
4886
|
+
| FunctionMessage;
|
|
4887
|
+
export type ChatCompletionsResponseFormatText = {
|
|
4888
|
+
type: "text";
|
|
4889
|
+
};
|
|
4890
|
+
export type ChatCompletionsResponseFormatJSONObject = {
|
|
4891
|
+
type: "json_object";
|
|
4892
|
+
};
|
|
4893
|
+
export type ResponseFormatJSONSchema = {
|
|
4894
|
+
type: "json_schema";
|
|
4895
|
+
json_schema: {
|
|
4896
|
+
name: string;
|
|
4897
|
+
description?: string;
|
|
4898
|
+
schema?: Record<string, unknown>;
|
|
4899
|
+
strict?: boolean | null;
|
|
4900
|
+
};
|
|
4901
|
+
};
|
|
4902
|
+
export type ResponseFormat =
|
|
4903
|
+
| ChatCompletionsResponseFormatText
|
|
4904
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4905
|
+
| ResponseFormatJSONSchema;
|
|
4906
|
+
export type ChatCompletionsStreamOptions = {
|
|
4907
|
+
include_usage?: boolean;
|
|
4908
|
+
include_obfuscation?: boolean;
|
|
4909
|
+
};
|
|
4910
|
+
export type PredictionContent = {
|
|
4911
|
+
type: "content";
|
|
4912
|
+
content:
|
|
4913
|
+
| string
|
|
4914
|
+
| Array<{
|
|
4915
|
+
type: "text";
|
|
4916
|
+
text: string;
|
|
4917
|
+
}>;
|
|
4918
|
+
};
|
|
4919
|
+
export type AudioParams = {
|
|
4920
|
+
voice:
|
|
4921
|
+
| string
|
|
4922
|
+
| {
|
|
4923
|
+
id: string;
|
|
4924
|
+
};
|
|
4925
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4926
|
+
};
|
|
4927
|
+
export type WebSearchUserLocation = {
|
|
4928
|
+
type: "approximate";
|
|
4929
|
+
approximate: {
|
|
4930
|
+
city?: string;
|
|
4931
|
+
country?: string;
|
|
4932
|
+
region?: string;
|
|
4933
|
+
timezone?: string;
|
|
4934
|
+
};
|
|
4935
|
+
};
|
|
4936
|
+
export type WebSearchOptions = {
|
|
4937
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4938
|
+
user_location?: WebSearchUserLocation;
|
|
4939
|
+
};
|
|
4940
|
+
export type ChatTemplateKwargs = {
|
|
4941
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4942
|
+
enable_thinking?: boolean;
|
|
4943
|
+
/** If false, preserves reasoning context between turns. */
|
|
4944
|
+
clear_thinking?: boolean;
|
|
4945
|
+
};
|
|
4946
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4947
|
+
export type ChatCompletionsCommonOptions = {
|
|
4948
|
+
model?: string;
|
|
4949
|
+
audio?: AudioParams;
|
|
4950
|
+
frequency_penalty?: number | null;
|
|
4951
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4952
|
+
logprobs?: boolean | null;
|
|
4953
|
+
top_logprobs?: number | null;
|
|
4954
|
+
max_tokens?: number | null;
|
|
4955
|
+
max_completion_tokens?: number | null;
|
|
4956
|
+
metadata?: Record<string, unknown> | null;
|
|
4957
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4958
|
+
n?: number | null;
|
|
4959
|
+
parallel_tool_calls?: boolean;
|
|
4960
|
+
prediction?: PredictionContent;
|
|
4961
|
+
presence_penalty?: number | null;
|
|
4962
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4963
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4964
|
+
response_format?: ResponseFormat;
|
|
4965
|
+
seed?: number | null;
|
|
4966
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4967
|
+
stop?: string | Array<string> | null;
|
|
4968
|
+
store?: boolean | null;
|
|
4969
|
+
stream?: boolean | null;
|
|
4970
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4971
|
+
temperature?: number | null;
|
|
4972
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4973
|
+
tools?: Array<ChatCompletionTool>;
|
|
4974
|
+
top_p?: number | null;
|
|
4975
|
+
user?: string;
|
|
4976
|
+
web_search_options?: WebSearchOptions;
|
|
4977
|
+
function_call?:
|
|
4978
|
+
| "none"
|
|
4979
|
+
| "auto"
|
|
4980
|
+
| {
|
|
4981
|
+
name: string;
|
|
4982
|
+
};
|
|
4983
|
+
functions?: Array<FunctionDefinition>;
|
|
4984
|
+
};
|
|
4985
|
+
export type PromptTokensDetails = {
|
|
4986
|
+
cached_tokens?: number;
|
|
4987
|
+
audio_tokens?: number;
|
|
4988
|
+
};
|
|
4989
|
+
export type CompletionTokensDetails = {
|
|
4990
|
+
reasoning_tokens?: number;
|
|
4991
|
+
audio_tokens?: number;
|
|
4992
|
+
accepted_prediction_tokens?: number;
|
|
4993
|
+
rejected_prediction_tokens?: number;
|
|
4994
|
+
};
|
|
4995
|
+
export type CompletionUsage = {
|
|
4996
|
+
prompt_tokens: number;
|
|
4997
|
+
completion_tokens: number;
|
|
4998
|
+
total_tokens: number;
|
|
4999
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
5000
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
5001
|
+
};
|
|
5002
|
+
export type ChatCompletionTopLogprob = {
|
|
5003
|
+
token: string;
|
|
5004
|
+
logprob: number;
|
|
5005
|
+
bytes: Array<number> | null;
|
|
5006
|
+
};
|
|
5007
|
+
export type ChatCompletionTokenLogprob = {
|
|
5008
|
+
token: string;
|
|
5009
|
+
logprob: number;
|
|
5010
|
+
bytes: Array<number> | null;
|
|
5011
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
5012
|
+
};
|
|
5013
|
+
export type ChatCompletionAudio = {
|
|
5014
|
+
id: string;
|
|
5015
|
+
/** Base64 encoded audio bytes. */
|
|
5016
|
+
data: string;
|
|
5017
|
+
expires_at: number;
|
|
5018
|
+
transcript: string;
|
|
5019
|
+
};
|
|
5020
|
+
export type ChatCompletionUrlCitation = {
|
|
5021
|
+
type: "url_citation";
|
|
5022
|
+
url_citation: {
|
|
5023
|
+
url: string;
|
|
5024
|
+
title: string;
|
|
5025
|
+
start_index: number;
|
|
5026
|
+
end_index: number;
|
|
5027
|
+
};
|
|
5028
|
+
};
|
|
5029
|
+
export type ChatCompletionResponseMessage = {
|
|
5030
|
+
role: "assistant";
|
|
5031
|
+
content: string | null;
|
|
5032
|
+
refusal: string | null;
|
|
5033
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
5034
|
+
audio?: ChatCompletionAudio;
|
|
5035
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
5036
|
+
function_call?: {
|
|
5037
|
+
name: string;
|
|
5038
|
+
arguments: string;
|
|
5039
|
+
} | null;
|
|
5040
|
+
};
|
|
5041
|
+
export type ChatCompletionLogprobs = {
|
|
5042
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
5043
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
5044
|
+
};
|
|
5045
|
+
export type ChatCompletionChoice = {
|
|
5046
|
+
index: number;
|
|
5047
|
+
message: ChatCompletionResponseMessage;
|
|
5048
|
+
finish_reason:
|
|
5049
|
+
| "stop"
|
|
5050
|
+
| "length"
|
|
5051
|
+
| "tool_calls"
|
|
5052
|
+
| "content_filter"
|
|
5053
|
+
| "function_call";
|
|
5054
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
5055
|
+
};
|
|
5056
|
+
export type ChatCompletionsPromptInput = {
|
|
5057
|
+
prompt: string;
|
|
5058
|
+
} & ChatCompletionsCommonOptions;
|
|
5059
|
+
export type ChatCompletionsMessagesInput = {
|
|
5060
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
5061
|
+
} & ChatCompletionsCommonOptions;
|
|
5062
|
+
export type ChatCompletionsOutput = {
|
|
5063
|
+
id: string;
|
|
5064
|
+
object: string;
|
|
5065
|
+
created: number;
|
|
5066
|
+
model: string;
|
|
5067
|
+
choices: Array<ChatCompletionChoice>;
|
|
5068
|
+
usage?: CompletionUsage;
|
|
5069
|
+
system_fingerprint?: string | null;
|
|
5070
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
5071
|
+
};
|
|
4367
5072
|
/**
|
|
4368
5073
|
* Workers AI support for OpenAI's Responses API
|
|
4369
5074
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4786,6 +5491,12 @@ export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4786
5491
|
export type StreamOptions = {
|
|
4787
5492
|
include_obfuscation?: boolean;
|
|
4788
5493
|
};
|
|
5494
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5495
|
+
export type Without<T, U> = {
|
|
5496
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5497
|
+
};
|
|
5498
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5499
|
+
export type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4789
5500
|
export type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4790
5501
|
| {
|
|
4791
5502
|
text: string | string[];
|
|
@@ -5078,10 +5789,12 @@ export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5078
5789
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5079
5790
|
}
|
|
5080
5791
|
export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5792
|
+
audio:
|
|
5793
|
+
| string
|
|
5794
|
+
| {
|
|
5795
|
+
body?: object;
|
|
5796
|
+
contentType?: string;
|
|
5797
|
+
};
|
|
5085
5798
|
/**
|
|
5086
5799
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5087
5800
|
*/
|
|
@@ -5099,9 +5812,33 @@ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5099
5812
|
*/
|
|
5100
5813
|
initial_prompt?: string;
|
|
5101
5814
|
/**
|
|
5102
|
-
* The prefix
|
|
5815
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5103
5816
|
*/
|
|
5104
5817
|
prefix?: string;
|
|
5818
|
+
/**
|
|
5819
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5820
|
+
*/
|
|
5821
|
+
beam_size?: number;
|
|
5822
|
+
/**
|
|
5823
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5824
|
+
*/
|
|
5825
|
+
condition_on_previous_text?: boolean;
|
|
5826
|
+
/**
|
|
5827
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5828
|
+
*/
|
|
5829
|
+
no_speech_threshold?: number;
|
|
5830
|
+
/**
|
|
5831
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5832
|
+
*/
|
|
5833
|
+
compression_ratio_threshold?: number;
|
|
5834
|
+
/**
|
|
5835
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5836
|
+
*/
|
|
5837
|
+
log_prob_threshold?: number;
|
|
5838
|
+
/**
|
|
5839
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5840
|
+
*/
|
|
5841
|
+
hallucination_silence_threshold?: number;
|
|
5105
5842
|
}
|
|
5106
5843
|
export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5107
5844
|
transcription_info?: {
|
|
@@ -5248,11 +5985,11 @@ export interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5248
5985
|
truncate_inputs?: boolean;
|
|
5249
5986
|
}
|
|
5250
5987
|
export type Ai_Cf_Baai_Bge_M3_Output =
|
|
5251
|
-
|
|
|
5988
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5252
5989
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5253
|
-
|
|
|
5990
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5254
5991
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5255
|
-
export interface
|
|
5992
|
+
export interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5256
5993
|
response?: {
|
|
5257
5994
|
/**
|
|
5258
5995
|
* Index of the context in the request
|
|
@@ -5272,7 +6009,7 @@ export interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5272
6009
|
*/
|
|
5273
6010
|
pooling?: "mean" | "cls";
|
|
5274
6011
|
}
|
|
5275
|
-
export interface
|
|
6012
|
+
export interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5276
6013
|
shape?: number[];
|
|
5277
6014
|
/**
|
|
5278
6015
|
* Embeddings of the requested text values
|
|
@@ -5377,7 +6114,7 @@ export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5377
6114
|
*/
|
|
5378
6115
|
role?: string;
|
|
5379
6116
|
/**
|
|
5380
|
-
* The tool call id.
|
|
6117
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5381
6118
|
*/
|
|
5382
6119
|
tool_call_id?: string;
|
|
5383
6120
|
content?:
|
|
@@ -5632,10 +6369,18 @@ export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5632
6369
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5633
6370
|
*/
|
|
5634
6371
|
role: string;
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
6372
|
+
content:
|
|
6373
|
+
| string
|
|
6374
|
+
| {
|
|
6375
|
+
/**
|
|
6376
|
+
* Type of the content (text)
|
|
6377
|
+
*/
|
|
6378
|
+
type?: string;
|
|
6379
|
+
/**
|
|
6380
|
+
* Text content
|
|
6381
|
+
*/
|
|
6382
|
+
text?: string;
|
|
6383
|
+
}[];
|
|
5639
6384
|
}[];
|
|
5640
6385
|
functions?: {
|
|
5641
6386
|
name: string;
|
|
@@ -6291,7 +7036,7 @@ export interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6291
7036
|
*/
|
|
6292
7037
|
role?: string;
|
|
6293
7038
|
/**
|
|
6294
|
-
* The tool call id.
|
|
7039
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6295
7040
|
*/
|
|
6296
7041
|
tool_call_id?: string;
|
|
6297
7042
|
content?:
|
|
@@ -6418,7 +7163,7 @@ export interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6418
7163
|
}
|
|
6419
7164
|
)[];
|
|
6420
7165
|
/**
|
|
6421
|
-
* JSON schema that should be
|
|
7166
|
+
* JSON schema that should be fufilled for the response.
|
|
6422
7167
|
*/
|
|
6423
7168
|
guided_json?: object;
|
|
6424
7169
|
/**
|
|
@@ -6692,7 +7437,7 @@ export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6692
7437
|
}
|
|
6693
7438
|
)[];
|
|
6694
7439
|
/**
|
|
6695
|
-
* JSON schema that should be
|
|
7440
|
+
* JSON schema that should be fufilled for the response.
|
|
6696
7441
|
*/
|
|
6697
7442
|
guided_json?: object;
|
|
6698
7443
|
/**
|
|
@@ -6785,7 +7530,7 @@ export interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6785
7530
|
*/
|
|
6786
7531
|
prompt: string;
|
|
6787
7532
|
/**
|
|
6788
|
-
* JSON schema that should be
|
|
7533
|
+
* JSON schema that should be fufilled for the response.
|
|
6789
7534
|
*/
|
|
6790
7535
|
guided_json?: object;
|
|
6791
7536
|
/**
|
|
@@ -6949,7 +7694,7 @@ export interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6949
7694
|
}
|
|
6950
7695
|
)[];
|
|
6951
7696
|
/**
|
|
6952
|
-
* JSON schema that should be
|
|
7697
|
+
* JSON schema that should be fufilled for the response.
|
|
6953
7698
|
*/
|
|
6954
7699
|
guided_json?: object;
|
|
6955
7700
|
/**
|
|
@@ -7230,7 +7975,7 @@ export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7230
7975
|
)[];
|
|
7231
7976
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7232
7977
|
/**
|
|
7233
|
-
* JSON schema that should be
|
|
7978
|
+
* JSON schema that should be fufilled for the response.
|
|
7234
7979
|
*/
|
|
7235
7980
|
guided_json?: object;
|
|
7236
7981
|
/**
|
|
@@ -7469,7 +8214,7 @@ export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7469
8214
|
)[];
|
|
7470
8215
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7471
8216
|
/**
|
|
7472
|
-
* JSON schema that should be
|
|
8217
|
+
* JSON schema that should be fufilled for the response.
|
|
7473
8218
|
*/
|
|
7474
8219
|
guided_json?: object;
|
|
7475
8220
|
/**
|
|
@@ -7634,10 +8379,18 @@ export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7634
8379
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7635
8380
|
*/
|
|
7636
8381
|
role: string;
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
8382
|
+
content:
|
|
8383
|
+
| string
|
|
8384
|
+
| {
|
|
8385
|
+
/**
|
|
8386
|
+
* Type of the content (text)
|
|
8387
|
+
*/
|
|
8388
|
+
type?: string;
|
|
8389
|
+
/**
|
|
8390
|
+
* Text content
|
|
8391
|
+
*/
|
|
8392
|
+
text?: string;
|
|
8393
|
+
}[];
|
|
7641
8394
|
}[];
|
|
7642
8395
|
functions?: {
|
|
7643
8396
|
name: string;
|
|
@@ -7849,10 +8602,18 @@ export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7849
8602
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7850
8603
|
*/
|
|
7851
8604
|
role: string;
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
8605
|
+
content:
|
|
8606
|
+
| string
|
|
8607
|
+
| {
|
|
8608
|
+
/**
|
|
8609
|
+
* Type of the content (text)
|
|
8610
|
+
*/
|
|
8611
|
+
type?: string;
|
|
8612
|
+
/**
|
|
8613
|
+
* Text content
|
|
8614
|
+
*/
|
|
8615
|
+
text?: string;
|
|
8616
|
+
}[];
|
|
7856
8617
|
}[];
|
|
7857
8618
|
functions?: {
|
|
7858
8619
|
name: string;
|
|
@@ -8420,12 +9181,12 @@ export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8420
9181
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8421
9182
|
}
|
|
8422
9183
|
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8423
|
-
inputs: ResponsesInput
|
|
8424
|
-
postProcessedOutputs: ResponsesOutput
|
|
9184
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9185
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8425
9186
|
}
|
|
8426
9187
|
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8427
|
-
inputs: ResponsesInput
|
|
8428
|
-
postProcessedOutputs: ResponsesOutput
|
|
9188
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9189
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8429
9190
|
}
|
|
8430
9191
|
export interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8431
9192
|
/**
|
|
@@ -8557,7 +9318,7 @@ export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8557
9318
|
*/
|
|
8558
9319
|
text: string | string[];
|
|
8559
9320
|
/**
|
|
8560
|
-
* Target
|
|
9321
|
+
* Target langauge to translate to
|
|
8561
9322
|
*/
|
|
8562
9323
|
target_language:
|
|
8563
9324
|
| "asm_Beng"
|
|
@@ -8673,10 +9434,18 @@ export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8673
9434
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8674
9435
|
*/
|
|
8675
9436
|
role: string;
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
9437
|
+
content:
|
|
9438
|
+
| string
|
|
9439
|
+
| {
|
|
9440
|
+
/**
|
|
9441
|
+
* Type of the content (text)
|
|
9442
|
+
*/
|
|
9443
|
+
type?: string;
|
|
9444
|
+
/**
|
|
9445
|
+
* Text content
|
|
9446
|
+
*/
|
|
9447
|
+
text?: string;
|
|
9448
|
+
}[];
|
|
8680
9449
|
}[];
|
|
8681
9450
|
functions?: {
|
|
8682
9451
|
name: string;
|
|
@@ -8888,10 +9657,18 @@ export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8888
9657
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8889
9658
|
*/
|
|
8890
9659
|
role: string;
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
9660
|
+
content:
|
|
9661
|
+
| string
|
|
9662
|
+
| {
|
|
9663
|
+
/**
|
|
9664
|
+
* Type of the content (text)
|
|
9665
|
+
*/
|
|
9666
|
+
type?: string;
|
|
9667
|
+
/**
|
|
9668
|
+
* Text content
|
|
9669
|
+
*/
|
|
9670
|
+
text?: string;
|
|
9671
|
+
}[];
|
|
8895
9672
|
}[];
|
|
8896
9673
|
functions?: {
|
|
8897
9674
|
name: string;
|
|
@@ -9446,6 +10223,66 @@ export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9446
10223
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9447
10224
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9448
10225
|
}
|
|
10226
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10227
|
+
multipart: {
|
|
10228
|
+
body?: object;
|
|
10229
|
+
contentType?: string;
|
|
10230
|
+
};
|
|
10231
|
+
}
|
|
10232
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10233
|
+
/**
|
|
10234
|
+
* Generated image as Base64 string.
|
|
10235
|
+
*/
|
|
10236
|
+
image?: string;
|
|
10237
|
+
}
|
|
10238
|
+
export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10239
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10240
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10241
|
+
}
|
|
10242
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10243
|
+
multipart: {
|
|
10244
|
+
body?: object;
|
|
10245
|
+
contentType?: string;
|
|
10246
|
+
};
|
|
10247
|
+
}
|
|
10248
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10249
|
+
/**
|
|
10250
|
+
* Generated image as Base64 string.
|
|
10251
|
+
*/
|
|
10252
|
+
image?: string;
|
|
10253
|
+
}
|
|
10254
|
+
export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10255
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10256
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10257
|
+
}
|
|
10258
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10259
|
+
multipart: {
|
|
10260
|
+
body?: object;
|
|
10261
|
+
contentType?: string;
|
|
10262
|
+
};
|
|
10263
|
+
}
|
|
10264
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10265
|
+
/**
|
|
10266
|
+
* Generated image as Base64 string.
|
|
10267
|
+
*/
|
|
10268
|
+
image?: string;
|
|
10269
|
+
}
|
|
10270
|
+
export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10271
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10272
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10273
|
+
}
|
|
10274
|
+
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10275
|
+
inputs: ChatCompletionsInput;
|
|
10276
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10277
|
+
}
|
|
10278
|
+
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10279
|
+
inputs: ChatCompletionsInput;
|
|
10280
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10281
|
+
}
|
|
10282
|
+
export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10283
|
+
inputs: ChatCompletionsInput;
|
|
10284
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10285
|
+
}
|
|
9449
10286
|
export interface AiModels {
|
|
9450
10287
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9451
10288
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9464,7 +10301,6 @@ export interface AiModels {
|
|
|
9464
10301
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9465
10302
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9466
10303
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9467
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9468
10304
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9469
10305
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9470
10306
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9531,6 +10367,12 @@ export interface AiModels {
|
|
|
9531
10367
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9532
10368
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9533
10369
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10370
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10371
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10372
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10373
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10374
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10375
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9534
10376
|
}
|
|
9535
10377
|
export type AiOptions = {
|
|
9536
10378
|
/**
|
|
@@ -9556,6 +10398,7 @@ export type AiOptions = {
|
|
|
9556
10398
|
returnRawResponse?: boolean;
|
|
9557
10399
|
prefix?: string;
|
|
9558
10400
|
extraHeaders?: object;
|
|
10401
|
+
signal?: AbortSignal;
|
|
9559
10402
|
};
|
|
9560
10403
|
export type AiModelsSearchParams = {
|
|
9561
10404
|
author?: string;
|
|
@@ -9582,6 +10425,16 @@ export type AiModelsSearchObject = {
|
|
|
9582
10425
|
value: string;
|
|
9583
10426
|
}[];
|
|
9584
10427
|
};
|
|
10428
|
+
export type ChatCompletionsBase = XOR<
|
|
10429
|
+
ChatCompletionsPromptInput,
|
|
10430
|
+
ChatCompletionsMessagesInput
|
|
10431
|
+
>;
|
|
10432
|
+
export type ChatCompletionsInput = XOR<
|
|
10433
|
+
ChatCompletionsBase,
|
|
10434
|
+
{
|
|
10435
|
+
requests: ChatCompletionsBase[];
|
|
10436
|
+
}
|
|
10437
|
+
>;
|
|
9585
10438
|
export interface InferenceUpstreamError extends Error {}
|
|
9586
10439
|
export interface AiInternalError extends Error {}
|
|
9587
10440
|
export type AiModelListType = Record<string, any>;
|
|
@@ -9591,46 +10444,16 @@ export declare abstract class Ai<
|
|
|
9591
10444
|
aiGatewayLogId: string | null;
|
|
9592
10445
|
gateway(gatewayId: string): AiGateway;
|
|
9593
10446
|
/**
|
|
9594
|
-
*
|
|
9595
|
-
*
|
|
9596
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9597
|
-
* - Account-level operations: `list()`, `create()`
|
|
9598
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9599
|
-
*
|
|
9600
|
-
* @example
|
|
9601
|
-
* ```typescript
|
|
9602
|
-
* // List all AI Search instances
|
|
9603
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9604
|
-
*
|
|
9605
|
-
* // Search an instance
|
|
9606
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9607
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9608
|
-
* ai_search_options: {
|
|
9609
|
-
* retrieval: { max_num_results: 10 }
|
|
9610
|
-
* }
|
|
9611
|
-
* });
|
|
9612
|
-
*
|
|
9613
|
-
* // Generate chat completions with AI Search context
|
|
9614
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9615
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9616
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9617
|
-
* });
|
|
9618
|
-
* ```
|
|
10447
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10448
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9619
10449
|
*/
|
|
9620
|
-
aiSearch():
|
|
10450
|
+
aiSearch(): AiSearchNamespace;
|
|
9621
10451
|
/**
|
|
9622
10452
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9623
|
-
* Use `
|
|
9624
|
-
*
|
|
9625
|
-
* Migration guide:
|
|
9626
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9627
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9628
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10453
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10454
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9629
10455
|
*
|
|
9630
|
-
*
|
|
9631
|
-
*
|
|
9632
|
-
* @see AiSearchAccountService
|
|
9633
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10456
|
+
* @param autoragId Instance ID
|
|
9634
10457
|
*/
|
|
9635
10458
|
autorag(autoragId: string): AutoRAG;
|
|
9636
10459
|
run<
|
|
@@ -9789,22 +10612,23 @@ export declare abstract class AiGateway {
|
|
|
9789
10612
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9790
10613
|
}
|
|
9791
10614
|
/**
|
|
9792
|
-
* @deprecated
|
|
9793
|
-
*
|
|
10615
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10616
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9794
10617
|
*/
|
|
9795
10618
|
export interface AutoRAGInternalError extends Error {}
|
|
9796
10619
|
/**
|
|
9797
|
-
* @deprecated
|
|
9798
|
-
*
|
|
10620
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10621
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9799
10622
|
*/
|
|
9800
10623
|
export interface AutoRAGNotFoundError extends Error {}
|
|
9801
10624
|
/**
|
|
9802
|
-
* @deprecated
|
|
10625
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10626
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9803
10627
|
*/
|
|
9804
10628
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
9805
10629
|
/**
|
|
9806
|
-
* @deprecated
|
|
9807
|
-
*
|
|
10630
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10631
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9808
10632
|
*/
|
|
9809
10633
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
9810
10634
|
export type ComparisonFilter = {
|
|
@@ -9817,9 +10641,8 @@ export type CompoundFilter = {
|
|
|
9817
10641
|
filters: ComparisonFilter[];
|
|
9818
10642
|
};
|
|
9819
10643
|
/**
|
|
9820
|
-
* @deprecated
|
|
9821
|
-
*
|
|
9822
|
-
* @see AiSearchSearchRequest
|
|
10644
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10645
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9823
10646
|
*/
|
|
9824
10647
|
export type AutoRagSearchRequest = {
|
|
9825
10648
|
query: string;
|
|
@@ -9836,18 +10659,16 @@ export type AutoRagSearchRequest = {
|
|
|
9836
10659
|
rewrite_query?: boolean;
|
|
9837
10660
|
};
|
|
9838
10661
|
/**
|
|
9839
|
-
* @deprecated
|
|
9840
|
-
*
|
|
9841
|
-
* @see AiSearchChatCompletionsRequest
|
|
10662
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10663
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9842
10664
|
*/
|
|
9843
10665
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9844
10666
|
stream?: boolean;
|
|
9845
10667
|
system_prompt?: string;
|
|
9846
10668
|
};
|
|
9847
10669
|
/**
|
|
9848
|
-
* @deprecated
|
|
9849
|
-
*
|
|
9850
|
-
* @see AiSearchChatCompletionsRequest
|
|
10670
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10671
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9851
10672
|
*/
|
|
9852
10673
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
9853
10674
|
AutoRagAiSearchRequest,
|
|
@@ -9856,9 +10677,8 @@ export type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9856
10677
|
stream: true;
|
|
9857
10678
|
};
|
|
9858
10679
|
/**
|
|
9859
|
-
* @deprecated
|
|
9860
|
-
*
|
|
9861
|
-
* @see AiSearchSearchResponse
|
|
10680
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10681
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9862
10682
|
*/
|
|
9863
10683
|
export type AutoRagSearchResponse = {
|
|
9864
10684
|
object: "vector_store.search_results.page";
|
|
@@ -9877,9 +10697,8 @@ export type AutoRagSearchResponse = {
|
|
|
9877
10697
|
next_page: string | null;
|
|
9878
10698
|
};
|
|
9879
10699
|
/**
|
|
9880
|
-
* @deprecated
|
|
9881
|
-
*
|
|
9882
|
-
* @see AiSearchListResponse
|
|
10700
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10701
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9883
10702
|
*/
|
|
9884
10703
|
export type AutoRagListResponse = {
|
|
9885
10704
|
id: string;
|
|
@@ -9891,49 +10710,40 @@ export type AutoRagListResponse = {
|
|
|
9891
10710
|
status: string;
|
|
9892
10711
|
}[];
|
|
9893
10712
|
/**
|
|
9894
|
-
* @deprecated
|
|
9895
|
-
*
|
|
10713
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10714
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9896
10715
|
*/
|
|
9897
10716
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9898
10717
|
response: string;
|
|
9899
10718
|
};
|
|
9900
10719
|
/**
|
|
9901
|
-
* @deprecated
|
|
9902
|
-
*
|
|
9903
|
-
*
|
|
9904
|
-
* Migration guide:
|
|
9905
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9906
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9907
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9908
|
-
*
|
|
9909
|
-
* @see AiSearchAccountService
|
|
9910
|
-
* @see AiSearchInstanceService
|
|
10720
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10721
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9911
10722
|
*/
|
|
9912
10723
|
export declare abstract class AutoRAG {
|
|
9913
10724
|
/**
|
|
9914
|
-
* @deprecated Use
|
|
9915
|
-
*
|
|
10725
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10726
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9916
10727
|
*/
|
|
9917
10728
|
list(): Promise<AutoRagListResponse>;
|
|
9918
10729
|
/**
|
|
9919
|
-
* @deprecated Use
|
|
9920
|
-
*
|
|
9921
|
-
* @see AiSearchInstanceService.search
|
|
10730
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10731
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9922
10732
|
*/
|
|
9923
10733
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9924
10734
|
/**
|
|
9925
|
-
* @deprecated Use
|
|
9926
|
-
*
|
|
10735
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10736
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9927
10737
|
*/
|
|
9928
10738
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9929
10739
|
/**
|
|
9930
|
-
* @deprecated Use
|
|
9931
|
-
*
|
|
10740
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10741
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9932
10742
|
*/
|
|
9933
10743
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9934
10744
|
/**
|
|
9935
|
-
* @deprecated Use
|
|
9936
|
-
*
|
|
10745
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10746
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9937
10747
|
*/
|
|
9938
10748
|
aiSearch(
|
|
9939
10749
|
params: AutoRagAiSearchRequest,
|
|
@@ -10058,6 +10868,41 @@ export interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
10058
10868
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
10059
10869
|
*/
|
|
10060
10870
|
cacheTtlByStatus?: Record<string, number>;
|
|
10871
|
+
/**
|
|
10872
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10873
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10874
|
+
*
|
|
10875
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10876
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10877
|
+
*
|
|
10878
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10879
|
+
*/
|
|
10880
|
+
cacheControl?: string;
|
|
10881
|
+
/**
|
|
10882
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10883
|
+
*/
|
|
10884
|
+
cacheReserveEligible?: boolean;
|
|
10885
|
+
/**
|
|
10886
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10887
|
+
*/
|
|
10888
|
+
respectStrongEtag?: boolean;
|
|
10889
|
+
/**
|
|
10890
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10891
|
+
*/
|
|
10892
|
+
stripEtags?: boolean;
|
|
10893
|
+
/**
|
|
10894
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10895
|
+
*/
|
|
10896
|
+
stripLastModified?: boolean;
|
|
10897
|
+
/**
|
|
10898
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10899
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10900
|
+
*/
|
|
10901
|
+
cacheDeceptionArmor?: boolean;
|
|
10902
|
+
/**
|
|
10903
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10904
|
+
*/
|
|
10905
|
+
cacheReserveMinimumFileSize?: number;
|
|
10061
10906
|
scrapeShield?: boolean;
|
|
10062
10907
|
apps?: boolean;
|
|
10063
10908
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11926,6 +12771,7 @@ export declare namespace CloudflareWorkersModule {
|
|
|
11926
12771
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11927
12772
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11928
12773
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12774
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11929
12775
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11930
12776
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11931
12777
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11946,6 +12792,7 @@ export declare namespace CloudflareWorkersModule {
|
|
|
11946
12792
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11947
12793
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11948
12794
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12795
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11949
12796
|
webSocketMessage?(
|
|
11950
12797
|
ws: WebSocket,
|
|
11951
12798
|
message: string | ArrayBuffer,
|
|
@@ -12086,17 +12933,6 @@ export interface StreamBinding {
|
|
|
12086
12933
|
* @returns A handle for per-video operations.
|
|
12087
12934
|
*/
|
|
12088
12935
|
video(id: string): StreamVideoHandle;
|
|
12089
|
-
/**
|
|
12090
|
-
* Uploads a new video from a File.
|
|
12091
|
-
* @param file The video file to upload.
|
|
12092
|
-
* @returns The uploaded video details.
|
|
12093
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12094
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12095
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12096
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12097
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12098
|
-
*/
|
|
12099
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12100
12936
|
/**
|
|
12101
12937
|
* Uploads a new video from a provided URL.
|
|
12102
12938
|
* @param url The URL to upload from.
|
|
@@ -12946,6 +13782,9 @@ export declare namespace TailStream {
|
|
|
12946
13782
|
readonly type: "fetch";
|
|
12947
13783
|
readonly statusCode: number;
|
|
12948
13784
|
}
|
|
13785
|
+
interface ConnectEventInfo {
|
|
13786
|
+
readonly type: "connect";
|
|
13787
|
+
}
|
|
12949
13788
|
type EventOutcome =
|
|
12950
13789
|
| "ok"
|
|
12951
13790
|
| "canceled"
|
|
@@ -12976,6 +13815,7 @@ export declare namespace TailStream {
|
|
|
12976
13815
|
readonly scriptVersion?: ScriptVersion;
|
|
12977
13816
|
readonly info:
|
|
12978
13817
|
| FetchEventInfo
|
|
13818
|
+
| ConnectEventInfo
|
|
12979
13819
|
| JsRpcEventInfo
|
|
12980
13820
|
| ScheduledEventInfo
|
|
12981
13821
|
| AlarmEventInfo
|