@cloudflare/workers-types 4.20260317.1 → 4.20260331.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2021-11-03/index.d.ts +1018 -180
- package/2021-11-03/index.ts +1020 -180
- package/2022-01-31/index.d.ts +1018 -180
- package/2022-01-31/index.ts +1020 -180
- package/2022-03-21/index.d.ts +1018 -180
- package/2022-03-21/index.ts +1020 -180
- package/2022-08-04/index.d.ts +1018 -180
- package/2022-08-04/index.ts +1020 -180
- package/2022-10-31/index.d.ts +1018 -180
- package/2022-10-31/index.ts +1020 -180
- package/2022-11-30/index.d.ts +1018 -180
- package/2022-11-30/index.ts +1020 -180
- package/2023-03-01/index.d.ts +1018 -180
- package/2023-03-01/index.ts +1020 -180
- package/2023-07-01/index.d.ts +1018 -180
- package/2023-07-01/index.ts +1020 -180
- package/experimental/index.d.ts +1089 -181
- package/experimental/index.ts +1091 -181
- package/index.d.ts +1018 -180
- package/index.ts +1020 -180
- package/latest/index.d.ts +1018 -180
- package/latest/index.ts +1020 -180
- package/oldest/index.d.ts +1018 -180
- package/oldest/index.ts +1020 -180
- package/package.json +1 -1
package/2022-10-31/index.d.ts
CHANGED
|
@@ -481,6 +481,11 @@ type ExportedHandlerFetchHandler<
|
|
|
481
481
|
env: Env,
|
|
482
482
|
ctx: ExecutionContext<Props>,
|
|
483
483
|
) => Response | Promise<Response>;
|
|
484
|
+
type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
|
|
485
|
+
socket: Socket,
|
|
486
|
+
env: Env,
|
|
487
|
+
ctx: ExecutionContext<Props>,
|
|
488
|
+
) => void | Promise<void>;
|
|
484
489
|
type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
|
|
485
490
|
events: TraceItem[],
|
|
486
491
|
env: Env,
|
|
@@ -522,6 +527,7 @@ interface ExportedHandler<
|
|
|
522
527
|
Props = unknown,
|
|
523
528
|
> {
|
|
524
529
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
|
|
530
|
+
connect?: ExportedHandlerConnectHandler<Env, Props>;
|
|
525
531
|
tail?: ExportedHandlerTailHandler<Env, Props>;
|
|
526
532
|
trace?: ExportedHandlerTraceHandler<Env, Props>;
|
|
527
533
|
tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
|
|
@@ -541,12 +547,14 @@ declare abstract class Navigator {
|
|
|
541
547
|
interface AlarmInvocationInfo {
|
|
542
548
|
readonly isRetry: boolean;
|
|
543
549
|
readonly retryCount: number;
|
|
550
|
+
readonly scheduledTime: number;
|
|
544
551
|
}
|
|
545
552
|
interface Cloudflare {
|
|
546
553
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
547
554
|
}
|
|
548
555
|
interface DurableObject {
|
|
549
556
|
fetch(request: Request): Response | Promise<Response>;
|
|
557
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
550
558
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
551
559
|
webSocketMessage?(
|
|
552
560
|
ws: WebSocket,
|
|
@@ -564,7 +572,7 @@ type DurableObjectStub<
|
|
|
564
572
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
565
573
|
> = Fetcher<
|
|
566
574
|
T,
|
|
567
|
-
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
575
|
+
"alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
568
576
|
> & {
|
|
569
577
|
readonly id: DurableObjectId;
|
|
570
578
|
readonly name?: string;
|
|
@@ -573,6 +581,7 @@ interface DurableObjectId {
|
|
|
573
581
|
toString(): string;
|
|
574
582
|
equals(other: DurableObjectId): boolean;
|
|
575
583
|
readonly name?: string;
|
|
584
|
+
readonly jurisdiction?: string;
|
|
576
585
|
}
|
|
577
586
|
declare abstract class DurableObjectNamespace<
|
|
578
587
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
@@ -3083,6 +3092,11 @@ interface QueuingStrategyInit {
|
|
|
3083
3092
|
*/
|
|
3084
3093
|
highWaterMark: number;
|
|
3085
3094
|
}
|
|
3095
|
+
interface TracePreviewInfo {
|
|
3096
|
+
id: string;
|
|
3097
|
+
slug: string;
|
|
3098
|
+
name: string;
|
|
3099
|
+
}
|
|
3086
3100
|
interface ScriptVersion {
|
|
3087
3101
|
id?: string;
|
|
3088
3102
|
tag?: string;
|
|
@@ -3097,6 +3111,7 @@ interface TraceItem {
|
|
|
3097
3111
|
| (
|
|
3098
3112
|
| TraceItemFetchEventInfo
|
|
3099
3113
|
| TraceItemJsRpcEventInfo
|
|
3114
|
+
| TraceItemConnectEventInfo
|
|
3100
3115
|
| TraceItemScheduledEventInfo
|
|
3101
3116
|
| TraceItemAlarmEventInfo
|
|
3102
3117
|
| TraceItemQueueEventInfo
|
|
@@ -3115,6 +3130,8 @@ interface TraceItem {
|
|
|
3115
3130
|
readonly scriptVersion?: ScriptVersion;
|
|
3116
3131
|
readonly dispatchNamespace?: string;
|
|
3117
3132
|
readonly scriptTags?: string[];
|
|
3133
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3134
|
+
readonly preview?: TracePreviewInfo;
|
|
3118
3135
|
readonly durableObjectId?: string;
|
|
3119
3136
|
readonly outcome: string;
|
|
3120
3137
|
readonly executionModel: string;
|
|
@@ -3125,6 +3142,7 @@ interface TraceItem {
|
|
|
3125
3142
|
interface TraceItemAlarmEventInfo {
|
|
3126
3143
|
readonly scheduledTime: Date;
|
|
3127
3144
|
}
|
|
3145
|
+
interface TraceItemConnectEventInfo {}
|
|
3128
3146
|
interface TraceItemCustomEventInfo {}
|
|
3129
3147
|
interface TraceItemScheduledEventInfo {
|
|
3130
3148
|
readonly scheduledTime: number;
|
|
@@ -3745,7 +3763,7 @@ interface ContainerStartupOptions {
|
|
|
3745
3763
|
entrypoint?: string[];
|
|
3746
3764
|
enableInternet: boolean;
|
|
3747
3765
|
env?: Record<string, string>;
|
|
3748
|
-
|
|
3766
|
+
labels?: Record<string, string>;
|
|
3749
3767
|
}
|
|
3750
3768
|
/**
|
|
3751
3769
|
* 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.
|
|
@@ -3872,11 +3890,10 @@ declare abstract class Performance {
|
|
|
3872
3890
|
*/
|
|
3873
3891
|
toJSON(): object;
|
|
3874
3892
|
}
|
|
3875
|
-
// AI Search
|
|
3893
|
+
// ============ AI Search Error Interfaces ============
|
|
3876
3894
|
interface AiSearchInternalError extends Error {}
|
|
3877
3895
|
interface AiSearchNotFoundError extends Error {}
|
|
3878
|
-
|
|
3879
|
-
// AI Search V2 Request Types
|
|
3896
|
+
// ============ AI Search Request Types ============
|
|
3880
3897
|
type AiSearchSearchRequest = {
|
|
3881
3898
|
messages: Array<{
|
|
3882
3899
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3901,9 +3918,8 @@ type AiSearchSearchRequest = {
|
|
|
3901
3918
|
[key: string]: unknown;
|
|
3902
3919
|
};
|
|
3903
3920
|
reranking?: {
|
|
3904
|
-
/** Enable reranking (default false) */
|
|
3905
3921
|
enabled?: boolean;
|
|
3906
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3922
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3907
3923
|
/** Match threshold (0-1, default 0.4) */
|
|
3908
3924
|
match_threshold?: number;
|
|
3909
3925
|
[key: string]: unknown;
|
|
@@ -3915,6 +3931,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3915
3931
|
messages: Array<{
|
|
3916
3932
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3917
3933
|
content: string | null;
|
|
3934
|
+
[key: string]: unknown;
|
|
3918
3935
|
}>;
|
|
3919
3936
|
model?: string;
|
|
3920
3937
|
stream?: boolean;
|
|
@@ -3935,7 +3952,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3935
3952
|
};
|
|
3936
3953
|
reranking?: {
|
|
3937
3954
|
enabled?: boolean;
|
|
3938
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3955
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3939
3956
|
match_threshold?: number;
|
|
3940
3957
|
[key: string]: unknown;
|
|
3941
3958
|
};
|
|
@@ -3943,7 +3960,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3943
3960
|
};
|
|
3944
3961
|
[key: string]: unknown;
|
|
3945
3962
|
};
|
|
3946
|
-
// AI Search
|
|
3963
|
+
// ============ AI Search Response Types ============
|
|
3947
3964
|
type AiSearchSearchResponse = {
|
|
3948
3965
|
search_query: string;
|
|
3949
3966
|
chunks: Array<{
|
|
@@ -3962,26 +3979,65 @@ type AiSearchSearchResponse = {
|
|
|
3962
3979
|
keyword_score?: number;
|
|
3963
3980
|
/** Vector similarity score (0-1) */
|
|
3964
3981
|
vector_score?: number;
|
|
3982
|
+
[key: string]: unknown;
|
|
3983
|
+
};
|
|
3984
|
+
}>;
|
|
3985
|
+
};
|
|
3986
|
+
type AiSearchChatCompletionsResponse = {
|
|
3987
|
+
id?: string;
|
|
3988
|
+
object?: string;
|
|
3989
|
+
model?: string;
|
|
3990
|
+
choices: Array<{
|
|
3991
|
+
index?: number;
|
|
3992
|
+
message: {
|
|
3993
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3994
|
+
content: string | null;
|
|
3995
|
+
[key: string]: unknown;
|
|
3965
3996
|
};
|
|
3997
|
+
[key: string]: unknown;
|
|
3966
3998
|
}>;
|
|
3999
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4000
|
+
[key: string]: unknown;
|
|
3967
4001
|
};
|
|
3968
|
-
type
|
|
4002
|
+
type AiSearchStatsResponse = {
|
|
4003
|
+
queued?: number;
|
|
4004
|
+
running?: number;
|
|
4005
|
+
completed?: number;
|
|
4006
|
+
error?: number;
|
|
4007
|
+
skipped?: number;
|
|
4008
|
+
outdated?: number;
|
|
4009
|
+
last_activity?: string;
|
|
4010
|
+
};
|
|
4011
|
+
// ============ AI Search Instance Info Types ============
|
|
4012
|
+
type AiSearchInstanceInfo = {
|
|
3969
4013
|
id: string;
|
|
3970
|
-
|
|
3971
|
-
account_id?: string;
|
|
3972
|
-
account_tag?: string;
|
|
3973
|
-
/** Whether the instance is enabled (default true) */
|
|
3974
|
-
enable?: boolean;
|
|
3975
|
-
type?: "r2" | "web-crawler";
|
|
4014
|
+
type?: "r2" | "web-crawler" | string;
|
|
3976
4015
|
source?: string;
|
|
4016
|
+
paused?: boolean;
|
|
4017
|
+
status?: string;
|
|
4018
|
+
namespace?: string;
|
|
4019
|
+
created_at?: string;
|
|
4020
|
+
modified_at?: string;
|
|
3977
4021
|
[key: string]: unknown;
|
|
3978
|
-
}
|
|
4022
|
+
};
|
|
4023
|
+
type AiSearchListResponse = {
|
|
4024
|
+
result: AiSearchInstanceInfo[];
|
|
4025
|
+
result_info?: {
|
|
4026
|
+
count: number;
|
|
4027
|
+
page: number;
|
|
4028
|
+
per_page: number;
|
|
4029
|
+
total_count: number;
|
|
4030
|
+
};
|
|
4031
|
+
};
|
|
4032
|
+
// ============ AI Search Config Types ============
|
|
3979
4033
|
type AiSearchConfig = {
|
|
3980
4034
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3981
4035
|
id: string;
|
|
3982
|
-
type
|
|
3983
|
-
|
|
3984
|
-
|
|
4036
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4037
|
+
type?: "r2" | "web-crawler" | string;
|
|
4038
|
+
/** Source URL (required for web-crawler type). */
|
|
4039
|
+
source?: string;
|
|
4040
|
+
source_params?: unknown;
|
|
3985
4041
|
/** Token ID (UUID format) */
|
|
3986
4042
|
token_id?: string;
|
|
3987
4043
|
ai_gateway_id?: string;
|
|
@@ -3991,54 +4047,307 @@ type AiSearchConfig = {
|
|
|
3991
4047
|
reranking?: boolean;
|
|
3992
4048
|
embedding_model?: string;
|
|
3993
4049
|
ai_search_model?: string;
|
|
4050
|
+
[key: string]: unknown;
|
|
3994
4051
|
};
|
|
3995
|
-
|
|
4052
|
+
// ============ AI Search Item Types ============
|
|
4053
|
+
type AiSearchItemInfo = {
|
|
3996
4054
|
id: string;
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4055
|
+
key: string;
|
|
4056
|
+
status:
|
|
4057
|
+
| "completed"
|
|
4058
|
+
| "error"
|
|
4059
|
+
| "skipped"
|
|
4060
|
+
| "queued"
|
|
4061
|
+
| "processing"
|
|
4062
|
+
| "outdated";
|
|
4063
|
+
metadata?: Record<string, unknown>;
|
|
4000
4064
|
[key: string]: unknown;
|
|
4001
4065
|
};
|
|
4002
|
-
|
|
4003
|
-
|
|
4066
|
+
type AiSearchItemContentResult = {
|
|
4067
|
+
body: ReadableStream;
|
|
4068
|
+
contentType: string;
|
|
4069
|
+
filename: string;
|
|
4070
|
+
size: number;
|
|
4071
|
+
};
|
|
4072
|
+
type AiSearchUploadItemOptions = {
|
|
4073
|
+
metadata?: Record<string, unknown>;
|
|
4074
|
+
};
|
|
4075
|
+
type AiSearchListItemsParams = {
|
|
4076
|
+
page?: number;
|
|
4077
|
+
per_page?: number;
|
|
4078
|
+
};
|
|
4079
|
+
type AiSearchListItemsResponse = {
|
|
4080
|
+
result: AiSearchItemInfo[];
|
|
4081
|
+
result_info?: {
|
|
4082
|
+
count: number;
|
|
4083
|
+
page: number;
|
|
4084
|
+
per_page: number;
|
|
4085
|
+
total_count: number;
|
|
4086
|
+
};
|
|
4087
|
+
};
|
|
4088
|
+
// ============ AI Search Job Types ============
|
|
4089
|
+
type AiSearchJobInfo = {
|
|
4090
|
+
id: string;
|
|
4091
|
+
source: "user" | "schedule";
|
|
4092
|
+
description?: string;
|
|
4093
|
+
last_seen_at?: string;
|
|
4094
|
+
started_at?: string;
|
|
4095
|
+
ended_at?: string;
|
|
4096
|
+
end_reason?: string;
|
|
4097
|
+
};
|
|
4098
|
+
type AiSearchJobLog = {
|
|
4099
|
+
id: number;
|
|
4100
|
+
message: string;
|
|
4101
|
+
message_type: number;
|
|
4102
|
+
created_at: number;
|
|
4103
|
+
};
|
|
4104
|
+
type AiSearchCreateJobParams = {
|
|
4105
|
+
description?: string;
|
|
4106
|
+
};
|
|
4107
|
+
type AiSearchListJobsParams = {
|
|
4108
|
+
page?: number;
|
|
4109
|
+
per_page?: number;
|
|
4110
|
+
};
|
|
4111
|
+
type AiSearchListJobsResponse = {
|
|
4112
|
+
result: AiSearchJobInfo[];
|
|
4113
|
+
result_info?: {
|
|
4114
|
+
count: number;
|
|
4115
|
+
page: number;
|
|
4116
|
+
per_page: number;
|
|
4117
|
+
total_count: number;
|
|
4118
|
+
};
|
|
4119
|
+
};
|
|
4120
|
+
type AiSearchJobLogsParams = {
|
|
4121
|
+
page?: number;
|
|
4122
|
+
per_page?: number;
|
|
4123
|
+
};
|
|
4124
|
+
type AiSearchJobLogsResponse = {
|
|
4125
|
+
result: AiSearchJobLog[];
|
|
4126
|
+
result_info?: {
|
|
4127
|
+
count: number;
|
|
4128
|
+
page: number;
|
|
4129
|
+
per_page: number;
|
|
4130
|
+
total_count: number;
|
|
4131
|
+
};
|
|
4132
|
+
};
|
|
4133
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4134
|
+
/**
|
|
4135
|
+
* Single item service for an AI Search instance.
|
|
4136
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4137
|
+
*/
|
|
4138
|
+
declare abstract class AiSearchItem {
|
|
4139
|
+
/** Get metadata about this item. */
|
|
4140
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4141
|
+
/**
|
|
4142
|
+
* Download the item's content.
|
|
4143
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4144
|
+
*/
|
|
4145
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4146
|
+
}
|
|
4147
|
+
/**
|
|
4148
|
+
* Items collection service for an AI Search instance.
|
|
4149
|
+
* Provides list, upload, and access to individual items.
|
|
4150
|
+
*/
|
|
4151
|
+
declare abstract class AiSearchItems {
|
|
4152
|
+
/** List items in this instance. */
|
|
4153
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4154
|
+
/**
|
|
4155
|
+
* Upload a file as an item.
|
|
4156
|
+
* @param name Filename for the uploaded item.
|
|
4157
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4158
|
+
* @param options Optional metadata to attach to the item.
|
|
4159
|
+
* @returns The created item info.
|
|
4160
|
+
*/
|
|
4161
|
+
upload(
|
|
4162
|
+
name: string,
|
|
4163
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4164
|
+
options?: AiSearchUploadItemOptions,
|
|
4165
|
+
): Promise<AiSearchItemInfo>;
|
|
4166
|
+
/**
|
|
4167
|
+
* Upload a file and poll until processing completes.
|
|
4168
|
+
* @param name Filename for the uploaded item.
|
|
4169
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4170
|
+
* @param options Optional metadata to attach to the item.
|
|
4171
|
+
* @returns The item info after processing completes (or timeout).
|
|
4172
|
+
*/
|
|
4173
|
+
uploadAndPoll(
|
|
4174
|
+
name: string,
|
|
4175
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4176
|
+
options?: AiSearchUploadItemOptions,
|
|
4177
|
+
): Promise<AiSearchItemInfo>;
|
|
4178
|
+
/**
|
|
4179
|
+
* Get an item by ID.
|
|
4180
|
+
* @param itemId The item identifier.
|
|
4181
|
+
* @returns Item service for info, delete, and download operations.
|
|
4182
|
+
*/
|
|
4183
|
+
get(itemId: string): AiSearchItem;
|
|
4184
|
+
/** Delete this item from the instance.
|
|
4185
|
+
* @param itemId The item identifier.
|
|
4186
|
+
*/
|
|
4187
|
+
delete(itemId: string): Promise<void>;
|
|
4188
|
+
}
|
|
4189
|
+
/**
|
|
4190
|
+
* Single job service for an AI Search instance.
|
|
4191
|
+
* Provides info and logs for a specific job.
|
|
4192
|
+
*/
|
|
4193
|
+
declare abstract class AiSearchJob {
|
|
4194
|
+
/** Get metadata about this job. */
|
|
4195
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4196
|
+
/** Get logs for this job. */
|
|
4197
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4198
|
+
}
|
|
4199
|
+
/**
|
|
4200
|
+
* Jobs collection service for an AI Search instance.
|
|
4201
|
+
* Provides list, create, and access to individual jobs.
|
|
4202
|
+
*/
|
|
4203
|
+
declare abstract class AiSearchJobs {
|
|
4204
|
+
/** List jobs for this instance. */
|
|
4205
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4206
|
+
/**
|
|
4207
|
+
* Create a new indexing job.
|
|
4208
|
+
* @param params Optional job parameters.
|
|
4209
|
+
* @returns The created job info.
|
|
4210
|
+
*/
|
|
4211
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4212
|
+
/**
|
|
4213
|
+
* Get a job by ID.
|
|
4214
|
+
* @param jobId The job identifier.
|
|
4215
|
+
* @returns Job service for info and logs operations.
|
|
4216
|
+
*/
|
|
4217
|
+
get(jobId: string): AiSearchJob;
|
|
4218
|
+
}
|
|
4219
|
+
// ============ AI Search Binding Classes ============
|
|
4220
|
+
/**
|
|
4221
|
+
* Instance-level AI Search service.
|
|
4222
|
+
*
|
|
4223
|
+
* Used as:
|
|
4224
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4225
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4226
|
+
*
|
|
4227
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4228
|
+
*
|
|
4229
|
+
* @example
|
|
4230
|
+
* ```ts
|
|
4231
|
+
* // Via namespace binding
|
|
4232
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4233
|
+
* const results = await instance.search({
|
|
4234
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4235
|
+
* });
|
|
4236
|
+
*
|
|
4237
|
+
* // Via single instance binding
|
|
4238
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4239
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4240
|
+
* });
|
|
4241
|
+
* ```
|
|
4242
|
+
*/
|
|
4243
|
+
declare abstract class AiSearchInstance {
|
|
4004
4244
|
/**
|
|
4005
4245
|
* Search the AI Search instance for relevant chunks.
|
|
4006
|
-
* @param params Search request with messages and AI search options
|
|
4007
|
-
* @returns Search response with matching chunks
|
|
4246
|
+
* @param params Search request with messages and optional AI search options.
|
|
4247
|
+
* @returns Search response with matching chunks and search query.
|
|
4008
4248
|
*/
|
|
4009
4249
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4250
|
+
/**
|
|
4251
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4252
|
+
* @param params Chat completions request with stream: true.
|
|
4253
|
+
* @returns ReadableStream of server-sent events.
|
|
4254
|
+
*/
|
|
4255
|
+
chatCompletions(
|
|
4256
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4257
|
+
stream: true;
|
|
4258
|
+
},
|
|
4259
|
+
): Promise<ReadableStream>;
|
|
4010
4260
|
/**
|
|
4011
4261
|
* Generate chat completions with AI Search context.
|
|
4012
|
-
* @param params Chat completions request
|
|
4013
|
-
* @returns
|
|
4262
|
+
* @param params Chat completions request.
|
|
4263
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4014
4264
|
*/
|
|
4015
4265
|
chatCompletions(
|
|
4016
4266
|
params: AiSearchChatCompletionsRequest,
|
|
4017
|
-
): Promise<
|
|
4267
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4018
4268
|
/**
|
|
4019
|
-
*
|
|
4269
|
+
* Update the instance configuration.
|
|
4270
|
+
* @param config Partial configuration to update.
|
|
4271
|
+
* @returns Updated instance info.
|
|
4020
4272
|
*/
|
|
4021
|
-
|
|
4273
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4274
|
+
/** Get metadata about this instance. */
|
|
4275
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4276
|
+
/**
|
|
4277
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4278
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4279
|
+
*/
|
|
4280
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4281
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4282
|
+
get items(): AiSearchItems;
|
|
4283
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4284
|
+
get jobs(): AiSearchJobs;
|
|
4022
4285
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4286
|
+
/**
|
|
4287
|
+
* Namespace-level AI Search service.
|
|
4288
|
+
*
|
|
4289
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4290
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4291
|
+
*
|
|
4292
|
+
* @example
|
|
4293
|
+
* ```ts
|
|
4294
|
+
* // Access an instance within the namespace
|
|
4295
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4296
|
+
* const results = await blog.search({
|
|
4297
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4298
|
+
* });
|
|
4299
|
+
*
|
|
4300
|
+
* // List all instances in the namespace
|
|
4301
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4302
|
+
*
|
|
4303
|
+
* // Create a new instance with built-in storage
|
|
4304
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4305
|
+
* id: "tenant-123",
|
|
4306
|
+
* });
|
|
4307
|
+
*
|
|
4308
|
+
* // Upload items into the instance
|
|
4309
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4310
|
+
*
|
|
4311
|
+
* // Delete an instance
|
|
4312
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4313
|
+
* ```
|
|
4314
|
+
*/
|
|
4315
|
+
declare abstract class AiSearchNamespace {
|
|
4025
4316
|
/**
|
|
4026
|
-
*
|
|
4027
|
-
* @
|
|
4317
|
+
* Get an instance by name within the bound namespace.
|
|
4318
|
+
* @param name Instance name.
|
|
4319
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4320
|
+
*/
|
|
4321
|
+
get(name: string): AiSearchInstance;
|
|
4322
|
+
/**
|
|
4323
|
+
* List all instances in the bound namespace.
|
|
4324
|
+
* @returns Array of instance metadata.
|
|
4028
4325
|
*/
|
|
4029
4326
|
list(): Promise<AiSearchListResponse>;
|
|
4030
4327
|
/**
|
|
4031
|
-
*
|
|
4032
|
-
* @param
|
|
4033
|
-
* @returns Instance service for
|
|
4328
|
+
* Create a new instance within the bound namespace.
|
|
4329
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4330
|
+
* @returns Instance service for the newly created instance.
|
|
4331
|
+
*
|
|
4332
|
+
* @example
|
|
4333
|
+
* ```ts
|
|
4334
|
+
* // Create with built-in storage (upload items manually)
|
|
4335
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4336
|
+
*
|
|
4337
|
+
* // Create with web crawler source
|
|
4338
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4339
|
+
* id: "docs-search",
|
|
4340
|
+
* type: "web-crawler",
|
|
4341
|
+
* source: "https://developers.cloudflare.com",
|
|
4342
|
+
* });
|
|
4343
|
+
* ```
|
|
4034
4344
|
*/
|
|
4035
|
-
|
|
4345
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4036
4346
|
/**
|
|
4037
|
-
*
|
|
4038
|
-
* @param
|
|
4039
|
-
* @returns Instance service for performing operations
|
|
4347
|
+
* Delete an instance from the bound namespace.
|
|
4348
|
+
* @param name Instance name to delete.
|
|
4040
4349
|
*/
|
|
4041
|
-
|
|
4350
|
+
delete(name: string): Promise<void>;
|
|
4042
4351
|
}
|
|
4043
4352
|
type AiImageClassificationInput = {
|
|
4044
4353
|
image: number[];
|
|
@@ -4314,6 +4623,400 @@ declare abstract class BaseAiTranslation {
|
|
|
4314
4623
|
inputs: AiTranslationInput;
|
|
4315
4624
|
postProcessedOutputs: AiTranslationOutput;
|
|
4316
4625
|
}
|
|
4626
|
+
/**
|
|
4627
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4628
|
+
*/
|
|
4629
|
+
type ChatCompletionContentPartText = {
|
|
4630
|
+
type: "text";
|
|
4631
|
+
text: string;
|
|
4632
|
+
};
|
|
4633
|
+
type ChatCompletionContentPartImage = {
|
|
4634
|
+
type: "image_url";
|
|
4635
|
+
image_url: {
|
|
4636
|
+
url: string;
|
|
4637
|
+
detail?: "auto" | "low" | "high";
|
|
4638
|
+
};
|
|
4639
|
+
};
|
|
4640
|
+
type ChatCompletionContentPartInputAudio = {
|
|
4641
|
+
type: "input_audio";
|
|
4642
|
+
input_audio: {
|
|
4643
|
+
/** Base64 encoded audio data. */
|
|
4644
|
+
data: string;
|
|
4645
|
+
format: "wav" | "mp3";
|
|
4646
|
+
};
|
|
4647
|
+
};
|
|
4648
|
+
type ChatCompletionContentPartFile = {
|
|
4649
|
+
type: "file";
|
|
4650
|
+
file: {
|
|
4651
|
+
/** Base64 encoded file data. */
|
|
4652
|
+
file_data?: string;
|
|
4653
|
+
/** The ID of an uploaded file. */
|
|
4654
|
+
file_id?: string;
|
|
4655
|
+
filename?: string;
|
|
4656
|
+
};
|
|
4657
|
+
};
|
|
4658
|
+
type ChatCompletionContentPartRefusal = {
|
|
4659
|
+
type: "refusal";
|
|
4660
|
+
refusal: string;
|
|
4661
|
+
};
|
|
4662
|
+
type ChatCompletionContentPart =
|
|
4663
|
+
| ChatCompletionContentPartText
|
|
4664
|
+
| ChatCompletionContentPartImage
|
|
4665
|
+
| ChatCompletionContentPartInputAudio
|
|
4666
|
+
| ChatCompletionContentPartFile;
|
|
4667
|
+
type FunctionDefinition = {
|
|
4668
|
+
name: string;
|
|
4669
|
+
description?: string;
|
|
4670
|
+
parameters?: Record<string, unknown>;
|
|
4671
|
+
strict?: boolean | null;
|
|
4672
|
+
};
|
|
4673
|
+
type ChatCompletionFunctionTool = {
|
|
4674
|
+
type: "function";
|
|
4675
|
+
function: FunctionDefinition;
|
|
4676
|
+
};
|
|
4677
|
+
type ChatCompletionCustomToolGrammarFormat = {
|
|
4678
|
+
type: "grammar";
|
|
4679
|
+
grammar: {
|
|
4680
|
+
definition: string;
|
|
4681
|
+
syntax: "lark" | "regex";
|
|
4682
|
+
};
|
|
4683
|
+
};
|
|
4684
|
+
type ChatCompletionCustomToolTextFormat = {
|
|
4685
|
+
type: "text";
|
|
4686
|
+
};
|
|
4687
|
+
type ChatCompletionCustomToolFormat =
|
|
4688
|
+
| ChatCompletionCustomToolTextFormat
|
|
4689
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4690
|
+
type ChatCompletionCustomTool = {
|
|
4691
|
+
type: "custom";
|
|
4692
|
+
custom: {
|
|
4693
|
+
name: string;
|
|
4694
|
+
description?: string;
|
|
4695
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4696
|
+
};
|
|
4697
|
+
};
|
|
4698
|
+
type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
|
|
4699
|
+
type ChatCompletionMessageFunctionToolCall = {
|
|
4700
|
+
id: string;
|
|
4701
|
+
type: "function";
|
|
4702
|
+
function: {
|
|
4703
|
+
name: string;
|
|
4704
|
+
/** JSON-encoded arguments string. */
|
|
4705
|
+
arguments: string;
|
|
4706
|
+
};
|
|
4707
|
+
};
|
|
4708
|
+
type ChatCompletionMessageCustomToolCall = {
|
|
4709
|
+
id: string;
|
|
4710
|
+
type: "custom";
|
|
4711
|
+
custom: {
|
|
4712
|
+
name: string;
|
|
4713
|
+
input: string;
|
|
4714
|
+
};
|
|
4715
|
+
};
|
|
4716
|
+
type ChatCompletionMessageToolCall =
|
|
4717
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4718
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4719
|
+
type ChatCompletionToolChoiceFunction = {
|
|
4720
|
+
type: "function";
|
|
4721
|
+
function: {
|
|
4722
|
+
name: string;
|
|
4723
|
+
};
|
|
4724
|
+
};
|
|
4725
|
+
type ChatCompletionToolChoiceCustom = {
|
|
4726
|
+
type: "custom";
|
|
4727
|
+
custom: {
|
|
4728
|
+
name: string;
|
|
4729
|
+
};
|
|
4730
|
+
};
|
|
4731
|
+
type ChatCompletionToolChoiceAllowedTools = {
|
|
4732
|
+
type: "allowed_tools";
|
|
4733
|
+
allowed_tools: {
|
|
4734
|
+
mode: "auto" | "required";
|
|
4735
|
+
tools: Array<Record<string, unknown>>;
|
|
4736
|
+
};
|
|
4737
|
+
};
|
|
4738
|
+
type ChatCompletionToolChoiceOption =
|
|
4739
|
+
| "none"
|
|
4740
|
+
| "auto"
|
|
4741
|
+
| "required"
|
|
4742
|
+
| ChatCompletionToolChoiceFunction
|
|
4743
|
+
| ChatCompletionToolChoiceCustom
|
|
4744
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4745
|
+
type DeveloperMessage = {
|
|
4746
|
+
role: "developer";
|
|
4747
|
+
content:
|
|
4748
|
+
| string
|
|
4749
|
+
| Array<{
|
|
4750
|
+
type: "text";
|
|
4751
|
+
text: string;
|
|
4752
|
+
}>;
|
|
4753
|
+
name?: string;
|
|
4754
|
+
};
|
|
4755
|
+
type SystemMessage = {
|
|
4756
|
+
role: "system";
|
|
4757
|
+
content:
|
|
4758
|
+
| string
|
|
4759
|
+
| Array<{
|
|
4760
|
+
type: "text";
|
|
4761
|
+
text: string;
|
|
4762
|
+
}>;
|
|
4763
|
+
name?: string;
|
|
4764
|
+
};
|
|
4765
|
+
/**
|
|
4766
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4767
|
+
*
|
|
4768
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4769
|
+
* inside nested array items does not correctly match different branches for
|
|
4770
|
+
* different array elements, so the schema uses a single merged object.
|
|
4771
|
+
*/
|
|
4772
|
+
type UserMessageContentPart = {
|
|
4773
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4774
|
+
text?: string;
|
|
4775
|
+
image_url?: {
|
|
4776
|
+
url?: string;
|
|
4777
|
+
detail?: "auto" | "low" | "high";
|
|
4778
|
+
};
|
|
4779
|
+
input_audio?: {
|
|
4780
|
+
data?: string;
|
|
4781
|
+
format?: "wav" | "mp3";
|
|
4782
|
+
};
|
|
4783
|
+
file?: {
|
|
4784
|
+
file_data?: string;
|
|
4785
|
+
file_id?: string;
|
|
4786
|
+
filename?: string;
|
|
4787
|
+
};
|
|
4788
|
+
};
|
|
4789
|
+
type UserMessage = {
|
|
4790
|
+
role: "user";
|
|
4791
|
+
content: string | Array<UserMessageContentPart>;
|
|
4792
|
+
name?: string;
|
|
4793
|
+
};
|
|
4794
|
+
type AssistantMessageContentPart = {
|
|
4795
|
+
type: "text" | "refusal";
|
|
4796
|
+
text?: string;
|
|
4797
|
+
refusal?: string;
|
|
4798
|
+
};
|
|
4799
|
+
type AssistantMessage = {
|
|
4800
|
+
role: "assistant";
|
|
4801
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4802
|
+
refusal?: string | null;
|
|
4803
|
+
name?: string;
|
|
4804
|
+
audio?: {
|
|
4805
|
+
id: string;
|
|
4806
|
+
};
|
|
4807
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4808
|
+
function_call?: {
|
|
4809
|
+
name: string;
|
|
4810
|
+
arguments: string;
|
|
4811
|
+
};
|
|
4812
|
+
};
|
|
4813
|
+
type ToolMessage = {
|
|
4814
|
+
role: "tool";
|
|
4815
|
+
content:
|
|
4816
|
+
| string
|
|
4817
|
+
| Array<{
|
|
4818
|
+
type: "text";
|
|
4819
|
+
text: string;
|
|
4820
|
+
}>;
|
|
4821
|
+
tool_call_id: string;
|
|
4822
|
+
};
|
|
4823
|
+
type FunctionMessage = {
|
|
4824
|
+
role: "function";
|
|
4825
|
+
content: string;
|
|
4826
|
+
name: string;
|
|
4827
|
+
};
|
|
4828
|
+
type ChatCompletionMessageParam =
|
|
4829
|
+
| DeveloperMessage
|
|
4830
|
+
| SystemMessage
|
|
4831
|
+
| UserMessage
|
|
4832
|
+
| AssistantMessage
|
|
4833
|
+
| ToolMessage
|
|
4834
|
+
| FunctionMessage;
|
|
4835
|
+
type ChatCompletionsResponseFormatText = {
|
|
4836
|
+
type: "text";
|
|
4837
|
+
};
|
|
4838
|
+
type ChatCompletionsResponseFormatJSONObject = {
|
|
4839
|
+
type: "json_object";
|
|
4840
|
+
};
|
|
4841
|
+
type ResponseFormatJSONSchema = {
|
|
4842
|
+
type: "json_schema";
|
|
4843
|
+
json_schema: {
|
|
4844
|
+
name: string;
|
|
4845
|
+
description?: string;
|
|
4846
|
+
schema?: Record<string, unknown>;
|
|
4847
|
+
strict?: boolean | null;
|
|
4848
|
+
};
|
|
4849
|
+
};
|
|
4850
|
+
type ResponseFormat =
|
|
4851
|
+
| ChatCompletionsResponseFormatText
|
|
4852
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4853
|
+
| ResponseFormatJSONSchema;
|
|
4854
|
+
type ChatCompletionsStreamOptions = {
|
|
4855
|
+
include_usage?: boolean;
|
|
4856
|
+
include_obfuscation?: boolean;
|
|
4857
|
+
};
|
|
4858
|
+
type PredictionContent = {
|
|
4859
|
+
type: "content";
|
|
4860
|
+
content:
|
|
4861
|
+
| string
|
|
4862
|
+
| Array<{
|
|
4863
|
+
type: "text";
|
|
4864
|
+
text: string;
|
|
4865
|
+
}>;
|
|
4866
|
+
};
|
|
4867
|
+
type AudioParams = {
|
|
4868
|
+
voice:
|
|
4869
|
+
| string
|
|
4870
|
+
| {
|
|
4871
|
+
id: string;
|
|
4872
|
+
};
|
|
4873
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4874
|
+
};
|
|
4875
|
+
type WebSearchUserLocation = {
|
|
4876
|
+
type: "approximate";
|
|
4877
|
+
approximate: {
|
|
4878
|
+
city?: string;
|
|
4879
|
+
country?: string;
|
|
4880
|
+
region?: string;
|
|
4881
|
+
timezone?: string;
|
|
4882
|
+
};
|
|
4883
|
+
};
|
|
4884
|
+
type WebSearchOptions = {
|
|
4885
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4886
|
+
user_location?: WebSearchUserLocation;
|
|
4887
|
+
};
|
|
4888
|
+
type ChatTemplateKwargs = {
|
|
4889
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4890
|
+
enable_thinking?: boolean;
|
|
4891
|
+
/** If false, preserves reasoning context between turns. */
|
|
4892
|
+
clear_thinking?: boolean;
|
|
4893
|
+
};
|
|
4894
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4895
|
+
type ChatCompletionsCommonOptions = {
|
|
4896
|
+
model?: string;
|
|
4897
|
+
audio?: AudioParams;
|
|
4898
|
+
frequency_penalty?: number | null;
|
|
4899
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4900
|
+
logprobs?: boolean | null;
|
|
4901
|
+
top_logprobs?: number | null;
|
|
4902
|
+
max_tokens?: number | null;
|
|
4903
|
+
max_completion_tokens?: number | null;
|
|
4904
|
+
metadata?: Record<string, unknown> | null;
|
|
4905
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4906
|
+
n?: number | null;
|
|
4907
|
+
parallel_tool_calls?: boolean;
|
|
4908
|
+
prediction?: PredictionContent;
|
|
4909
|
+
presence_penalty?: number | null;
|
|
4910
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4911
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4912
|
+
response_format?: ResponseFormat;
|
|
4913
|
+
seed?: number | null;
|
|
4914
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4915
|
+
stop?: string | Array<string> | null;
|
|
4916
|
+
store?: boolean | null;
|
|
4917
|
+
stream?: boolean | null;
|
|
4918
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4919
|
+
temperature?: number | null;
|
|
4920
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4921
|
+
tools?: Array<ChatCompletionTool>;
|
|
4922
|
+
top_p?: number | null;
|
|
4923
|
+
user?: string;
|
|
4924
|
+
web_search_options?: WebSearchOptions;
|
|
4925
|
+
function_call?:
|
|
4926
|
+
| "none"
|
|
4927
|
+
| "auto"
|
|
4928
|
+
| {
|
|
4929
|
+
name: string;
|
|
4930
|
+
};
|
|
4931
|
+
functions?: Array<FunctionDefinition>;
|
|
4932
|
+
};
|
|
4933
|
+
type PromptTokensDetails = {
|
|
4934
|
+
cached_tokens?: number;
|
|
4935
|
+
audio_tokens?: number;
|
|
4936
|
+
};
|
|
4937
|
+
type CompletionTokensDetails = {
|
|
4938
|
+
reasoning_tokens?: number;
|
|
4939
|
+
audio_tokens?: number;
|
|
4940
|
+
accepted_prediction_tokens?: number;
|
|
4941
|
+
rejected_prediction_tokens?: number;
|
|
4942
|
+
};
|
|
4943
|
+
type CompletionUsage = {
|
|
4944
|
+
prompt_tokens: number;
|
|
4945
|
+
completion_tokens: number;
|
|
4946
|
+
total_tokens: number;
|
|
4947
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4948
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4949
|
+
};
|
|
4950
|
+
type ChatCompletionTopLogprob = {
|
|
4951
|
+
token: string;
|
|
4952
|
+
logprob: number;
|
|
4953
|
+
bytes: Array<number> | null;
|
|
4954
|
+
};
|
|
4955
|
+
type ChatCompletionTokenLogprob = {
|
|
4956
|
+
token: string;
|
|
4957
|
+
logprob: number;
|
|
4958
|
+
bytes: Array<number> | null;
|
|
4959
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4960
|
+
};
|
|
4961
|
+
type ChatCompletionAudio = {
|
|
4962
|
+
id: string;
|
|
4963
|
+
/** Base64 encoded audio bytes. */
|
|
4964
|
+
data: string;
|
|
4965
|
+
expires_at: number;
|
|
4966
|
+
transcript: string;
|
|
4967
|
+
};
|
|
4968
|
+
type ChatCompletionUrlCitation = {
|
|
4969
|
+
type: "url_citation";
|
|
4970
|
+
url_citation: {
|
|
4971
|
+
url: string;
|
|
4972
|
+
title: string;
|
|
4973
|
+
start_index: number;
|
|
4974
|
+
end_index: number;
|
|
4975
|
+
};
|
|
4976
|
+
};
|
|
4977
|
+
type ChatCompletionResponseMessage = {
|
|
4978
|
+
role: "assistant";
|
|
4979
|
+
content: string | null;
|
|
4980
|
+
refusal: string | null;
|
|
4981
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
4982
|
+
audio?: ChatCompletionAudio;
|
|
4983
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4984
|
+
function_call?: {
|
|
4985
|
+
name: string;
|
|
4986
|
+
arguments: string;
|
|
4987
|
+
} | null;
|
|
4988
|
+
};
|
|
4989
|
+
type ChatCompletionLogprobs = {
|
|
4990
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
4991
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
4992
|
+
};
|
|
4993
|
+
type ChatCompletionChoice = {
|
|
4994
|
+
index: number;
|
|
4995
|
+
message: ChatCompletionResponseMessage;
|
|
4996
|
+
finish_reason:
|
|
4997
|
+
| "stop"
|
|
4998
|
+
| "length"
|
|
4999
|
+
| "tool_calls"
|
|
5000
|
+
| "content_filter"
|
|
5001
|
+
| "function_call";
|
|
5002
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
5003
|
+
};
|
|
5004
|
+
type ChatCompletionsPromptInput = {
|
|
5005
|
+
prompt: string;
|
|
5006
|
+
} & ChatCompletionsCommonOptions;
|
|
5007
|
+
type ChatCompletionsMessagesInput = {
|
|
5008
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
5009
|
+
} & ChatCompletionsCommonOptions;
|
|
5010
|
+
type ChatCompletionsOutput = {
|
|
5011
|
+
id: string;
|
|
5012
|
+
object: string;
|
|
5013
|
+
created: number;
|
|
5014
|
+
model: string;
|
|
5015
|
+
choices: Array<ChatCompletionChoice>;
|
|
5016
|
+
usage?: CompletionUsage;
|
|
5017
|
+
system_fingerprint?: string | null;
|
|
5018
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
5019
|
+
};
|
|
4317
5020
|
/**
|
|
4318
5021
|
* Workers AI support for OpenAI's Responses API
|
|
4319
5022
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4735,6 +5438,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4735
5438
|
type StreamOptions = {
|
|
4736
5439
|
include_obfuscation?: boolean;
|
|
4737
5440
|
};
|
|
5441
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5442
|
+
type Without<T, U> = {
|
|
5443
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5444
|
+
};
|
|
5445
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5446
|
+
type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4738
5447
|
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4739
5448
|
| {
|
|
4740
5449
|
text: string | string[];
|
|
@@ -5027,10 +5736,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5027
5736
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5028
5737
|
}
|
|
5029
5738
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5739
|
+
audio:
|
|
5740
|
+
| string
|
|
5741
|
+
| {
|
|
5742
|
+
body?: object;
|
|
5743
|
+
contentType?: string;
|
|
5744
|
+
};
|
|
5034
5745
|
/**
|
|
5035
5746
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5036
5747
|
*/
|
|
@@ -5048,9 +5759,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5048
5759
|
*/
|
|
5049
5760
|
initial_prompt?: string;
|
|
5050
5761
|
/**
|
|
5051
|
-
* The prefix
|
|
5762
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5052
5763
|
*/
|
|
5053
5764
|
prefix?: string;
|
|
5765
|
+
/**
|
|
5766
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5767
|
+
*/
|
|
5768
|
+
beam_size?: number;
|
|
5769
|
+
/**
|
|
5770
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5771
|
+
*/
|
|
5772
|
+
condition_on_previous_text?: boolean;
|
|
5773
|
+
/**
|
|
5774
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5775
|
+
*/
|
|
5776
|
+
no_speech_threshold?: number;
|
|
5777
|
+
/**
|
|
5778
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5779
|
+
*/
|
|
5780
|
+
compression_ratio_threshold?: number;
|
|
5781
|
+
/**
|
|
5782
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5783
|
+
*/
|
|
5784
|
+
log_prob_threshold?: number;
|
|
5785
|
+
/**
|
|
5786
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5787
|
+
*/
|
|
5788
|
+
hallucination_silence_threshold?: number;
|
|
5054
5789
|
}
|
|
5055
5790
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5056
5791
|
transcription_info?: {
|
|
@@ -5197,11 +5932,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5197
5932
|
truncate_inputs?: boolean;
|
|
5198
5933
|
}
|
|
5199
5934
|
type Ai_Cf_Baai_Bge_M3_Output =
|
|
5200
|
-
|
|
|
5935
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5201
5936
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5202
|
-
|
|
|
5937
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5203
5938
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5204
|
-
interface
|
|
5939
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5205
5940
|
response?: {
|
|
5206
5941
|
/**
|
|
5207
5942
|
* Index of the context in the request
|
|
@@ -5221,7 +5956,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5221
5956
|
*/
|
|
5222
5957
|
pooling?: "mean" | "cls";
|
|
5223
5958
|
}
|
|
5224
|
-
interface
|
|
5959
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5225
5960
|
shape?: number[];
|
|
5226
5961
|
/**
|
|
5227
5962
|
* Embeddings of the requested text values
|
|
@@ -5326,7 +6061,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5326
6061
|
*/
|
|
5327
6062
|
role?: string;
|
|
5328
6063
|
/**
|
|
5329
|
-
* The tool call id.
|
|
6064
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5330
6065
|
*/
|
|
5331
6066
|
tool_call_id?: string;
|
|
5332
6067
|
content?:
|
|
@@ -5581,10 +6316,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5581
6316
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5582
6317
|
*/
|
|
5583
6318
|
role: string;
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
6319
|
+
content:
|
|
6320
|
+
| string
|
|
6321
|
+
| {
|
|
6322
|
+
/**
|
|
6323
|
+
* Type of the content (text)
|
|
6324
|
+
*/
|
|
6325
|
+
type?: string;
|
|
6326
|
+
/**
|
|
6327
|
+
* Text content
|
|
6328
|
+
*/
|
|
6329
|
+
text?: string;
|
|
6330
|
+
}[];
|
|
5588
6331
|
}[];
|
|
5589
6332
|
functions?: {
|
|
5590
6333
|
name: string;
|
|
@@ -6240,7 +6983,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6240
6983
|
*/
|
|
6241
6984
|
role?: string;
|
|
6242
6985
|
/**
|
|
6243
|
-
* The tool call id.
|
|
6986
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6244
6987
|
*/
|
|
6245
6988
|
tool_call_id?: string;
|
|
6246
6989
|
content?:
|
|
@@ -6367,7 +7110,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6367
7110
|
}
|
|
6368
7111
|
)[];
|
|
6369
7112
|
/**
|
|
6370
|
-
* JSON schema that should be
|
|
7113
|
+
* JSON schema that should be fufilled for the response.
|
|
6371
7114
|
*/
|
|
6372
7115
|
guided_json?: object;
|
|
6373
7116
|
/**
|
|
@@ -6641,7 +7384,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6641
7384
|
}
|
|
6642
7385
|
)[];
|
|
6643
7386
|
/**
|
|
6644
|
-
* JSON schema that should be
|
|
7387
|
+
* JSON schema that should be fufilled for the response.
|
|
6645
7388
|
*/
|
|
6646
7389
|
guided_json?: object;
|
|
6647
7390
|
/**
|
|
@@ -6734,7 +7477,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6734
7477
|
*/
|
|
6735
7478
|
prompt: string;
|
|
6736
7479
|
/**
|
|
6737
|
-
* JSON schema that should be
|
|
7480
|
+
* JSON schema that should be fufilled for the response.
|
|
6738
7481
|
*/
|
|
6739
7482
|
guided_json?: object;
|
|
6740
7483
|
/**
|
|
@@ -6898,7 +7641,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6898
7641
|
}
|
|
6899
7642
|
)[];
|
|
6900
7643
|
/**
|
|
6901
|
-
* JSON schema that should be
|
|
7644
|
+
* JSON schema that should be fufilled for the response.
|
|
6902
7645
|
*/
|
|
6903
7646
|
guided_json?: object;
|
|
6904
7647
|
/**
|
|
@@ -7179,7 +7922,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7179
7922
|
)[];
|
|
7180
7923
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7181
7924
|
/**
|
|
7182
|
-
* JSON schema that should be
|
|
7925
|
+
* JSON schema that should be fufilled for the response.
|
|
7183
7926
|
*/
|
|
7184
7927
|
guided_json?: object;
|
|
7185
7928
|
/**
|
|
@@ -7418,7 +8161,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7418
8161
|
)[];
|
|
7419
8162
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7420
8163
|
/**
|
|
7421
|
-
* JSON schema that should be
|
|
8164
|
+
* JSON schema that should be fufilled for the response.
|
|
7422
8165
|
*/
|
|
7423
8166
|
guided_json?: object;
|
|
7424
8167
|
/**
|
|
@@ -7583,10 +8326,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7583
8326
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7584
8327
|
*/
|
|
7585
8328
|
role: string;
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
8329
|
+
content:
|
|
8330
|
+
| string
|
|
8331
|
+
| {
|
|
8332
|
+
/**
|
|
8333
|
+
* Type of the content (text)
|
|
8334
|
+
*/
|
|
8335
|
+
type?: string;
|
|
8336
|
+
/**
|
|
8337
|
+
* Text content
|
|
8338
|
+
*/
|
|
8339
|
+
text?: string;
|
|
8340
|
+
}[];
|
|
7590
8341
|
}[];
|
|
7591
8342
|
functions?: {
|
|
7592
8343
|
name: string;
|
|
@@ -7798,10 +8549,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7798
8549
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7799
8550
|
*/
|
|
7800
8551
|
role: string;
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
8552
|
+
content:
|
|
8553
|
+
| string
|
|
8554
|
+
| {
|
|
8555
|
+
/**
|
|
8556
|
+
* Type of the content (text)
|
|
8557
|
+
*/
|
|
8558
|
+
type?: string;
|
|
8559
|
+
/**
|
|
8560
|
+
* Text content
|
|
8561
|
+
*/
|
|
8562
|
+
text?: string;
|
|
8563
|
+
}[];
|
|
7805
8564
|
}[];
|
|
7806
8565
|
functions?: {
|
|
7807
8566
|
name: string;
|
|
@@ -8369,12 +9128,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8369
9128
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8370
9129
|
}
|
|
8371
9130
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8372
|
-
inputs: ResponsesInput
|
|
8373
|
-
postProcessedOutputs: ResponsesOutput
|
|
9131
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9132
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8374
9133
|
}
|
|
8375
9134
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8376
|
-
inputs: ResponsesInput
|
|
8377
|
-
postProcessedOutputs: ResponsesOutput
|
|
9135
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9136
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8378
9137
|
}
|
|
8379
9138
|
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8380
9139
|
/**
|
|
@@ -8506,7 +9265,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8506
9265
|
*/
|
|
8507
9266
|
text: string | string[];
|
|
8508
9267
|
/**
|
|
8509
|
-
* Target
|
|
9268
|
+
* Target langauge to translate to
|
|
8510
9269
|
*/
|
|
8511
9270
|
target_language:
|
|
8512
9271
|
| "asm_Beng"
|
|
@@ -8622,10 +9381,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8622
9381
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8623
9382
|
*/
|
|
8624
9383
|
role: string;
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
9384
|
+
content:
|
|
9385
|
+
| string
|
|
9386
|
+
| {
|
|
9387
|
+
/**
|
|
9388
|
+
* Type of the content (text)
|
|
9389
|
+
*/
|
|
9390
|
+
type?: string;
|
|
9391
|
+
/**
|
|
9392
|
+
* Text content
|
|
9393
|
+
*/
|
|
9394
|
+
text?: string;
|
|
9395
|
+
}[];
|
|
8629
9396
|
}[];
|
|
8630
9397
|
functions?: {
|
|
8631
9398
|
name: string;
|
|
@@ -8837,10 +9604,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8837
9604
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8838
9605
|
*/
|
|
8839
9606
|
role: string;
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
9607
|
+
content:
|
|
9608
|
+
| string
|
|
9609
|
+
| {
|
|
9610
|
+
/**
|
|
9611
|
+
* Type of the content (text)
|
|
9612
|
+
*/
|
|
9613
|
+
type?: string;
|
|
9614
|
+
/**
|
|
9615
|
+
* Text content
|
|
9616
|
+
*/
|
|
9617
|
+
text?: string;
|
|
9618
|
+
}[];
|
|
8844
9619
|
}[];
|
|
8845
9620
|
functions?: {
|
|
8846
9621
|
name: string;
|
|
@@ -9395,6 +10170,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9395
10170
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9396
10171
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9397
10172
|
}
|
|
10173
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10174
|
+
multipart: {
|
|
10175
|
+
body?: object;
|
|
10176
|
+
contentType?: string;
|
|
10177
|
+
};
|
|
10178
|
+
}
|
|
10179
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10180
|
+
/**
|
|
10181
|
+
* Generated image as Base64 string.
|
|
10182
|
+
*/
|
|
10183
|
+
image?: string;
|
|
10184
|
+
}
|
|
10185
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10186
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10187
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10188
|
+
}
|
|
10189
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10190
|
+
multipart: {
|
|
10191
|
+
body?: object;
|
|
10192
|
+
contentType?: string;
|
|
10193
|
+
};
|
|
10194
|
+
}
|
|
10195
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10196
|
+
/**
|
|
10197
|
+
* Generated image as Base64 string.
|
|
10198
|
+
*/
|
|
10199
|
+
image?: string;
|
|
10200
|
+
}
|
|
10201
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10202
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10203
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10204
|
+
}
|
|
10205
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10206
|
+
multipart: {
|
|
10207
|
+
body?: object;
|
|
10208
|
+
contentType?: string;
|
|
10209
|
+
};
|
|
10210
|
+
}
|
|
10211
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10212
|
+
/**
|
|
10213
|
+
* Generated image as Base64 string.
|
|
10214
|
+
*/
|
|
10215
|
+
image?: string;
|
|
10216
|
+
}
|
|
10217
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10218
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10219
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10220
|
+
}
|
|
10221
|
+
declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10222
|
+
inputs: ChatCompletionsInput;
|
|
10223
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10224
|
+
}
|
|
10225
|
+
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10226
|
+
inputs: ChatCompletionsInput;
|
|
10227
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10228
|
+
}
|
|
10229
|
+
declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10230
|
+
inputs: ChatCompletionsInput;
|
|
10231
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10232
|
+
}
|
|
9398
10233
|
interface AiModels {
|
|
9399
10234
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9400
10235
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9413,7 +10248,6 @@ interface AiModels {
|
|
|
9413
10248
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9414
10249
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9415
10250
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9416
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9417
10251
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9418
10252
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9419
10253
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9480,6 +10314,12 @@ interface AiModels {
|
|
|
9480
10314
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9481
10315
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9482
10316
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10317
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10318
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10319
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10320
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10321
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10322
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9483
10323
|
}
|
|
9484
10324
|
type AiOptions = {
|
|
9485
10325
|
/**
|
|
@@ -9505,6 +10345,7 @@ type AiOptions = {
|
|
|
9505
10345
|
returnRawResponse?: boolean;
|
|
9506
10346
|
prefix?: string;
|
|
9507
10347
|
extraHeaders?: object;
|
|
10348
|
+
signal?: AbortSignal;
|
|
9508
10349
|
};
|
|
9509
10350
|
type AiModelsSearchParams = {
|
|
9510
10351
|
author?: string;
|
|
@@ -9531,6 +10372,16 @@ type AiModelsSearchObject = {
|
|
|
9531
10372
|
value: string;
|
|
9532
10373
|
}[];
|
|
9533
10374
|
};
|
|
10375
|
+
type ChatCompletionsBase = XOR<
|
|
10376
|
+
ChatCompletionsPromptInput,
|
|
10377
|
+
ChatCompletionsMessagesInput
|
|
10378
|
+
>;
|
|
10379
|
+
type ChatCompletionsInput = XOR<
|
|
10380
|
+
ChatCompletionsBase,
|
|
10381
|
+
{
|
|
10382
|
+
requests: ChatCompletionsBase[];
|
|
10383
|
+
}
|
|
10384
|
+
>;
|
|
9534
10385
|
interface InferenceUpstreamError extends Error {}
|
|
9535
10386
|
interface AiInternalError extends Error {}
|
|
9536
10387
|
type AiModelListType = Record<string, any>;
|
|
@@ -9538,46 +10389,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
9538
10389
|
aiGatewayLogId: string | null;
|
|
9539
10390
|
gateway(gatewayId: string): AiGateway;
|
|
9540
10391
|
/**
|
|
9541
|
-
*
|
|
9542
|
-
*
|
|
9543
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9544
|
-
* - Account-level operations: `list()`, `create()`
|
|
9545
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9546
|
-
*
|
|
9547
|
-
* @example
|
|
9548
|
-
* ```typescript
|
|
9549
|
-
* // List all AI Search instances
|
|
9550
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9551
|
-
*
|
|
9552
|
-
* // Search an instance
|
|
9553
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9554
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9555
|
-
* ai_search_options: {
|
|
9556
|
-
* retrieval: { max_num_results: 10 }
|
|
9557
|
-
* }
|
|
9558
|
-
* });
|
|
9559
|
-
*
|
|
9560
|
-
* // Generate chat completions with AI Search context
|
|
9561
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9562
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9563
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9564
|
-
* });
|
|
9565
|
-
* ```
|
|
10392
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10393
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9566
10394
|
*/
|
|
9567
|
-
aiSearch():
|
|
10395
|
+
aiSearch(): AiSearchNamespace;
|
|
9568
10396
|
/**
|
|
9569
10397
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9570
|
-
* Use `
|
|
9571
|
-
*
|
|
9572
|
-
* Migration guide:
|
|
9573
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9574
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9575
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10398
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10399
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9576
10400
|
*
|
|
9577
|
-
*
|
|
9578
|
-
*
|
|
9579
|
-
* @see AiSearchAccountService
|
|
9580
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10401
|
+
* @param autoragId Instance ID
|
|
9581
10402
|
*/
|
|
9582
10403
|
autorag(autoragId: string): AutoRAG;
|
|
9583
10404
|
run<
|
|
@@ -9736,22 +10557,23 @@ declare abstract class AiGateway {
|
|
|
9736
10557
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9737
10558
|
}
|
|
9738
10559
|
/**
|
|
9739
|
-
* @deprecated
|
|
9740
|
-
*
|
|
10560
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10561
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9741
10562
|
*/
|
|
9742
10563
|
interface AutoRAGInternalError extends Error {}
|
|
9743
10564
|
/**
|
|
9744
|
-
* @deprecated
|
|
9745
|
-
*
|
|
10565
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10566
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9746
10567
|
*/
|
|
9747
10568
|
interface AutoRAGNotFoundError extends Error {}
|
|
9748
10569
|
/**
|
|
9749
|
-
* @deprecated
|
|
10570
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10571
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9750
10572
|
*/
|
|
9751
10573
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
9752
10574
|
/**
|
|
9753
|
-
* @deprecated
|
|
9754
|
-
*
|
|
10575
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10576
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9755
10577
|
*/
|
|
9756
10578
|
interface AutoRAGNameNotSetError extends Error {}
|
|
9757
10579
|
type ComparisonFilter = {
|
|
@@ -9764,9 +10586,8 @@ type CompoundFilter = {
|
|
|
9764
10586
|
filters: ComparisonFilter[];
|
|
9765
10587
|
};
|
|
9766
10588
|
/**
|
|
9767
|
-
* @deprecated
|
|
9768
|
-
*
|
|
9769
|
-
* @see AiSearchSearchRequest
|
|
10589
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10590
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9770
10591
|
*/
|
|
9771
10592
|
type AutoRagSearchRequest = {
|
|
9772
10593
|
query: string;
|
|
@@ -9783,18 +10604,16 @@ type AutoRagSearchRequest = {
|
|
|
9783
10604
|
rewrite_query?: boolean;
|
|
9784
10605
|
};
|
|
9785
10606
|
/**
|
|
9786
|
-
* @deprecated
|
|
9787
|
-
*
|
|
9788
|
-
* @see AiSearchChatCompletionsRequest
|
|
10607
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10608
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9789
10609
|
*/
|
|
9790
10610
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9791
10611
|
stream?: boolean;
|
|
9792
10612
|
system_prompt?: string;
|
|
9793
10613
|
};
|
|
9794
10614
|
/**
|
|
9795
|
-
* @deprecated
|
|
9796
|
-
*
|
|
9797
|
-
* @see AiSearchChatCompletionsRequest
|
|
10615
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10616
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9798
10617
|
*/
|
|
9799
10618
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
9800
10619
|
AutoRagAiSearchRequest,
|
|
@@ -9803,9 +10622,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9803
10622
|
stream: true;
|
|
9804
10623
|
};
|
|
9805
10624
|
/**
|
|
9806
|
-
* @deprecated
|
|
9807
|
-
*
|
|
9808
|
-
* @see AiSearchSearchResponse
|
|
10625
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10626
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9809
10627
|
*/
|
|
9810
10628
|
type AutoRagSearchResponse = {
|
|
9811
10629
|
object: "vector_store.search_results.page";
|
|
@@ -9824,9 +10642,8 @@ type AutoRagSearchResponse = {
|
|
|
9824
10642
|
next_page: string | null;
|
|
9825
10643
|
};
|
|
9826
10644
|
/**
|
|
9827
|
-
* @deprecated
|
|
9828
|
-
*
|
|
9829
|
-
* @see AiSearchListResponse
|
|
10645
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10646
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9830
10647
|
*/
|
|
9831
10648
|
type AutoRagListResponse = {
|
|
9832
10649
|
id: string;
|
|
@@ -9838,49 +10655,40 @@ type AutoRagListResponse = {
|
|
|
9838
10655
|
status: string;
|
|
9839
10656
|
}[];
|
|
9840
10657
|
/**
|
|
9841
|
-
* @deprecated
|
|
9842
|
-
*
|
|
10658
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10659
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9843
10660
|
*/
|
|
9844
10661
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9845
10662
|
response: string;
|
|
9846
10663
|
};
|
|
9847
10664
|
/**
|
|
9848
|
-
* @deprecated
|
|
9849
|
-
*
|
|
9850
|
-
*
|
|
9851
|
-
* Migration guide:
|
|
9852
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9853
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9854
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9855
|
-
*
|
|
9856
|
-
* @see AiSearchAccountService
|
|
9857
|
-
* @see AiSearchInstanceService
|
|
10665
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10666
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9858
10667
|
*/
|
|
9859
10668
|
declare abstract class AutoRAG {
|
|
9860
10669
|
/**
|
|
9861
|
-
* @deprecated Use
|
|
9862
|
-
*
|
|
10670
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10671
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9863
10672
|
*/
|
|
9864
10673
|
list(): Promise<AutoRagListResponse>;
|
|
9865
10674
|
/**
|
|
9866
|
-
* @deprecated Use
|
|
9867
|
-
*
|
|
9868
|
-
* @see AiSearchInstanceService.search
|
|
10675
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10676
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9869
10677
|
*/
|
|
9870
10678
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9871
10679
|
/**
|
|
9872
|
-
* @deprecated Use
|
|
9873
|
-
*
|
|
10680
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10681
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9874
10682
|
*/
|
|
9875
10683
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9876
10684
|
/**
|
|
9877
|
-
* @deprecated Use
|
|
9878
|
-
*
|
|
10685
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10686
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9879
10687
|
*/
|
|
9880
10688
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9881
10689
|
/**
|
|
9882
|
-
* @deprecated Use
|
|
9883
|
-
*
|
|
10690
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10691
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9884
10692
|
*/
|
|
9885
10693
|
aiSearch(
|
|
9886
10694
|
params: AutoRagAiSearchRequest,
|
|
@@ -10005,6 +10813,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
10005
10813
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
10006
10814
|
*/
|
|
10007
10815
|
cacheTtlByStatus?: Record<string, number>;
|
|
10816
|
+
/**
|
|
10817
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10818
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10819
|
+
*
|
|
10820
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10821
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10822
|
+
*
|
|
10823
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10824
|
+
*/
|
|
10825
|
+
cacheControl?: string;
|
|
10826
|
+
/**
|
|
10827
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10828
|
+
*/
|
|
10829
|
+
cacheReserveEligible?: boolean;
|
|
10830
|
+
/**
|
|
10831
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10832
|
+
*/
|
|
10833
|
+
respectStrongEtag?: boolean;
|
|
10834
|
+
/**
|
|
10835
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10836
|
+
*/
|
|
10837
|
+
stripEtags?: boolean;
|
|
10838
|
+
/**
|
|
10839
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10840
|
+
*/
|
|
10841
|
+
stripLastModified?: boolean;
|
|
10842
|
+
/**
|
|
10843
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10844
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10845
|
+
*/
|
|
10846
|
+
cacheDeceptionArmor?: boolean;
|
|
10847
|
+
/**
|
|
10848
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10849
|
+
*/
|
|
10850
|
+
cacheReserveMinimumFileSize?: number;
|
|
10008
10851
|
scrapeShield?: boolean;
|
|
10009
10852
|
apps?: boolean;
|
|
10010
10853
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11917,6 +12760,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11917
12760
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11918
12761
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11919
12762
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12763
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11920
12764
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11921
12765
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11922
12766
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11937,6 +12781,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11937
12781
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11938
12782
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11939
12783
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12784
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11940
12785
|
webSocketMessage?(
|
|
11941
12786
|
ws: WebSocket,
|
|
11942
12787
|
message: string | ArrayBuffer,
|
|
@@ -12087,17 +12932,6 @@ interface StreamBinding {
|
|
|
12087
12932
|
* @returns A handle for per-video operations.
|
|
12088
12933
|
*/
|
|
12089
12934
|
video(id: string): StreamVideoHandle;
|
|
12090
|
-
/**
|
|
12091
|
-
* Uploads a new video from a File.
|
|
12092
|
-
* @param file The video file to upload.
|
|
12093
|
-
* @returns The uploaded video details.
|
|
12094
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12095
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12096
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12097
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12098
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12099
|
-
*/
|
|
12100
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12101
12935
|
/**
|
|
12102
12936
|
* Uploads a new video from a provided URL.
|
|
12103
12937
|
* @param url The URL to upload from.
|
|
@@ -12947,6 +13781,9 @@ declare namespace TailStream {
|
|
|
12947
13781
|
readonly type: "fetch";
|
|
12948
13782
|
readonly statusCode: number;
|
|
12949
13783
|
}
|
|
13784
|
+
interface ConnectEventInfo {
|
|
13785
|
+
readonly type: "connect";
|
|
13786
|
+
}
|
|
12950
13787
|
type EventOutcome =
|
|
12951
13788
|
| "ok"
|
|
12952
13789
|
| "canceled"
|
|
@@ -12977,6 +13814,7 @@ declare namespace TailStream {
|
|
|
12977
13814
|
readonly scriptVersion?: ScriptVersion;
|
|
12978
13815
|
readonly info:
|
|
12979
13816
|
| FetchEventInfo
|
|
13817
|
+
| ConnectEventInfo
|
|
12980
13818
|
| JsRpcEventInfo
|
|
12981
13819
|
| ScheduledEventInfo
|
|
12982
13820
|
| AlarmEventInfo
|