@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-01-31/index.d.ts
CHANGED
|
@@ -478,6 +478,11 @@ type ExportedHandlerFetchHandler<
|
|
|
478
478
|
env: Env,
|
|
479
479
|
ctx: ExecutionContext<Props>,
|
|
480
480
|
) => Response | Promise<Response>;
|
|
481
|
+
type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
|
|
482
|
+
socket: Socket,
|
|
483
|
+
env: Env,
|
|
484
|
+
ctx: ExecutionContext<Props>,
|
|
485
|
+
) => void | Promise<void>;
|
|
481
486
|
type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
|
|
482
487
|
events: TraceItem[],
|
|
483
488
|
env: Env,
|
|
@@ -519,6 +524,7 @@ interface ExportedHandler<
|
|
|
519
524
|
Props = unknown,
|
|
520
525
|
> {
|
|
521
526
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
|
|
527
|
+
connect?: ExportedHandlerConnectHandler<Env, Props>;
|
|
522
528
|
tail?: ExportedHandlerTailHandler<Env, Props>;
|
|
523
529
|
trace?: ExportedHandlerTraceHandler<Env, Props>;
|
|
524
530
|
tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
|
|
@@ -533,12 +539,14 @@ interface StructuredSerializeOptions {
|
|
|
533
539
|
interface AlarmInvocationInfo {
|
|
534
540
|
readonly isRetry: boolean;
|
|
535
541
|
readonly retryCount: number;
|
|
542
|
+
readonly scheduledTime: number;
|
|
536
543
|
}
|
|
537
544
|
interface Cloudflare {
|
|
538
545
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
539
546
|
}
|
|
540
547
|
interface DurableObject {
|
|
541
548
|
fetch(request: Request): Response | Promise<Response>;
|
|
549
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
542
550
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
543
551
|
webSocketMessage?(
|
|
544
552
|
ws: WebSocket,
|
|
@@ -556,7 +564,7 @@ type DurableObjectStub<
|
|
|
556
564
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
557
565
|
> = Fetcher<
|
|
558
566
|
T,
|
|
559
|
-
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
567
|
+
"alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
560
568
|
> & {
|
|
561
569
|
readonly id: DurableObjectId;
|
|
562
570
|
readonly name?: string;
|
|
@@ -565,6 +573,7 @@ interface DurableObjectId {
|
|
|
565
573
|
toString(): string;
|
|
566
574
|
equals(other: DurableObjectId): boolean;
|
|
567
575
|
readonly name?: string;
|
|
576
|
+
readonly jurisdiction?: string;
|
|
568
577
|
}
|
|
569
578
|
declare abstract class DurableObjectNamespace<
|
|
570
579
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
@@ -3074,6 +3083,11 @@ interface QueuingStrategyInit {
|
|
|
3074
3083
|
*/
|
|
3075
3084
|
highWaterMark: number;
|
|
3076
3085
|
}
|
|
3086
|
+
interface TracePreviewInfo {
|
|
3087
|
+
id: string;
|
|
3088
|
+
slug: string;
|
|
3089
|
+
name: string;
|
|
3090
|
+
}
|
|
3077
3091
|
interface ScriptVersion {
|
|
3078
3092
|
id?: string;
|
|
3079
3093
|
tag?: string;
|
|
@@ -3088,6 +3102,7 @@ interface TraceItem {
|
|
|
3088
3102
|
| (
|
|
3089
3103
|
| TraceItemFetchEventInfo
|
|
3090
3104
|
| TraceItemJsRpcEventInfo
|
|
3105
|
+
| TraceItemConnectEventInfo
|
|
3091
3106
|
| TraceItemScheduledEventInfo
|
|
3092
3107
|
| TraceItemAlarmEventInfo
|
|
3093
3108
|
| TraceItemQueueEventInfo
|
|
@@ -3106,6 +3121,8 @@ interface TraceItem {
|
|
|
3106
3121
|
readonly scriptVersion?: ScriptVersion;
|
|
3107
3122
|
readonly dispatchNamespace?: string;
|
|
3108
3123
|
readonly scriptTags?: string[];
|
|
3124
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3125
|
+
readonly preview?: TracePreviewInfo;
|
|
3109
3126
|
readonly durableObjectId?: string;
|
|
3110
3127
|
readonly outcome: string;
|
|
3111
3128
|
readonly executionModel: string;
|
|
@@ -3116,6 +3133,7 @@ interface TraceItem {
|
|
|
3116
3133
|
interface TraceItemAlarmEventInfo {
|
|
3117
3134
|
readonly scheduledTime: Date;
|
|
3118
3135
|
}
|
|
3136
|
+
interface TraceItemConnectEventInfo {}
|
|
3119
3137
|
interface TraceItemCustomEventInfo {}
|
|
3120
3138
|
interface TraceItemScheduledEventInfo {
|
|
3121
3139
|
readonly scheduledTime: number;
|
|
@@ -3716,7 +3734,7 @@ interface ContainerStartupOptions {
|
|
|
3716
3734
|
entrypoint?: string[];
|
|
3717
3735
|
enableInternet: boolean;
|
|
3718
3736
|
env?: Record<string, string>;
|
|
3719
|
-
|
|
3737
|
+
labels?: Record<string, string>;
|
|
3720
3738
|
}
|
|
3721
3739
|
/**
|
|
3722
3740
|
* 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.
|
|
@@ -3843,11 +3861,10 @@ declare abstract class Performance {
|
|
|
3843
3861
|
*/
|
|
3844
3862
|
toJSON(): object;
|
|
3845
3863
|
}
|
|
3846
|
-
// AI Search
|
|
3864
|
+
// ============ AI Search Error Interfaces ============
|
|
3847
3865
|
interface AiSearchInternalError extends Error {}
|
|
3848
3866
|
interface AiSearchNotFoundError extends Error {}
|
|
3849
|
-
|
|
3850
|
-
// AI Search V2 Request Types
|
|
3867
|
+
// ============ AI Search Request Types ============
|
|
3851
3868
|
type AiSearchSearchRequest = {
|
|
3852
3869
|
messages: Array<{
|
|
3853
3870
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3872,9 +3889,8 @@ type AiSearchSearchRequest = {
|
|
|
3872
3889
|
[key: string]: unknown;
|
|
3873
3890
|
};
|
|
3874
3891
|
reranking?: {
|
|
3875
|
-
/** Enable reranking (default false) */
|
|
3876
3892
|
enabled?: boolean;
|
|
3877
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3893
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3878
3894
|
/** Match threshold (0-1, default 0.4) */
|
|
3879
3895
|
match_threshold?: number;
|
|
3880
3896
|
[key: string]: unknown;
|
|
@@ -3886,6 +3902,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3886
3902
|
messages: Array<{
|
|
3887
3903
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3888
3904
|
content: string | null;
|
|
3905
|
+
[key: string]: unknown;
|
|
3889
3906
|
}>;
|
|
3890
3907
|
model?: string;
|
|
3891
3908
|
stream?: boolean;
|
|
@@ -3906,7 +3923,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3906
3923
|
};
|
|
3907
3924
|
reranking?: {
|
|
3908
3925
|
enabled?: boolean;
|
|
3909
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3926
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3910
3927
|
match_threshold?: number;
|
|
3911
3928
|
[key: string]: unknown;
|
|
3912
3929
|
};
|
|
@@ -3914,7 +3931,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3914
3931
|
};
|
|
3915
3932
|
[key: string]: unknown;
|
|
3916
3933
|
};
|
|
3917
|
-
// AI Search
|
|
3934
|
+
// ============ AI Search Response Types ============
|
|
3918
3935
|
type AiSearchSearchResponse = {
|
|
3919
3936
|
search_query: string;
|
|
3920
3937
|
chunks: Array<{
|
|
@@ -3933,26 +3950,65 @@ type AiSearchSearchResponse = {
|
|
|
3933
3950
|
keyword_score?: number;
|
|
3934
3951
|
/** Vector similarity score (0-1) */
|
|
3935
3952
|
vector_score?: number;
|
|
3953
|
+
[key: string]: unknown;
|
|
3954
|
+
};
|
|
3955
|
+
}>;
|
|
3956
|
+
};
|
|
3957
|
+
type AiSearchChatCompletionsResponse = {
|
|
3958
|
+
id?: string;
|
|
3959
|
+
object?: string;
|
|
3960
|
+
model?: string;
|
|
3961
|
+
choices: Array<{
|
|
3962
|
+
index?: number;
|
|
3963
|
+
message: {
|
|
3964
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3965
|
+
content: string | null;
|
|
3966
|
+
[key: string]: unknown;
|
|
3936
3967
|
};
|
|
3968
|
+
[key: string]: unknown;
|
|
3937
3969
|
}>;
|
|
3970
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
3971
|
+
[key: string]: unknown;
|
|
3938
3972
|
};
|
|
3939
|
-
type
|
|
3973
|
+
type AiSearchStatsResponse = {
|
|
3974
|
+
queued?: number;
|
|
3975
|
+
running?: number;
|
|
3976
|
+
completed?: number;
|
|
3977
|
+
error?: number;
|
|
3978
|
+
skipped?: number;
|
|
3979
|
+
outdated?: number;
|
|
3980
|
+
last_activity?: string;
|
|
3981
|
+
};
|
|
3982
|
+
// ============ AI Search Instance Info Types ============
|
|
3983
|
+
type AiSearchInstanceInfo = {
|
|
3940
3984
|
id: string;
|
|
3941
|
-
|
|
3942
|
-
account_id?: string;
|
|
3943
|
-
account_tag?: string;
|
|
3944
|
-
/** Whether the instance is enabled (default true) */
|
|
3945
|
-
enable?: boolean;
|
|
3946
|
-
type?: "r2" | "web-crawler";
|
|
3985
|
+
type?: "r2" | "web-crawler" | string;
|
|
3947
3986
|
source?: string;
|
|
3987
|
+
paused?: boolean;
|
|
3988
|
+
status?: string;
|
|
3989
|
+
namespace?: string;
|
|
3990
|
+
created_at?: string;
|
|
3991
|
+
modified_at?: string;
|
|
3948
3992
|
[key: string]: unknown;
|
|
3949
|
-
}
|
|
3993
|
+
};
|
|
3994
|
+
type AiSearchListResponse = {
|
|
3995
|
+
result: AiSearchInstanceInfo[];
|
|
3996
|
+
result_info?: {
|
|
3997
|
+
count: number;
|
|
3998
|
+
page: number;
|
|
3999
|
+
per_page: number;
|
|
4000
|
+
total_count: number;
|
|
4001
|
+
};
|
|
4002
|
+
};
|
|
4003
|
+
// ============ AI Search Config Types ============
|
|
3950
4004
|
type AiSearchConfig = {
|
|
3951
4005
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3952
4006
|
id: string;
|
|
3953
|
-
type
|
|
3954
|
-
|
|
3955
|
-
|
|
4007
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4008
|
+
type?: "r2" | "web-crawler" | string;
|
|
4009
|
+
/** Source URL (required for web-crawler type). */
|
|
4010
|
+
source?: string;
|
|
4011
|
+
source_params?: unknown;
|
|
3956
4012
|
/** Token ID (UUID format) */
|
|
3957
4013
|
token_id?: string;
|
|
3958
4014
|
ai_gateway_id?: string;
|
|
@@ -3962,54 +4018,307 @@ type AiSearchConfig = {
|
|
|
3962
4018
|
reranking?: boolean;
|
|
3963
4019
|
embedding_model?: string;
|
|
3964
4020
|
ai_search_model?: string;
|
|
4021
|
+
[key: string]: unknown;
|
|
3965
4022
|
};
|
|
3966
|
-
|
|
4023
|
+
// ============ AI Search Item Types ============
|
|
4024
|
+
type AiSearchItemInfo = {
|
|
3967
4025
|
id: string;
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
4026
|
+
key: string;
|
|
4027
|
+
status:
|
|
4028
|
+
| "completed"
|
|
4029
|
+
| "error"
|
|
4030
|
+
| "skipped"
|
|
4031
|
+
| "queued"
|
|
4032
|
+
| "processing"
|
|
4033
|
+
| "outdated";
|
|
4034
|
+
metadata?: Record<string, unknown>;
|
|
3971
4035
|
[key: string]: unknown;
|
|
3972
4036
|
};
|
|
3973
|
-
|
|
3974
|
-
|
|
4037
|
+
type AiSearchItemContentResult = {
|
|
4038
|
+
body: ReadableStream;
|
|
4039
|
+
contentType: string;
|
|
4040
|
+
filename: string;
|
|
4041
|
+
size: number;
|
|
4042
|
+
};
|
|
4043
|
+
type AiSearchUploadItemOptions = {
|
|
4044
|
+
metadata?: Record<string, unknown>;
|
|
4045
|
+
};
|
|
4046
|
+
type AiSearchListItemsParams = {
|
|
4047
|
+
page?: number;
|
|
4048
|
+
per_page?: number;
|
|
4049
|
+
};
|
|
4050
|
+
type AiSearchListItemsResponse = {
|
|
4051
|
+
result: AiSearchItemInfo[];
|
|
4052
|
+
result_info?: {
|
|
4053
|
+
count: number;
|
|
4054
|
+
page: number;
|
|
4055
|
+
per_page: number;
|
|
4056
|
+
total_count: number;
|
|
4057
|
+
};
|
|
4058
|
+
};
|
|
4059
|
+
// ============ AI Search Job Types ============
|
|
4060
|
+
type AiSearchJobInfo = {
|
|
4061
|
+
id: string;
|
|
4062
|
+
source: "user" | "schedule";
|
|
4063
|
+
description?: string;
|
|
4064
|
+
last_seen_at?: string;
|
|
4065
|
+
started_at?: string;
|
|
4066
|
+
ended_at?: string;
|
|
4067
|
+
end_reason?: string;
|
|
4068
|
+
};
|
|
4069
|
+
type AiSearchJobLog = {
|
|
4070
|
+
id: number;
|
|
4071
|
+
message: string;
|
|
4072
|
+
message_type: number;
|
|
4073
|
+
created_at: number;
|
|
4074
|
+
};
|
|
4075
|
+
type AiSearchCreateJobParams = {
|
|
4076
|
+
description?: string;
|
|
4077
|
+
};
|
|
4078
|
+
type AiSearchListJobsParams = {
|
|
4079
|
+
page?: number;
|
|
4080
|
+
per_page?: number;
|
|
4081
|
+
};
|
|
4082
|
+
type AiSearchListJobsResponse = {
|
|
4083
|
+
result: AiSearchJobInfo[];
|
|
4084
|
+
result_info?: {
|
|
4085
|
+
count: number;
|
|
4086
|
+
page: number;
|
|
4087
|
+
per_page: number;
|
|
4088
|
+
total_count: number;
|
|
4089
|
+
};
|
|
4090
|
+
};
|
|
4091
|
+
type AiSearchJobLogsParams = {
|
|
4092
|
+
page?: number;
|
|
4093
|
+
per_page?: number;
|
|
4094
|
+
};
|
|
4095
|
+
type AiSearchJobLogsResponse = {
|
|
4096
|
+
result: AiSearchJobLog[];
|
|
4097
|
+
result_info?: {
|
|
4098
|
+
count: number;
|
|
4099
|
+
page: number;
|
|
4100
|
+
per_page: number;
|
|
4101
|
+
total_count: number;
|
|
4102
|
+
};
|
|
4103
|
+
};
|
|
4104
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4105
|
+
/**
|
|
4106
|
+
* Single item service for an AI Search instance.
|
|
4107
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4108
|
+
*/
|
|
4109
|
+
declare abstract class AiSearchItem {
|
|
4110
|
+
/** Get metadata about this item. */
|
|
4111
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4112
|
+
/**
|
|
4113
|
+
* Download the item's content.
|
|
4114
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4115
|
+
*/
|
|
4116
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4117
|
+
}
|
|
4118
|
+
/**
|
|
4119
|
+
* Items collection service for an AI Search instance.
|
|
4120
|
+
* Provides list, upload, and access to individual items.
|
|
4121
|
+
*/
|
|
4122
|
+
declare abstract class AiSearchItems {
|
|
4123
|
+
/** List items in this instance. */
|
|
4124
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4125
|
+
/**
|
|
4126
|
+
* Upload a file as an item.
|
|
4127
|
+
* @param name Filename for the uploaded item.
|
|
4128
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4129
|
+
* @param options Optional metadata to attach to the item.
|
|
4130
|
+
* @returns The created item info.
|
|
4131
|
+
*/
|
|
4132
|
+
upload(
|
|
4133
|
+
name: string,
|
|
4134
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4135
|
+
options?: AiSearchUploadItemOptions,
|
|
4136
|
+
): Promise<AiSearchItemInfo>;
|
|
4137
|
+
/**
|
|
4138
|
+
* Upload a file and poll until processing completes.
|
|
4139
|
+
* @param name Filename for the uploaded item.
|
|
4140
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4141
|
+
* @param options Optional metadata to attach to the item.
|
|
4142
|
+
* @returns The item info after processing completes (or timeout).
|
|
4143
|
+
*/
|
|
4144
|
+
uploadAndPoll(
|
|
4145
|
+
name: string,
|
|
4146
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4147
|
+
options?: AiSearchUploadItemOptions,
|
|
4148
|
+
): Promise<AiSearchItemInfo>;
|
|
4149
|
+
/**
|
|
4150
|
+
* Get an item by ID.
|
|
4151
|
+
* @param itemId The item identifier.
|
|
4152
|
+
* @returns Item service for info, delete, and download operations.
|
|
4153
|
+
*/
|
|
4154
|
+
get(itemId: string): AiSearchItem;
|
|
4155
|
+
/** Delete this item from the instance.
|
|
4156
|
+
* @param itemId The item identifier.
|
|
4157
|
+
*/
|
|
4158
|
+
delete(itemId: string): Promise<void>;
|
|
4159
|
+
}
|
|
4160
|
+
/**
|
|
4161
|
+
* Single job service for an AI Search instance.
|
|
4162
|
+
* Provides info and logs for a specific job.
|
|
4163
|
+
*/
|
|
4164
|
+
declare abstract class AiSearchJob {
|
|
4165
|
+
/** Get metadata about this job. */
|
|
4166
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4167
|
+
/** Get logs for this job. */
|
|
4168
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* Jobs collection service for an AI Search instance.
|
|
4172
|
+
* Provides list, create, and access to individual jobs.
|
|
4173
|
+
*/
|
|
4174
|
+
declare abstract class AiSearchJobs {
|
|
4175
|
+
/** List jobs for this instance. */
|
|
4176
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4177
|
+
/**
|
|
4178
|
+
* Create a new indexing job.
|
|
4179
|
+
* @param params Optional job parameters.
|
|
4180
|
+
* @returns The created job info.
|
|
4181
|
+
*/
|
|
4182
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4183
|
+
/**
|
|
4184
|
+
* Get a job by ID.
|
|
4185
|
+
* @param jobId The job identifier.
|
|
4186
|
+
* @returns Job service for info and logs operations.
|
|
4187
|
+
*/
|
|
4188
|
+
get(jobId: string): AiSearchJob;
|
|
4189
|
+
}
|
|
4190
|
+
// ============ AI Search Binding Classes ============
|
|
4191
|
+
/**
|
|
4192
|
+
* Instance-level AI Search service.
|
|
4193
|
+
*
|
|
4194
|
+
* Used as:
|
|
4195
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4196
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4197
|
+
*
|
|
4198
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4199
|
+
*
|
|
4200
|
+
* @example
|
|
4201
|
+
* ```ts
|
|
4202
|
+
* // Via namespace binding
|
|
4203
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4204
|
+
* const results = await instance.search({
|
|
4205
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4206
|
+
* });
|
|
4207
|
+
*
|
|
4208
|
+
* // Via single instance binding
|
|
4209
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4210
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4211
|
+
* });
|
|
4212
|
+
* ```
|
|
4213
|
+
*/
|
|
4214
|
+
declare abstract class AiSearchInstance {
|
|
3975
4215
|
/**
|
|
3976
4216
|
* Search the AI Search instance for relevant chunks.
|
|
3977
|
-
* @param params Search request with messages and AI search options
|
|
3978
|
-
* @returns Search response with matching chunks
|
|
4217
|
+
* @param params Search request with messages and optional AI search options.
|
|
4218
|
+
* @returns Search response with matching chunks and search query.
|
|
3979
4219
|
*/
|
|
3980
4220
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4221
|
+
/**
|
|
4222
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4223
|
+
* @param params Chat completions request with stream: true.
|
|
4224
|
+
* @returns ReadableStream of server-sent events.
|
|
4225
|
+
*/
|
|
4226
|
+
chatCompletions(
|
|
4227
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4228
|
+
stream: true;
|
|
4229
|
+
},
|
|
4230
|
+
): Promise<ReadableStream>;
|
|
3981
4231
|
/**
|
|
3982
4232
|
* Generate chat completions with AI Search context.
|
|
3983
|
-
* @param params Chat completions request
|
|
3984
|
-
* @returns
|
|
4233
|
+
* @param params Chat completions request.
|
|
4234
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
3985
4235
|
*/
|
|
3986
4236
|
chatCompletions(
|
|
3987
4237
|
params: AiSearchChatCompletionsRequest,
|
|
3988
|
-
): Promise<
|
|
4238
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
3989
4239
|
/**
|
|
3990
|
-
*
|
|
4240
|
+
* Update the instance configuration.
|
|
4241
|
+
* @param config Partial configuration to update.
|
|
4242
|
+
* @returns Updated instance info.
|
|
3991
4243
|
*/
|
|
3992
|
-
|
|
4244
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4245
|
+
/** Get metadata about this instance. */
|
|
4246
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4247
|
+
/**
|
|
4248
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4249
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4250
|
+
*/
|
|
4251
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4252
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4253
|
+
get items(): AiSearchItems;
|
|
4254
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4255
|
+
get jobs(): AiSearchJobs;
|
|
3993
4256
|
}
|
|
3994
|
-
|
|
3995
|
-
|
|
4257
|
+
/**
|
|
4258
|
+
* Namespace-level AI Search service.
|
|
4259
|
+
*
|
|
4260
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4261
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4262
|
+
*
|
|
4263
|
+
* @example
|
|
4264
|
+
* ```ts
|
|
4265
|
+
* // Access an instance within the namespace
|
|
4266
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4267
|
+
* const results = await blog.search({
|
|
4268
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4269
|
+
* });
|
|
4270
|
+
*
|
|
4271
|
+
* // List all instances in the namespace
|
|
4272
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4273
|
+
*
|
|
4274
|
+
* // Create a new instance with built-in storage
|
|
4275
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4276
|
+
* id: "tenant-123",
|
|
4277
|
+
* });
|
|
4278
|
+
*
|
|
4279
|
+
* // Upload items into the instance
|
|
4280
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4281
|
+
*
|
|
4282
|
+
* // Delete an instance
|
|
4283
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4284
|
+
* ```
|
|
4285
|
+
*/
|
|
4286
|
+
declare abstract class AiSearchNamespace {
|
|
3996
4287
|
/**
|
|
3997
|
-
*
|
|
3998
|
-
* @
|
|
4288
|
+
* Get an instance by name within the bound namespace.
|
|
4289
|
+
* @param name Instance name.
|
|
4290
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4291
|
+
*/
|
|
4292
|
+
get(name: string): AiSearchInstance;
|
|
4293
|
+
/**
|
|
4294
|
+
* List all instances in the bound namespace.
|
|
4295
|
+
* @returns Array of instance metadata.
|
|
3999
4296
|
*/
|
|
4000
4297
|
list(): Promise<AiSearchListResponse>;
|
|
4001
4298
|
/**
|
|
4002
|
-
*
|
|
4003
|
-
* @param
|
|
4004
|
-
* @returns Instance service for
|
|
4299
|
+
* Create a new instance within the bound namespace.
|
|
4300
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4301
|
+
* @returns Instance service for the newly created instance.
|
|
4302
|
+
*
|
|
4303
|
+
* @example
|
|
4304
|
+
* ```ts
|
|
4305
|
+
* // Create with built-in storage (upload items manually)
|
|
4306
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4307
|
+
*
|
|
4308
|
+
* // Create with web crawler source
|
|
4309
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4310
|
+
* id: "docs-search",
|
|
4311
|
+
* type: "web-crawler",
|
|
4312
|
+
* source: "https://developers.cloudflare.com",
|
|
4313
|
+
* });
|
|
4314
|
+
* ```
|
|
4005
4315
|
*/
|
|
4006
|
-
|
|
4316
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4007
4317
|
/**
|
|
4008
|
-
*
|
|
4009
|
-
* @param
|
|
4010
|
-
* @returns Instance service for performing operations
|
|
4318
|
+
* Delete an instance from the bound namespace.
|
|
4319
|
+
* @param name Instance name to delete.
|
|
4011
4320
|
*/
|
|
4012
|
-
|
|
4321
|
+
delete(name: string): Promise<void>;
|
|
4013
4322
|
}
|
|
4014
4323
|
type AiImageClassificationInput = {
|
|
4015
4324
|
image: number[];
|
|
@@ -4285,6 +4594,400 @@ declare abstract class BaseAiTranslation {
|
|
|
4285
4594
|
inputs: AiTranslationInput;
|
|
4286
4595
|
postProcessedOutputs: AiTranslationOutput;
|
|
4287
4596
|
}
|
|
4597
|
+
/**
|
|
4598
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4599
|
+
*/
|
|
4600
|
+
type ChatCompletionContentPartText = {
|
|
4601
|
+
type: "text";
|
|
4602
|
+
text: string;
|
|
4603
|
+
};
|
|
4604
|
+
type ChatCompletionContentPartImage = {
|
|
4605
|
+
type: "image_url";
|
|
4606
|
+
image_url: {
|
|
4607
|
+
url: string;
|
|
4608
|
+
detail?: "auto" | "low" | "high";
|
|
4609
|
+
};
|
|
4610
|
+
};
|
|
4611
|
+
type ChatCompletionContentPartInputAudio = {
|
|
4612
|
+
type: "input_audio";
|
|
4613
|
+
input_audio: {
|
|
4614
|
+
/** Base64 encoded audio data. */
|
|
4615
|
+
data: string;
|
|
4616
|
+
format: "wav" | "mp3";
|
|
4617
|
+
};
|
|
4618
|
+
};
|
|
4619
|
+
type ChatCompletionContentPartFile = {
|
|
4620
|
+
type: "file";
|
|
4621
|
+
file: {
|
|
4622
|
+
/** Base64 encoded file data. */
|
|
4623
|
+
file_data?: string;
|
|
4624
|
+
/** The ID of an uploaded file. */
|
|
4625
|
+
file_id?: string;
|
|
4626
|
+
filename?: string;
|
|
4627
|
+
};
|
|
4628
|
+
};
|
|
4629
|
+
type ChatCompletionContentPartRefusal = {
|
|
4630
|
+
type: "refusal";
|
|
4631
|
+
refusal: string;
|
|
4632
|
+
};
|
|
4633
|
+
type ChatCompletionContentPart =
|
|
4634
|
+
| ChatCompletionContentPartText
|
|
4635
|
+
| ChatCompletionContentPartImage
|
|
4636
|
+
| ChatCompletionContentPartInputAudio
|
|
4637
|
+
| ChatCompletionContentPartFile;
|
|
4638
|
+
type FunctionDefinition = {
|
|
4639
|
+
name: string;
|
|
4640
|
+
description?: string;
|
|
4641
|
+
parameters?: Record<string, unknown>;
|
|
4642
|
+
strict?: boolean | null;
|
|
4643
|
+
};
|
|
4644
|
+
type ChatCompletionFunctionTool = {
|
|
4645
|
+
type: "function";
|
|
4646
|
+
function: FunctionDefinition;
|
|
4647
|
+
};
|
|
4648
|
+
type ChatCompletionCustomToolGrammarFormat = {
|
|
4649
|
+
type: "grammar";
|
|
4650
|
+
grammar: {
|
|
4651
|
+
definition: string;
|
|
4652
|
+
syntax: "lark" | "regex";
|
|
4653
|
+
};
|
|
4654
|
+
};
|
|
4655
|
+
type ChatCompletionCustomToolTextFormat = {
|
|
4656
|
+
type: "text";
|
|
4657
|
+
};
|
|
4658
|
+
type ChatCompletionCustomToolFormat =
|
|
4659
|
+
| ChatCompletionCustomToolTextFormat
|
|
4660
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4661
|
+
type ChatCompletionCustomTool = {
|
|
4662
|
+
type: "custom";
|
|
4663
|
+
custom: {
|
|
4664
|
+
name: string;
|
|
4665
|
+
description?: string;
|
|
4666
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4667
|
+
};
|
|
4668
|
+
};
|
|
4669
|
+
type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
|
|
4670
|
+
type ChatCompletionMessageFunctionToolCall = {
|
|
4671
|
+
id: string;
|
|
4672
|
+
type: "function";
|
|
4673
|
+
function: {
|
|
4674
|
+
name: string;
|
|
4675
|
+
/** JSON-encoded arguments string. */
|
|
4676
|
+
arguments: string;
|
|
4677
|
+
};
|
|
4678
|
+
};
|
|
4679
|
+
type ChatCompletionMessageCustomToolCall = {
|
|
4680
|
+
id: string;
|
|
4681
|
+
type: "custom";
|
|
4682
|
+
custom: {
|
|
4683
|
+
name: string;
|
|
4684
|
+
input: string;
|
|
4685
|
+
};
|
|
4686
|
+
};
|
|
4687
|
+
type ChatCompletionMessageToolCall =
|
|
4688
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4689
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4690
|
+
type ChatCompletionToolChoiceFunction = {
|
|
4691
|
+
type: "function";
|
|
4692
|
+
function: {
|
|
4693
|
+
name: string;
|
|
4694
|
+
};
|
|
4695
|
+
};
|
|
4696
|
+
type ChatCompletionToolChoiceCustom = {
|
|
4697
|
+
type: "custom";
|
|
4698
|
+
custom: {
|
|
4699
|
+
name: string;
|
|
4700
|
+
};
|
|
4701
|
+
};
|
|
4702
|
+
type ChatCompletionToolChoiceAllowedTools = {
|
|
4703
|
+
type: "allowed_tools";
|
|
4704
|
+
allowed_tools: {
|
|
4705
|
+
mode: "auto" | "required";
|
|
4706
|
+
tools: Array<Record<string, unknown>>;
|
|
4707
|
+
};
|
|
4708
|
+
};
|
|
4709
|
+
type ChatCompletionToolChoiceOption =
|
|
4710
|
+
| "none"
|
|
4711
|
+
| "auto"
|
|
4712
|
+
| "required"
|
|
4713
|
+
| ChatCompletionToolChoiceFunction
|
|
4714
|
+
| ChatCompletionToolChoiceCustom
|
|
4715
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4716
|
+
type DeveloperMessage = {
|
|
4717
|
+
role: "developer";
|
|
4718
|
+
content:
|
|
4719
|
+
| string
|
|
4720
|
+
| Array<{
|
|
4721
|
+
type: "text";
|
|
4722
|
+
text: string;
|
|
4723
|
+
}>;
|
|
4724
|
+
name?: string;
|
|
4725
|
+
};
|
|
4726
|
+
type SystemMessage = {
|
|
4727
|
+
role: "system";
|
|
4728
|
+
content:
|
|
4729
|
+
| string
|
|
4730
|
+
| Array<{
|
|
4731
|
+
type: "text";
|
|
4732
|
+
text: string;
|
|
4733
|
+
}>;
|
|
4734
|
+
name?: string;
|
|
4735
|
+
};
|
|
4736
|
+
/**
|
|
4737
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4738
|
+
*
|
|
4739
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4740
|
+
* inside nested array items does not correctly match different branches for
|
|
4741
|
+
* different array elements, so the schema uses a single merged object.
|
|
4742
|
+
*/
|
|
4743
|
+
type UserMessageContentPart = {
|
|
4744
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4745
|
+
text?: string;
|
|
4746
|
+
image_url?: {
|
|
4747
|
+
url?: string;
|
|
4748
|
+
detail?: "auto" | "low" | "high";
|
|
4749
|
+
};
|
|
4750
|
+
input_audio?: {
|
|
4751
|
+
data?: string;
|
|
4752
|
+
format?: "wav" | "mp3";
|
|
4753
|
+
};
|
|
4754
|
+
file?: {
|
|
4755
|
+
file_data?: string;
|
|
4756
|
+
file_id?: string;
|
|
4757
|
+
filename?: string;
|
|
4758
|
+
};
|
|
4759
|
+
};
|
|
4760
|
+
type UserMessage = {
|
|
4761
|
+
role: "user";
|
|
4762
|
+
content: string | Array<UserMessageContentPart>;
|
|
4763
|
+
name?: string;
|
|
4764
|
+
};
|
|
4765
|
+
type AssistantMessageContentPart = {
|
|
4766
|
+
type: "text" | "refusal";
|
|
4767
|
+
text?: string;
|
|
4768
|
+
refusal?: string;
|
|
4769
|
+
};
|
|
4770
|
+
type AssistantMessage = {
|
|
4771
|
+
role: "assistant";
|
|
4772
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4773
|
+
refusal?: string | null;
|
|
4774
|
+
name?: string;
|
|
4775
|
+
audio?: {
|
|
4776
|
+
id: string;
|
|
4777
|
+
};
|
|
4778
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4779
|
+
function_call?: {
|
|
4780
|
+
name: string;
|
|
4781
|
+
arguments: string;
|
|
4782
|
+
};
|
|
4783
|
+
};
|
|
4784
|
+
type ToolMessage = {
|
|
4785
|
+
role: "tool";
|
|
4786
|
+
content:
|
|
4787
|
+
| string
|
|
4788
|
+
| Array<{
|
|
4789
|
+
type: "text";
|
|
4790
|
+
text: string;
|
|
4791
|
+
}>;
|
|
4792
|
+
tool_call_id: string;
|
|
4793
|
+
};
|
|
4794
|
+
type FunctionMessage = {
|
|
4795
|
+
role: "function";
|
|
4796
|
+
content: string;
|
|
4797
|
+
name: string;
|
|
4798
|
+
};
|
|
4799
|
+
type ChatCompletionMessageParam =
|
|
4800
|
+
| DeveloperMessage
|
|
4801
|
+
| SystemMessage
|
|
4802
|
+
| UserMessage
|
|
4803
|
+
| AssistantMessage
|
|
4804
|
+
| ToolMessage
|
|
4805
|
+
| FunctionMessage;
|
|
4806
|
+
type ChatCompletionsResponseFormatText = {
|
|
4807
|
+
type: "text";
|
|
4808
|
+
};
|
|
4809
|
+
type ChatCompletionsResponseFormatJSONObject = {
|
|
4810
|
+
type: "json_object";
|
|
4811
|
+
};
|
|
4812
|
+
type ResponseFormatJSONSchema = {
|
|
4813
|
+
type: "json_schema";
|
|
4814
|
+
json_schema: {
|
|
4815
|
+
name: string;
|
|
4816
|
+
description?: string;
|
|
4817
|
+
schema?: Record<string, unknown>;
|
|
4818
|
+
strict?: boolean | null;
|
|
4819
|
+
};
|
|
4820
|
+
};
|
|
4821
|
+
type ResponseFormat =
|
|
4822
|
+
| ChatCompletionsResponseFormatText
|
|
4823
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4824
|
+
| ResponseFormatJSONSchema;
|
|
4825
|
+
type ChatCompletionsStreamOptions = {
|
|
4826
|
+
include_usage?: boolean;
|
|
4827
|
+
include_obfuscation?: boolean;
|
|
4828
|
+
};
|
|
4829
|
+
type PredictionContent = {
|
|
4830
|
+
type: "content";
|
|
4831
|
+
content:
|
|
4832
|
+
| string
|
|
4833
|
+
| Array<{
|
|
4834
|
+
type: "text";
|
|
4835
|
+
text: string;
|
|
4836
|
+
}>;
|
|
4837
|
+
};
|
|
4838
|
+
type AudioParams = {
|
|
4839
|
+
voice:
|
|
4840
|
+
| string
|
|
4841
|
+
| {
|
|
4842
|
+
id: string;
|
|
4843
|
+
};
|
|
4844
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4845
|
+
};
|
|
4846
|
+
type WebSearchUserLocation = {
|
|
4847
|
+
type: "approximate";
|
|
4848
|
+
approximate: {
|
|
4849
|
+
city?: string;
|
|
4850
|
+
country?: string;
|
|
4851
|
+
region?: string;
|
|
4852
|
+
timezone?: string;
|
|
4853
|
+
};
|
|
4854
|
+
};
|
|
4855
|
+
type WebSearchOptions = {
|
|
4856
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4857
|
+
user_location?: WebSearchUserLocation;
|
|
4858
|
+
};
|
|
4859
|
+
type ChatTemplateKwargs = {
|
|
4860
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4861
|
+
enable_thinking?: boolean;
|
|
4862
|
+
/** If false, preserves reasoning context between turns. */
|
|
4863
|
+
clear_thinking?: boolean;
|
|
4864
|
+
};
|
|
4865
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4866
|
+
type ChatCompletionsCommonOptions = {
|
|
4867
|
+
model?: string;
|
|
4868
|
+
audio?: AudioParams;
|
|
4869
|
+
frequency_penalty?: number | null;
|
|
4870
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4871
|
+
logprobs?: boolean | null;
|
|
4872
|
+
top_logprobs?: number | null;
|
|
4873
|
+
max_tokens?: number | null;
|
|
4874
|
+
max_completion_tokens?: number | null;
|
|
4875
|
+
metadata?: Record<string, unknown> | null;
|
|
4876
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4877
|
+
n?: number | null;
|
|
4878
|
+
parallel_tool_calls?: boolean;
|
|
4879
|
+
prediction?: PredictionContent;
|
|
4880
|
+
presence_penalty?: number | null;
|
|
4881
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4882
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4883
|
+
response_format?: ResponseFormat;
|
|
4884
|
+
seed?: number | null;
|
|
4885
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4886
|
+
stop?: string | Array<string> | null;
|
|
4887
|
+
store?: boolean | null;
|
|
4888
|
+
stream?: boolean | null;
|
|
4889
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4890
|
+
temperature?: number | null;
|
|
4891
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4892
|
+
tools?: Array<ChatCompletionTool>;
|
|
4893
|
+
top_p?: number | null;
|
|
4894
|
+
user?: string;
|
|
4895
|
+
web_search_options?: WebSearchOptions;
|
|
4896
|
+
function_call?:
|
|
4897
|
+
| "none"
|
|
4898
|
+
| "auto"
|
|
4899
|
+
| {
|
|
4900
|
+
name: string;
|
|
4901
|
+
};
|
|
4902
|
+
functions?: Array<FunctionDefinition>;
|
|
4903
|
+
};
|
|
4904
|
+
type PromptTokensDetails = {
|
|
4905
|
+
cached_tokens?: number;
|
|
4906
|
+
audio_tokens?: number;
|
|
4907
|
+
};
|
|
4908
|
+
type CompletionTokensDetails = {
|
|
4909
|
+
reasoning_tokens?: number;
|
|
4910
|
+
audio_tokens?: number;
|
|
4911
|
+
accepted_prediction_tokens?: number;
|
|
4912
|
+
rejected_prediction_tokens?: number;
|
|
4913
|
+
};
|
|
4914
|
+
type CompletionUsage = {
|
|
4915
|
+
prompt_tokens: number;
|
|
4916
|
+
completion_tokens: number;
|
|
4917
|
+
total_tokens: number;
|
|
4918
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4919
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4920
|
+
};
|
|
4921
|
+
type ChatCompletionTopLogprob = {
|
|
4922
|
+
token: string;
|
|
4923
|
+
logprob: number;
|
|
4924
|
+
bytes: Array<number> | null;
|
|
4925
|
+
};
|
|
4926
|
+
type ChatCompletionTokenLogprob = {
|
|
4927
|
+
token: string;
|
|
4928
|
+
logprob: number;
|
|
4929
|
+
bytes: Array<number> | null;
|
|
4930
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4931
|
+
};
|
|
4932
|
+
type ChatCompletionAudio = {
|
|
4933
|
+
id: string;
|
|
4934
|
+
/** Base64 encoded audio bytes. */
|
|
4935
|
+
data: string;
|
|
4936
|
+
expires_at: number;
|
|
4937
|
+
transcript: string;
|
|
4938
|
+
};
|
|
4939
|
+
type ChatCompletionUrlCitation = {
|
|
4940
|
+
type: "url_citation";
|
|
4941
|
+
url_citation: {
|
|
4942
|
+
url: string;
|
|
4943
|
+
title: string;
|
|
4944
|
+
start_index: number;
|
|
4945
|
+
end_index: number;
|
|
4946
|
+
};
|
|
4947
|
+
};
|
|
4948
|
+
type ChatCompletionResponseMessage = {
|
|
4949
|
+
role: "assistant";
|
|
4950
|
+
content: string | null;
|
|
4951
|
+
refusal: string | null;
|
|
4952
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
4953
|
+
audio?: ChatCompletionAudio;
|
|
4954
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4955
|
+
function_call?: {
|
|
4956
|
+
name: string;
|
|
4957
|
+
arguments: string;
|
|
4958
|
+
} | null;
|
|
4959
|
+
};
|
|
4960
|
+
type ChatCompletionLogprobs = {
|
|
4961
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
4962
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
4963
|
+
};
|
|
4964
|
+
type ChatCompletionChoice = {
|
|
4965
|
+
index: number;
|
|
4966
|
+
message: ChatCompletionResponseMessage;
|
|
4967
|
+
finish_reason:
|
|
4968
|
+
| "stop"
|
|
4969
|
+
| "length"
|
|
4970
|
+
| "tool_calls"
|
|
4971
|
+
| "content_filter"
|
|
4972
|
+
| "function_call";
|
|
4973
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
4974
|
+
};
|
|
4975
|
+
type ChatCompletionsPromptInput = {
|
|
4976
|
+
prompt: string;
|
|
4977
|
+
} & ChatCompletionsCommonOptions;
|
|
4978
|
+
type ChatCompletionsMessagesInput = {
|
|
4979
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
4980
|
+
} & ChatCompletionsCommonOptions;
|
|
4981
|
+
type ChatCompletionsOutput = {
|
|
4982
|
+
id: string;
|
|
4983
|
+
object: string;
|
|
4984
|
+
created: number;
|
|
4985
|
+
model: string;
|
|
4986
|
+
choices: Array<ChatCompletionChoice>;
|
|
4987
|
+
usage?: CompletionUsage;
|
|
4988
|
+
system_fingerprint?: string | null;
|
|
4989
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4990
|
+
};
|
|
4288
4991
|
/**
|
|
4289
4992
|
* Workers AI support for OpenAI's Responses API
|
|
4290
4993
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4706,6 +5409,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4706
5409
|
type StreamOptions = {
|
|
4707
5410
|
include_obfuscation?: boolean;
|
|
4708
5411
|
};
|
|
5412
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5413
|
+
type Without<T, U> = {
|
|
5414
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5415
|
+
};
|
|
5416
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5417
|
+
type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4709
5418
|
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4710
5419
|
| {
|
|
4711
5420
|
text: string | string[];
|
|
@@ -4998,10 +5707,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
4998
5707
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
4999
5708
|
}
|
|
5000
5709
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5710
|
+
audio:
|
|
5711
|
+
| string
|
|
5712
|
+
| {
|
|
5713
|
+
body?: object;
|
|
5714
|
+
contentType?: string;
|
|
5715
|
+
};
|
|
5005
5716
|
/**
|
|
5006
5717
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5007
5718
|
*/
|
|
@@ -5019,9 +5730,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5019
5730
|
*/
|
|
5020
5731
|
initial_prompt?: string;
|
|
5021
5732
|
/**
|
|
5022
|
-
* The prefix
|
|
5733
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5023
5734
|
*/
|
|
5024
5735
|
prefix?: string;
|
|
5736
|
+
/**
|
|
5737
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5738
|
+
*/
|
|
5739
|
+
beam_size?: number;
|
|
5740
|
+
/**
|
|
5741
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5742
|
+
*/
|
|
5743
|
+
condition_on_previous_text?: boolean;
|
|
5744
|
+
/**
|
|
5745
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5746
|
+
*/
|
|
5747
|
+
no_speech_threshold?: number;
|
|
5748
|
+
/**
|
|
5749
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5750
|
+
*/
|
|
5751
|
+
compression_ratio_threshold?: number;
|
|
5752
|
+
/**
|
|
5753
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5754
|
+
*/
|
|
5755
|
+
log_prob_threshold?: number;
|
|
5756
|
+
/**
|
|
5757
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5758
|
+
*/
|
|
5759
|
+
hallucination_silence_threshold?: number;
|
|
5025
5760
|
}
|
|
5026
5761
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5027
5762
|
transcription_info?: {
|
|
@@ -5168,11 +5903,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5168
5903
|
truncate_inputs?: boolean;
|
|
5169
5904
|
}
|
|
5170
5905
|
type Ai_Cf_Baai_Bge_M3_Output =
|
|
5171
|
-
|
|
|
5906
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5172
5907
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5173
|
-
|
|
|
5908
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5174
5909
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5175
|
-
interface
|
|
5910
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5176
5911
|
response?: {
|
|
5177
5912
|
/**
|
|
5178
5913
|
* Index of the context in the request
|
|
@@ -5192,7 +5927,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5192
5927
|
*/
|
|
5193
5928
|
pooling?: "mean" | "cls";
|
|
5194
5929
|
}
|
|
5195
|
-
interface
|
|
5930
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5196
5931
|
shape?: number[];
|
|
5197
5932
|
/**
|
|
5198
5933
|
* Embeddings of the requested text values
|
|
@@ -5297,7 +6032,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5297
6032
|
*/
|
|
5298
6033
|
role?: string;
|
|
5299
6034
|
/**
|
|
5300
|
-
* The tool call id.
|
|
6035
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5301
6036
|
*/
|
|
5302
6037
|
tool_call_id?: string;
|
|
5303
6038
|
content?:
|
|
@@ -5552,10 +6287,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5552
6287
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5553
6288
|
*/
|
|
5554
6289
|
role: string;
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
6290
|
+
content:
|
|
6291
|
+
| string
|
|
6292
|
+
| {
|
|
6293
|
+
/**
|
|
6294
|
+
* Type of the content (text)
|
|
6295
|
+
*/
|
|
6296
|
+
type?: string;
|
|
6297
|
+
/**
|
|
6298
|
+
* Text content
|
|
6299
|
+
*/
|
|
6300
|
+
text?: string;
|
|
6301
|
+
}[];
|
|
5559
6302
|
}[];
|
|
5560
6303
|
functions?: {
|
|
5561
6304
|
name: string;
|
|
@@ -6211,7 +6954,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6211
6954
|
*/
|
|
6212
6955
|
role?: string;
|
|
6213
6956
|
/**
|
|
6214
|
-
* The tool call id.
|
|
6957
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6215
6958
|
*/
|
|
6216
6959
|
tool_call_id?: string;
|
|
6217
6960
|
content?:
|
|
@@ -6338,7 +7081,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6338
7081
|
}
|
|
6339
7082
|
)[];
|
|
6340
7083
|
/**
|
|
6341
|
-
* JSON schema that should be
|
|
7084
|
+
* JSON schema that should be fufilled for the response.
|
|
6342
7085
|
*/
|
|
6343
7086
|
guided_json?: object;
|
|
6344
7087
|
/**
|
|
@@ -6612,7 +7355,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6612
7355
|
}
|
|
6613
7356
|
)[];
|
|
6614
7357
|
/**
|
|
6615
|
-
* JSON schema that should be
|
|
7358
|
+
* JSON schema that should be fufilled for the response.
|
|
6616
7359
|
*/
|
|
6617
7360
|
guided_json?: object;
|
|
6618
7361
|
/**
|
|
@@ -6705,7 +7448,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6705
7448
|
*/
|
|
6706
7449
|
prompt: string;
|
|
6707
7450
|
/**
|
|
6708
|
-
* JSON schema that should be
|
|
7451
|
+
* JSON schema that should be fufilled for the response.
|
|
6709
7452
|
*/
|
|
6710
7453
|
guided_json?: object;
|
|
6711
7454
|
/**
|
|
@@ -6869,7 +7612,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6869
7612
|
}
|
|
6870
7613
|
)[];
|
|
6871
7614
|
/**
|
|
6872
|
-
* JSON schema that should be
|
|
7615
|
+
* JSON schema that should be fufilled for the response.
|
|
6873
7616
|
*/
|
|
6874
7617
|
guided_json?: object;
|
|
6875
7618
|
/**
|
|
@@ -7150,7 +7893,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7150
7893
|
)[];
|
|
7151
7894
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7152
7895
|
/**
|
|
7153
|
-
* JSON schema that should be
|
|
7896
|
+
* JSON schema that should be fufilled for the response.
|
|
7154
7897
|
*/
|
|
7155
7898
|
guided_json?: object;
|
|
7156
7899
|
/**
|
|
@@ -7389,7 +8132,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7389
8132
|
)[];
|
|
7390
8133
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7391
8134
|
/**
|
|
7392
|
-
* JSON schema that should be
|
|
8135
|
+
* JSON schema that should be fufilled for the response.
|
|
7393
8136
|
*/
|
|
7394
8137
|
guided_json?: object;
|
|
7395
8138
|
/**
|
|
@@ -7554,10 +8297,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7554
8297
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7555
8298
|
*/
|
|
7556
8299
|
role: string;
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
8300
|
+
content:
|
|
8301
|
+
| string
|
|
8302
|
+
| {
|
|
8303
|
+
/**
|
|
8304
|
+
* Type of the content (text)
|
|
8305
|
+
*/
|
|
8306
|
+
type?: string;
|
|
8307
|
+
/**
|
|
8308
|
+
* Text content
|
|
8309
|
+
*/
|
|
8310
|
+
text?: string;
|
|
8311
|
+
}[];
|
|
7561
8312
|
}[];
|
|
7562
8313
|
functions?: {
|
|
7563
8314
|
name: string;
|
|
@@ -7769,10 +8520,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7769
8520
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7770
8521
|
*/
|
|
7771
8522
|
role: string;
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
8523
|
+
content:
|
|
8524
|
+
| string
|
|
8525
|
+
| {
|
|
8526
|
+
/**
|
|
8527
|
+
* Type of the content (text)
|
|
8528
|
+
*/
|
|
8529
|
+
type?: string;
|
|
8530
|
+
/**
|
|
8531
|
+
* Text content
|
|
8532
|
+
*/
|
|
8533
|
+
text?: string;
|
|
8534
|
+
}[];
|
|
7776
8535
|
}[];
|
|
7777
8536
|
functions?: {
|
|
7778
8537
|
name: string;
|
|
@@ -8340,12 +9099,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8340
9099
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8341
9100
|
}
|
|
8342
9101
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8343
|
-
inputs: ResponsesInput
|
|
8344
|
-
postProcessedOutputs: ResponsesOutput
|
|
9102
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9103
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8345
9104
|
}
|
|
8346
9105
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8347
|
-
inputs: ResponsesInput
|
|
8348
|
-
postProcessedOutputs: ResponsesOutput
|
|
9106
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9107
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8349
9108
|
}
|
|
8350
9109
|
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8351
9110
|
/**
|
|
@@ -8477,7 +9236,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8477
9236
|
*/
|
|
8478
9237
|
text: string | string[];
|
|
8479
9238
|
/**
|
|
8480
|
-
* Target
|
|
9239
|
+
* Target langauge to translate to
|
|
8481
9240
|
*/
|
|
8482
9241
|
target_language:
|
|
8483
9242
|
| "asm_Beng"
|
|
@@ -8593,10 +9352,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8593
9352
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8594
9353
|
*/
|
|
8595
9354
|
role: string;
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
9355
|
+
content:
|
|
9356
|
+
| string
|
|
9357
|
+
| {
|
|
9358
|
+
/**
|
|
9359
|
+
* Type of the content (text)
|
|
9360
|
+
*/
|
|
9361
|
+
type?: string;
|
|
9362
|
+
/**
|
|
9363
|
+
* Text content
|
|
9364
|
+
*/
|
|
9365
|
+
text?: string;
|
|
9366
|
+
}[];
|
|
8600
9367
|
}[];
|
|
8601
9368
|
functions?: {
|
|
8602
9369
|
name: string;
|
|
@@ -8808,10 +9575,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8808
9575
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8809
9576
|
*/
|
|
8810
9577
|
role: string;
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
9578
|
+
content:
|
|
9579
|
+
| string
|
|
9580
|
+
| {
|
|
9581
|
+
/**
|
|
9582
|
+
* Type of the content (text)
|
|
9583
|
+
*/
|
|
9584
|
+
type?: string;
|
|
9585
|
+
/**
|
|
9586
|
+
* Text content
|
|
9587
|
+
*/
|
|
9588
|
+
text?: string;
|
|
9589
|
+
}[];
|
|
8815
9590
|
}[];
|
|
8816
9591
|
functions?: {
|
|
8817
9592
|
name: string;
|
|
@@ -9366,6 +10141,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9366
10141
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9367
10142
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9368
10143
|
}
|
|
10144
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10145
|
+
multipart: {
|
|
10146
|
+
body?: object;
|
|
10147
|
+
contentType?: string;
|
|
10148
|
+
};
|
|
10149
|
+
}
|
|
10150
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10151
|
+
/**
|
|
10152
|
+
* Generated image as Base64 string.
|
|
10153
|
+
*/
|
|
10154
|
+
image?: string;
|
|
10155
|
+
}
|
|
10156
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10157
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10158
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10159
|
+
}
|
|
10160
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10161
|
+
multipart: {
|
|
10162
|
+
body?: object;
|
|
10163
|
+
contentType?: string;
|
|
10164
|
+
};
|
|
10165
|
+
}
|
|
10166
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10167
|
+
/**
|
|
10168
|
+
* Generated image as Base64 string.
|
|
10169
|
+
*/
|
|
10170
|
+
image?: string;
|
|
10171
|
+
}
|
|
10172
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10173
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10174
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10175
|
+
}
|
|
10176
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10177
|
+
multipart: {
|
|
10178
|
+
body?: object;
|
|
10179
|
+
contentType?: string;
|
|
10180
|
+
};
|
|
10181
|
+
}
|
|
10182
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10183
|
+
/**
|
|
10184
|
+
* Generated image as Base64 string.
|
|
10185
|
+
*/
|
|
10186
|
+
image?: string;
|
|
10187
|
+
}
|
|
10188
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10189
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10190
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10191
|
+
}
|
|
10192
|
+
declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10193
|
+
inputs: ChatCompletionsInput;
|
|
10194
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10195
|
+
}
|
|
10196
|
+
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10197
|
+
inputs: ChatCompletionsInput;
|
|
10198
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10199
|
+
}
|
|
10200
|
+
declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10201
|
+
inputs: ChatCompletionsInput;
|
|
10202
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10203
|
+
}
|
|
9369
10204
|
interface AiModels {
|
|
9370
10205
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9371
10206
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9384,7 +10219,6 @@ interface AiModels {
|
|
|
9384
10219
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9385
10220
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9386
10221
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9387
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9388
10222
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9389
10223
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9390
10224
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9451,6 +10285,12 @@ interface AiModels {
|
|
|
9451
10285
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9452
10286
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9453
10287
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10288
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10289
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10290
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10291
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10292
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10293
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9454
10294
|
}
|
|
9455
10295
|
type AiOptions = {
|
|
9456
10296
|
/**
|
|
@@ -9476,6 +10316,7 @@ type AiOptions = {
|
|
|
9476
10316
|
returnRawResponse?: boolean;
|
|
9477
10317
|
prefix?: string;
|
|
9478
10318
|
extraHeaders?: object;
|
|
10319
|
+
signal?: AbortSignal;
|
|
9479
10320
|
};
|
|
9480
10321
|
type AiModelsSearchParams = {
|
|
9481
10322
|
author?: string;
|
|
@@ -9502,6 +10343,16 @@ type AiModelsSearchObject = {
|
|
|
9502
10343
|
value: string;
|
|
9503
10344
|
}[];
|
|
9504
10345
|
};
|
|
10346
|
+
type ChatCompletionsBase = XOR<
|
|
10347
|
+
ChatCompletionsPromptInput,
|
|
10348
|
+
ChatCompletionsMessagesInput
|
|
10349
|
+
>;
|
|
10350
|
+
type ChatCompletionsInput = XOR<
|
|
10351
|
+
ChatCompletionsBase,
|
|
10352
|
+
{
|
|
10353
|
+
requests: ChatCompletionsBase[];
|
|
10354
|
+
}
|
|
10355
|
+
>;
|
|
9505
10356
|
interface InferenceUpstreamError extends Error {}
|
|
9506
10357
|
interface AiInternalError extends Error {}
|
|
9507
10358
|
type AiModelListType = Record<string, any>;
|
|
@@ -9509,46 +10360,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
9509
10360
|
aiGatewayLogId: string | null;
|
|
9510
10361
|
gateway(gatewayId: string): AiGateway;
|
|
9511
10362
|
/**
|
|
9512
|
-
*
|
|
9513
|
-
*
|
|
9514
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9515
|
-
* - Account-level operations: `list()`, `create()`
|
|
9516
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9517
|
-
*
|
|
9518
|
-
* @example
|
|
9519
|
-
* ```typescript
|
|
9520
|
-
* // List all AI Search instances
|
|
9521
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9522
|
-
*
|
|
9523
|
-
* // Search an instance
|
|
9524
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9525
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9526
|
-
* ai_search_options: {
|
|
9527
|
-
* retrieval: { max_num_results: 10 }
|
|
9528
|
-
* }
|
|
9529
|
-
* });
|
|
9530
|
-
*
|
|
9531
|
-
* // Generate chat completions with AI Search context
|
|
9532
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9533
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9534
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9535
|
-
* });
|
|
9536
|
-
* ```
|
|
10363
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10364
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9537
10365
|
*/
|
|
9538
|
-
aiSearch():
|
|
10366
|
+
aiSearch(): AiSearchNamespace;
|
|
9539
10367
|
/**
|
|
9540
10368
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9541
|
-
* Use `
|
|
9542
|
-
*
|
|
9543
|
-
* Migration guide:
|
|
9544
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9545
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9546
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10369
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10370
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9547
10371
|
*
|
|
9548
|
-
*
|
|
9549
|
-
*
|
|
9550
|
-
* @see AiSearchAccountService
|
|
9551
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10372
|
+
* @param autoragId Instance ID
|
|
9552
10373
|
*/
|
|
9553
10374
|
autorag(autoragId: string): AutoRAG;
|
|
9554
10375
|
run<
|
|
@@ -9707,22 +10528,23 @@ declare abstract class AiGateway {
|
|
|
9707
10528
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9708
10529
|
}
|
|
9709
10530
|
/**
|
|
9710
|
-
* @deprecated
|
|
9711
|
-
*
|
|
10531
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10532
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9712
10533
|
*/
|
|
9713
10534
|
interface AutoRAGInternalError extends Error {}
|
|
9714
10535
|
/**
|
|
9715
|
-
* @deprecated
|
|
9716
|
-
*
|
|
10536
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10537
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9717
10538
|
*/
|
|
9718
10539
|
interface AutoRAGNotFoundError extends Error {}
|
|
9719
10540
|
/**
|
|
9720
|
-
* @deprecated
|
|
10541
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10542
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9721
10543
|
*/
|
|
9722
10544
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
9723
10545
|
/**
|
|
9724
|
-
* @deprecated
|
|
9725
|
-
*
|
|
10546
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10547
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9726
10548
|
*/
|
|
9727
10549
|
interface AutoRAGNameNotSetError extends Error {}
|
|
9728
10550
|
type ComparisonFilter = {
|
|
@@ -9735,9 +10557,8 @@ type CompoundFilter = {
|
|
|
9735
10557
|
filters: ComparisonFilter[];
|
|
9736
10558
|
};
|
|
9737
10559
|
/**
|
|
9738
|
-
* @deprecated
|
|
9739
|
-
*
|
|
9740
|
-
* @see AiSearchSearchRequest
|
|
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
|
type AutoRagSearchRequest = {
|
|
9743
10564
|
query: string;
|
|
@@ -9754,18 +10575,16 @@ type AutoRagSearchRequest = {
|
|
|
9754
10575
|
rewrite_query?: boolean;
|
|
9755
10576
|
};
|
|
9756
10577
|
/**
|
|
9757
|
-
* @deprecated
|
|
9758
|
-
*
|
|
9759
|
-
* @see AiSearchChatCompletionsRequest
|
|
10578
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10579
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9760
10580
|
*/
|
|
9761
10581
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9762
10582
|
stream?: boolean;
|
|
9763
10583
|
system_prompt?: string;
|
|
9764
10584
|
};
|
|
9765
10585
|
/**
|
|
9766
|
-
* @deprecated
|
|
9767
|
-
*
|
|
9768
|
-
* @see AiSearchChatCompletionsRequest
|
|
10586
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10587
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9769
10588
|
*/
|
|
9770
10589
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
9771
10590
|
AutoRagAiSearchRequest,
|
|
@@ -9774,9 +10593,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9774
10593
|
stream: true;
|
|
9775
10594
|
};
|
|
9776
10595
|
/**
|
|
9777
|
-
* @deprecated
|
|
9778
|
-
*
|
|
9779
|
-
* @see AiSearchSearchResponse
|
|
10596
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10597
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9780
10598
|
*/
|
|
9781
10599
|
type AutoRagSearchResponse = {
|
|
9782
10600
|
object: "vector_store.search_results.page";
|
|
@@ -9795,9 +10613,8 @@ type AutoRagSearchResponse = {
|
|
|
9795
10613
|
next_page: string | null;
|
|
9796
10614
|
};
|
|
9797
10615
|
/**
|
|
9798
|
-
* @deprecated
|
|
9799
|
-
*
|
|
9800
|
-
* @see AiSearchListResponse
|
|
10616
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10617
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9801
10618
|
*/
|
|
9802
10619
|
type AutoRagListResponse = {
|
|
9803
10620
|
id: string;
|
|
@@ -9809,49 +10626,40 @@ type AutoRagListResponse = {
|
|
|
9809
10626
|
status: string;
|
|
9810
10627
|
}[];
|
|
9811
10628
|
/**
|
|
9812
|
-
* @deprecated
|
|
9813
|
-
*
|
|
10629
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10630
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9814
10631
|
*/
|
|
9815
10632
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9816
10633
|
response: string;
|
|
9817
10634
|
};
|
|
9818
10635
|
/**
|
|
9819
|
-
* @deprecated
|
|
9820
|
-
*
|
|
9821
|
-
*
|
|
9822
|
-
* Migration guide:
|
|
9823
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9824
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9825
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9826
|
-
*
|
|
9827
|
-
* @see AiSearchAccountService
|
|
9828
|
-
* @see AiSearchInstanceService
|
|
10636
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10637
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9829
10638
|
*/
|
|
9830
10639
|
declare abstract class AutoRAG {
|
|
9831
10640
|
/**
|
|
9832
|
-
* @deprecated Use
|
|
9833
|
-
*
|
|
10641
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10642
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9834
10643
|
*/
|
|
9835
10644
|
list(): Promise<AutoRagListResponse>;
|
|
9836
10645
|
/**
|
|
9837
|
-
* @deprecated Use
|
|
9838
|
-
*
|
|
9839
|
-
* @see AiSearchInstanceService.search
|
|
10646
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10647
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9840
10648
|
*/
|
|
9841
10649
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9842
10650
|
/**
|
|
9843
|
-
* @deprecated Use
|
|
9844
|
-
*
|
|
10651
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10652
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9845
10653
|
*/
|
|
9846
10654
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9847
10655
|
/**
|
|
9848
|
-
* @deprecated Use
|
|
9849
|
-
*
|
|
10656
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10657
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9850
10658
|
*/
|
|
9851
10659
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9852
10660
|
/**
|
|
9853
|
-
* @deprecated Use
|
|
9854
|
-
*
|
|
10661
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10662
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9855
10663
|
*/
|
|
9856
10664
|
aiSearch(
|
|
9857
10665
|
params: AutoRagAiSearchRequest,
|
|
@@ -9976,6 +10784,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
9976
10784
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
9977
10785
|
*/
|
|
9978
10786
|
cacheTtlByStatus?: Record<string, number>;
|
|
10787
|
+
/**
|
|
10788
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10789
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10790
|
+
*
|
|
10791
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10792
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10793
|
+
*
|
|
10794
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10795
|
+
*/
|
|
10796
|
+
cacheControl?: string;
|
|
10797
|
+
/**
|
|
10798
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10799
|
+
*/
|
|
10800
|
+
cacheReserveEligible?: boolean;
|
|
10801
|
+
/**
|
|
10802
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10803
|
+
*/
|
|
10804
|
+
respectStrongEtag?: boolean;
|
|
10805
|
+
/**
|
|
10806
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10807
|
+
*/
|
|
10808
|
+
stripEtags?: boolean;
|
|
10809
|
+
/**
|
|
10810
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10811
|
+
*/
|
|
10812
|
+
stripLastModified?: boolean;
|
|
10813
|
+
/**
|
|
10814
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10815
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10816
|
+
*/
|
|
10817
|
+
cacheDeceptionArmor?: boolean;
|
|
10818
|
+
/**
|
|
10819
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10820
|
+
*/
|
|
10821
|
+
cacheReserveMinimumFileSize?: number;
|
|
9979
10822
|
scrapeShield?: boolean;
|
|
9980
10823
|
apps?: boolean;
|
|
9981
10824
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11888,6 +12731,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11888
12731
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11889
12732
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11890
12733
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12734
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11891
12735
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11892
12736
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11893
12737
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11908,6 +12752,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11908
12752
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11909
12753
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11910
12754
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12755
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11911
12756
|
webSocketMessage?(
|
|
11912
12757
|
ws: WebSocket,
|
|
11913
12758
|
message: string | ArrayBuffer,
|
|
@@ -12058,17 +12903,6 @@ interface StreamBinding {
|
|
|
12058
12903
|
* @returns A handle for per-video operations.
|
|
12059
12904
|
*/
|
|
12060
12905
|
video(id: string): StreamVideoHandle;
|
|
12061
|
-
/**
|
|
12062
|
-
* Uploads a new video from a File.
|
|
12063
|
-
* @param file The video file to upload.
|
|
12064
|
-
* @returns The uploaded video details.
|
|
12065
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12066
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12067
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12068
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12069
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12070
|
-
*/
|
|
12071
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12072
12906
|
/**
|
|
12073
12907
|
* Uploads a new video from a provided URL.
|
|
12074
12908
|
* @param url The URL to upload from.
|
|
@@ -12918,6 +13752,9 @@ declare namespace TailStream {
|
|
|
12918
13752
|
readonly type: "fetch";
|
|
12919
13753
|
readonly statusCode: number;
|
|
12920
13754
|
}
|
|
13755
|
+
interface ConnectEventInfo {
|
|
13756
|
+
readonly type: "connect";
|
|
13757
|
+
}
|
|
12921
13758
|
type EventOutcome =
|
|
12922
13759
|
| "ok"
|
|
12923
13760
|
| "canceled"
|
|
@@ -12948,6 +13785,7 @@ declare namespace TailStream {
|
|
|
12948
13785
|
readonly scriptVersion?: ScriptVersion;
|
|
12949
13786
|
readonly info:
|
|
12950
13787
|
| FetchEventInfo
|
|
13788
|
+
| ConnectEventInfo
|
|
12951
13789
|
| JsRpcEventInfo
|
|
12952
13790
|
| ScheduledEventInfo
|
|
12953
13791
|
| AlarmEventInfo
|