@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-08-04/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;
|
|
@@ -3725,7 +3743,7 @@ interface ContainerStartupOptions {
|
|
|
3725
3743
|
entrypoint?: string[];
|
|
3726
3744
|
enableInternet: boolean;
|
|
3727
3745
|
env?: Record<string, string>;
|
|
3728
|
-
|
|
3746
|
+
labels?: Record<string, string>;
|
|
3729
3747
|
}
|
|
3730
3748
|
/**
|
|
3731
3749
|
* 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.
|
|
@@ -3852,11 +3870,10 @@ declare abstract class Performance {
|
|
|
3852
3870
|
*/
|
|
3853
3871
|
toJSON(): object;
|
|
3854
3872
|
}
|
|
3855
|
-
// AI Search
|
|
3873
|
+
// ============ AI Search Error Interfaces ============
|
|
3856
3874
|
interface AiSearchInternalError extends Error {}
|
|
3857
3875
|
interface AiSearchNotFoundError extends Error {}
|
|
3858
|
-
|
|
3859
|
-
// AI Search V2 Request Types
|
|
3876
|
+
// ============ AI Search Request Types ============
|
|
3860
3877
|
type AiSearchSearchRequest = {
|
|
3861
3878
|
messages: Array<{
|
|
3862
3879
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3881,9 +3898,8 @@ type AiSearchSearchRequest = {
|
|
|
3881
3898
|
[key: string]: unknown;
|
|
3882
3899
|
};
|
|
3883
3900
|
reranking?: {
|
|
3884
|
-
/** Enable reranking (default false) */
|
|
3885
3901
|
enabled?: boolean;
|
|
3886
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3902
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3887
3903
|
/** Match threshold (0-1, default 0.4) */
|
|
3888
3904
|
match_threshold?: number;
|
|
3889
3905
|
[key: string]: unknown;
|
|
@@ -3895,6 +3911,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3895
3911
|
messages: Array<{
|
|
3896
3912
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3897
3913
|
content: string | null;
|
|
3914
|
+
[key: string]: unknown;
|
|
3898
3915
|
}>;
|
|
3899
3916
|
model?: string;
|
|
3900
3917
|
stream?: boolean;
|
|
@@ -3915,7 +3932,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3915
3932
|
};
|
|
3916
3933
|
reranking?: {
|
|
3917
3934
|
enabled?: boolean;
|
|
3918
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3935
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3919
3936
|
match_threshold?: number;
|
|
3920
3937
|
[key: string]: unknown;
|
|
3921
3938
|
};
|
|
@@ -3923,7 +3940,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
3923
3940
|
};
|
|
3924
3941
|
[key: string]: unknown;
|
|
3925
3942
|
};
|
|
3926
|
-
// AI Search
|
|
3943
|
+
// ============ AI Search Response Types ============
|
|
3927
3944
|
type AiSearchSearchResponse = {
|
|
3928
3945
|
search_query: string;
|
|
3929
3946
|
chunks: Array<{
|
|
@@ -3942,26 +3959,65 @@ type AiSearchSearchResponse = {
|
|
|
3942
3959
|
keyword_score?: number;
|
|
3943
3960
|
/** Vector similarity score (0-1) */
|
|
3944
3961
|
vector_score?: number;
|
|
3962
|
+
[key: string]: unknown;
|
|
3963
|
+
};
|
|
3964
|
+
}>;
|
|
3965
|
+
};
|
|
3966
|
+
type AiSearchChatCompletionsResponse = {
|
|
3967
|
+
id?: string;
|
|
3968
|
+
object?: string;
|
|
3969
|
+
model?: string;
|
|
3970
|
+
choices: Array<{
|
|
3971
|
+
index?: number;
|
|
3972
|
+
message: {
|
|
3973
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3974
|
+
content: string | null;
|
|
3975
|
+
[key: string]: unknown;
|
|
3945
3976
|
};
|
|
3977
|
+
[key: string]: unknown;
|
|
3946
3978
|
}>;
|
|
3979
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
3980
|
+
[key: string]: unknown;
|
|
3947
3981
|
};
|
|
3948
|
-
type
|
|
3982
|
+
type AiSearchStatsResponse = {
|
|
3983
|
+
queued?: number;
|
|
3984
|
+
running?: number;
|
|
3985
|
+
completed?: number;
|
|
3986
|
+
error?: number;
|
|
3987
|
+
skipped?: number;
|
|
3988
|
+
outdated?: number;
|
|
3989
|
+
last_activity?: string;
|
|
3990
|
+
};
|
|
3991
|
+
// ============ AI Search Instance Info Types ============
|
|
3992
|
+
type AiSearchInstanceInfo = {
|
|
3949
3993
|
id: string;
|
|
3950
|
-
|
|
3951
|
-
account_id?: string;
|
|
3952
|
-
account_tag?: string;
|
|
3953
|
-
/** Whether the instance is enabled (default true) */
|
|
3954
|
-
enable?: boolean;
|
|
3955
|
-
type?: "r2" | "web-crawler";
|
|
3994
|
+
type?: "r2" | "web-crawler" | string;
|
|
3956
3995
|
source?: string;
|
|
3996
|
+
paused?: boolean;
|
|
3997
|
+
status?: string;
|
|
3998
|
+
namespace?: string;
|
|
3999
|
+
created_at?: string;
|
|
4000
|
+
modified_at?: string;
|
|
3957
4001
|
[key: string]: unknown;
|
|
3958
|
-
}
|
|
4002
|
+
};
|
|
4003
|
+
type AiSearchListResponse = {
|
|
4004
|
+
result: AiSearchInstanceInfo[];
|
|
4005
|
+
result_info?: {
|
|
4006
|
+
count: number;
|
|
4007
|
+
page: number;
|
|
4008
|
+
per_page: number;
|
|
4009
|
+
total_count: number;
|
|
4010
|
+
};
|
|
4011
|
+
};
|
|
4012
|
+
// ============ AI Search Config Types ============
|
|
3959
4013
|
type AiSearchConfig = {
|
|
3960
4014
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3961
4015
|
id: string;
|
|
3962
|
-
type
|
|
3963
|
-
|
|
3964
|
-
|
|
4016
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4017
|
+
type?: "r2" | "web-crawler" | string;
|
|
4018
|
+
/** Source URL (required for web-crawler type). */
|
|
4019
|
+
source?: string;
|
|
4020
|
+
source_params?: unknown;
|
|
3965
4021
|
/** Token ID (UUID format) */
|
|
3966
4022
|
token_id?: string;
|
|
3967
4023
|
ai_gateway_id?: string;
|
|
@@ -3971,54 +4027,307 @@ type AiSearchConfig = {
|
|
|
3971
4027
|
reranking?: boolean;
|
|
3972
4028
|
embedding_model?: string;
|
|
3973
4029
|
ai_search_model?: string;
|
|
4030
|
+
[key: string]: unknown;
|
|
3974
4031
|
};
|
|
3975
|
-
|
|
4032
|
+
// ============ AI Search Item Types ============
|
|
4033
|
+
type AiSearchItemInfo = {
|
|
3976
4034
|
id: string;
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
4035
|
+
key: string;
|
|
4036
|
+
status:
|
|
4037
|
+
| "completed"
|
|
4038
|
+
| "error"
|
|
4039
|
+
| "skipped"
|
|
4040
|
+
| "queued"
|
|
4041
|
+
| "processing"
|
|
4042
|
+
| "outdated";
|
|
4043
|
+
metadata?: Record<string, unknown>;
|
|
3980
4044
|
[key: string]: unknown;
|
|
3981
4045
|
};
|
|
3982
|
-
|
|
3983
|
-
|
|
4046
|
+
type AiSearchItemContentResult = {
|
|
4047
|
+
body: ReadableStream;
|
|
4048
|
+
contentType: string;
|
|
4049
|
+
filename: string;
|
|
4050
|
+
size: number;
|
|
4051
|
+
};
|
|
4052
|
+
type AiSearchUploadItemOptions = {
|
|
4053
|
+
metadata?: Record<string, unknown>;
|
|
4054
|
+
};
|
|
4055
|
+
type AiSearchListItemsParams = {
|
|
4056
|
+
page?: number;
|
|
4057
|
+
per_page?: number;
|
|
4058
|
+
};
|
|
4059
|
+
type AiSearchListItemsResponse = {
|
|
4060
|
+
result: AiSearchItemInfo[];
|
|
4061
|
+
result_info?: {
|
|
4062
|
+
count: number;
|
|
4063
|
+
page: number;
|
|
4064
|
+
per_page: number;
|
|
4065
|
+
total_count: number;
|
|
4066
|
+
};
|
|
4067
|
+
};
|
|
4068
|
+
// ============ AI Search Job Types ============
|
|
4069
|
+
type AiSearchJobInfo = {
|
|
4070
|
+
id: string;
|
|
4071
|
+
source: "user" | "schedule";
|
|
4072
|
+
description?: string;
|
|
4073
|
+
last_seen_at?: string;
|
|
4074
|
+
started_at?: string;
|
|
4075
|
+
ended_at?: string;
|
|
4076
|
+
end_reason?: string;
|
|
4077
|
+
};
|
|
4078
|
+
type AiSearchJobLog = {
|
|
4079
|
+
id: number;
|
|
4080
|
+
message: string;
|
|
4081
|
+
message_type: number;
|
|
4082
|
+
created_at: number;
|
|
4083
|
+
};
|
|
4084
|
+
type AiSearchCreateJobParams = {
|
|
4085
|
+
description?: string;
|
|
4086
|
+
};
|
|
4087
|
+
type AiSearchListJobsParams = {
|
|
4088
|
+
page?: number;
|
|
4089
|
+
per_page?: number;
|
|
4090
|
+
};
|
|
4091
|
+
type AiSearchListJobsResponse = {
|
|
4092
|
+
result: AiSearchJobInfo[];
|
|
4093
|
+
result_info?: {
|
|
4094
|
+
count: number;
|
|
4095
|
+
page: number;
|
|
4096
|
+
per_page: number;
|
|
4097
|
+
total_count: number;
|
|
4098
|
+
};
|
|
4099
|
+
};
|
|
4100
|
+
type AiSearchJobLogsParams = {
|
|
4101
|
+
page?: number;
|
|
4102
|
+
per_page?: number;
|
|
4103
|
+
};
|
|
4104
|
+
type AiSearchJobLogsResponse = {
|
|
4105
|
+
result: AiSearchJobLog[];
|
|
4106
|
+
result_info?: {
|
|
4107
|
+
count: number;
|
|
4108
|
+
page: number;
|
|
4109
|
+
per_page: number;
|
|
4110
|
+
total_count: number;
|
|
4111
|
+
};
|
|
4112
|
+
};
|
|
4113
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4114
|
+
/**
|
|
4115
|
+
* Single item service for an AI Search instance.
|
|
4116
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4117
|
+
*/
|
|
4118
|
+
declare abstract class AiSearchItem {
|
|
4119
|
+
/** Get metadata about this item. */
|
|
4120
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4121
|
+
/**
|
|
4122
|
+
* Download the item's content.
|
|
4123
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4124
|
+
*/
|
|
4125
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4126
|
+
}
|
|
4127
|
+
/**
|
|
4128
|
+
* Items collection service for an AI Search instance.
|
|
4129
|
+
* Provides list, upload, and access to individual items.
|
|
4130
|
+
*/
|
|
4131
|
+
declare abstract class AiSearchItems {
|
|
4132
|
+
/** List items in this instance. */
|
|
4133
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4134
|
+
/**
|
|
4135
|
+
* Upload a file as an item.
|
|
4136
|
+
* @param name Filename for the uploaded item.
|
|
4137
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4138
|
+
* @param options Optional metadata to attach to the item.
|
|
4139
|
+
* @returns The created item info.
|
|
4140
|
+
*/
|
|
4141
|
+
upload(
|
|
4142
|
+
name: string,
|
|
4143
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4144
|
+
options?: AiSearchUploadItemOptions,
|
|
4145
|
+
): Promise<AiSearchItemInfo>;
|
|
4146
|
+
/**
|
|
4147
|
+
* Upload a file and poll until processing completes.
|
|
4148
|
+
* @param name Filename for the uploaded item.
|
|
4149
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4150
|
+
* @param options Optional metadata to attach to the item.
|
|
4151
|
+
* @returns The item info after processing completes (or timeout).
|
|
4152
|
+
*/
|
|
4153
|
+
uploadAndPoll(
|
|
4154
|
+
name: string,
|
|
4155
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4156
|
+
options?: AiSearchUploadItemOptions,
|
|
4157
|
+
): Promise<AiSearchItemInfo>;
|
|
4158
|
+
/**
|
|
4159
|
+
* Get an item by ID.
|
|
4160
|
+
* @param itemId The item identifier.
|
|
4161
|
+
* @returns Item service for info, delete, and download operations.
|
|
4162
|
+
*/
|
|
4163
|
+
get(itemId: string): AiSearchItem;
|
|
4164
|
+
/** Delete this item from the instance.
|
|
4165
|
+
* @param itemId The item identifier.
|
|
4166
|
+
*/
|
|
4167
|
+
delete(itemId: string): Promise<void>;
|
|
4168
|
+
}
|
|
4169
|
+
/**
|
|
4170
|
+
* Single job service for an AI Search instance.
|
|
4171
|
+
* Provides info and logs for a specific job.
|
|
4172
|
+
*/
|
|
4173
|
+
declare abstract class AiSearchJob {
|
|
4174
|
+
/** Get metadata about this job. */
|
|
4175
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4176
|
+
/** Get logs for this job. */
|
|
4177
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4178
|
+
}
|
|
4179
|
+
/**
|
|
4180
|
+
* Jobs collection service for an AI Search instance.
|
|
4181
|
+
* Provides list, create, and access to individual jobs.
|
|
4182
|
+
*/
|
|
4183
|
+
declare abstract class AiSearchJobs {
|
|
4184
|
+
/** List jobs for this instance. */
|
|
4185
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4186
|
+
/**
|
|
4187
|
+
* Create a new indexing job.
|
|
4188
|
+
* @param params Optional job parameters.
|
|
4189
|
+
* @returns The created job info.
|
|
4190
|
+
*/
|
|
4191
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4192
|
+
/**
|
|
4193
|
+
* Get a job by ID.
|
|
4194
|
+
* @param jobId The job identifier.
|
|
4195
|
+
* @returns Job service for info and logs operations.
|
|
4196
|
+
*/
|
|
4197
|
+
get(jobId: string): AiSearchJob;
|
|
4198
|
+
}
|
|
4199
|
+
// ============ AI Search Binding Classes ============
|
|
4200
|
+
/**
|
|
4201
|
+
* Instance-level AI Search service.
|
|
4202
|
+
*
|
|
4203
|
+
* Used as:
|
|
4204
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4205
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4206
|
+
*
|
|
4207
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4208
|
+
*
|
|
4209
|
+
* @example
|
|
4210
|
+
* ```ts
|
|
4211
|
+
* // Via namespace binding
|
|
4212
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4213
|
+
* const results = await instance.search({
|
|
4214
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4215
|
+
* });
|
|
4216
|
+
*
|
|
4217
|
+
* // Via single instance binding
|
|
4218
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4219
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4220
|
+
* });
|
|
4221
|
+
* ```
|
|
4222
|
+
*/
|
|
4223
|
+
declare abstract class AiSearchInstance {
|
|
3984
4224
|
/**
|
|
3985
4225
|
* Search the AI Search instance for relevant chunks.
|
|
3986
|
-
* @param params Search request with messages and AI search options
|
|
3987
|
-
* @returns Search response with matching chunks
|
|
4226
|
+
* @param params Search request with messages and optional AI search options.
|
|
4227
|
+
* @returns Search response with matching chunks and search query.
|
|
3988
4228
|
*/
|
|
3989
4229
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4230
|
+
/**
|
|
4231
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4232
|
+
* @param params Chat completions request with stream: true.
|
|
4233
|
+
* @returns ReadableStream of server-sent events.
|
|
4234
|
+
*/
|
|
4235
|
+
chatCompletions(
|
|
4236
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4237
|
+
stream: true;
|
|
4238
|
+
},
|
|
4239
|
+
): Promise<ReadableStream>;
|
|
3990
4240
|
/**
|
|
3991
4241
|
* Generate chat completions with AI Search context.
|
|
3992
|
-
* @param params Chat completions request
|
|
3993
|
-
* @returns
|
|
4242
|
+
* @param params Chat completions request.
|
|
4243
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
3994
4244
|
*/
|
|
3995
4245
|
chatCompletions(
|
|
3996
4246
|
params: AiSearchChatCompletionsRequest,
|
|
3997
|
-
): Promise<
|
|
4247
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
3998
4248
|
/**
|
|
3999
|
-
*
|
|
4249
|
+
* Update the instance configuration.
|
|
4250
|
+
* @param config Partial configuration to update.
|
|
4251
|
+
* @returns Updated instance info.
|
|
4000
4252
|
*/
|
|
4001
|
-
|
|
4253
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4254
|
+
/** Get metadata about this instance. */
|
|
4255
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4256
|
+
/**
|
|
4257
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4258
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4259
|
+
*/
|
|
4260
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4261
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4262
|
+
get items(): AiSearchItems;
|
|
4263
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4264
|
+
get jobs(): AiSearchJobs;
|
|
4002
4265
|
}
|
|
4003
|
-
|
|
4004
|
-
|
|
4266
|
+
/**
|
|
4267
|
+
* Namespace-level AI Search service.
|
|
4268
|
+
*
|
|
4269
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4270
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4271
|
+
*
|
|
4272
|
+
* @example
|
|
4273
|
+
* ```ts
|
|
4274
|
+
* // Access an instance within the namespace
|
|
4275
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4276
|
+
* const results = await blog.search({
|
|
4277
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4278
|
+
* });
|
|
4279
|
+
*
|
|
4280
|
+
* // List all instances in the namespace
|
|
4281
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4282
|
+
*
|
|
4283
|
+
* // Create a new instance with built-in storage
|
|
4284
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4285
|
+
* id: "tenant-123",
|
|
4286
|
+
* });
|
|
4287
|
+
*
|
|
4288
|
+
* // Upload items into the instance
|
|
4289
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4290
|
+
*
|
|
4291
|
+
* // Delete an instance
|
|
4292
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4293
|
+
* ```
|
|
4294
|
+
*/
|
|
4295
|
+
declare abstract class AiSearchNamespace {
|
|
4005
4296
|
/**
|
|
4006
|
-
*
|
|
4007
|
-
* @
|
|
4297
|
+
* Get an instance by name within the bound namespace.
|
|
4298
|
+
* @param name Instance name.
|
|
4299
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4300
|
+
*/
|
|
4301
|
+
get(name: string): AiSearchInstance;
|
|
4302
|
+
/**
|
|
4303
|
+
* List all instances in the bound namespace.
|
|
4304
|
+
* @returns Array of instance metadata.
|
|
4008
4305
|
*/
|
|
4009
4306
|
list(): Promise<AiSearchListResponse>;
|
|
4010
4307
|
/**
|
|
4011
|
-
*
|
|
4012
|
-
* @param
|
|
4013
|
-
* @returns Instance service for
|
|
4308
|
+
* Create a new instance within the bound namespace.
|
|
4309
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4310
|
+
* @returns Instance service for the newly created instance.
|
|
4311
|
+
*
|
|
4312
|
+
* @example
|
|
4313
|
+
* ```ts
|
|
4314
|
+
* // Create with built-in storage (upload items manually)
|
|
4315
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4316
|
+
*
|
|
4317
|
+
* // Create with web crawler source
|
|
4318
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4319
|
+
* id: "docs-search",
|
|
4320
|
+
* type: "web-crawler",
|
|
4321
|
+
* source: "https://developers.cloudflare.com",
|
|
4322
|
+
* });
|
|
4323
|
+
* ```
|
|
4014
4324
|
*/
|
|
4015
|
-
|
|
4325
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4016
4326
|
/**
|
|
4017
|
-
*
|
|
4018
|
-
* @param
|
|
4019
|
-
* @returns Instance service for performing operations
|
|
4327
|
+
* Delete an instance from the bound namespace.
|
|
4328
|
+
* @param name Instance name to delete.
|
|
4020
4329
|
*/
|
|
4021
|
-
|
|
4330
|
+
delete(name: string): Promise<void>;
|
|
4022
4331
|
}
|
|
4023
4332
|
type AiImageClassificationInput = {
|
|
4024
4333
|
image: number[];
|
|
@@ -4294,6 +4603,400 @@ declare abstract class BaseAiTranslation {
|
|
|
4294
4603
|
inputs: AiTranslationInput;
|
|
4295
4604
|
postProcessedOutputs: AiTranslationOutput;
|
|
4296
4605
|
}
|
|
4606
|
+
/**
|
|
4607
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4608
|
+
*/
|
|
4609
|
+
type ChatCompletionContentPartText = {
|
|
4610
|
+
type: "text";
|
|
4611
|
+
text: string;
|
|
4612
|
+
};
|
|
4613
|
+
type ChatCompletionContentPartImage = {
|
|
4614
|
+
type: "image_url";
|
|
4615
|
+
image_url: {
|
|
4616
|
+
url: string;
|
|
4617
|
+
detail?: "auto" | "low" | "high";
|
|
4618
|
+
};
|
|
4619
|
+
};
|
|
4620
|
+
type ChatCompletionContentPartInputAudio = {
|
|
4621
|
+
type: "input_audio";
|
|
4622
|
+
input_audio: {
|
|
4623
|
+
/** Base64 encoded audio data. */
|
|
4624
|
+
data: string;
|
|
4625
|
+
format: "wav" | "mp3";
|
|
4626
|
+
};
|
|
4627
|
+
};
|
|
4628
|
+
type ChatCompletionContentPartFile = {
|
|
4629
|
+
type: "file";
|
|
4630
|
+
file: {
|
|
4631
|
+
/** Base64 encoded file data. */
|
|
4632
|
+
file_data?: string;
|
|
4633
|
+
/** The ID of an uploaded file. */
|
|
4634
|
+
file_id?: string;
|
|
4635
|
+
filename?: string;
|
|
4636
|
+
};
|
|
4637
|
+
};
|
|
4638
|
+
type ChatCompletionContentPartRefusal = {
|
|
4639
|
+
type: "refusal";
|
|
4640
|
+
refusal: string;
|
|
4641
|
+
};
|
|
4642
|
+
type ChatCompletionContentPart =
|
|
4643
|
+
| ChatCompletionContentPartText
|
|
4644
|
+
| ChatCompletionContentPartImage
|
|
4645
|
+
| ChatCompletionContentPartInputAudio
|
|
4646
|
+
| ChatCompletionContentPartFile;
|
|
4647
|
+
type FunctionDefinition = {
|
|
4648
|
+
name: string;
|
|
4649
|
+
description?: string;
|
|
4650
|
+
parameters?: Record<string, unknown>;
|
|
4651
|
+
strict?: boolean | null;
|
|
4652
|
+
};
|
|
4653
|
+
type ChatCompletionFunctionTool = {
|
|
4654
|
+
type: "function";
|
|
4655
|
+
function: FunctionDefinition;
|
|
4656
|
+
};
|
|
4657
|
+
type ChatCompletionCustomToolGrammarFormat = {
|
|
4658
|
+
type: "grammar";
|
|
4659
|
+
grammar: {
|
|
4660
|
+
definition: string;
|
|
4661
|
+
syntax: "lark" | "regex";
|
|
4662
|
+
};
|
|
4663
|
+
};
|
|
4664
|
+
type ChatCompletionCustomToolTextFormat = {
|
|
4665
|
+
type: "text";
|
|
4666
|
+
};
|
|
4667
|
+
type ChatCompletionCustomToolFormat =
|
|
4668
|
+
| ChatCompletionCustomToolTextFormat
|
|
4669
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4670
|
+
type ChatCompletionCustomTool = {
|
|
4671
|
+
type: "custom";
|
|
4672
|
+
custom: {
|
|
4673
|
+
name: string;
|
|
4674
|
+
description?: string;
|
|
4675
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4676
|
+
};
|
|
4677
|
+
};
|
|
4678
|
+
type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
|
|
4679
|
+
type ChatCompletionMessageFunctionToolCall = {
|
|
4680
|
+
id: string;
|
|
4681
|
+
type: "function";
|
|
4682
|
+
function: {
|
|
4683
|
+
name: string;
|
|
4684
|
+
/** JSON-encoded arguments string. */
|
|
4685
|
+
arguments: string;
|
|
4686
|
+
};
|
|
4687
|
+
};
|
|
4688
|
+
type ChatCompletionMessageCustomToolCall = {
|
|
4689
|
+
id: string;
|
|
4690
|
+
type: "custom";
|
|
4691
|
+
custom: {
|
|
4692
|
+
name: string;
|
|
4693
|
+
input: string;
|
|
4694
|
+
};
|
|
4695
|
+
};
|
|
4696
|
+
type ChatCompletionMessageToolCall =
|
|
4697
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4698
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4699
|
+
type ChatCompletionToolChoiceFunction = {
|
|
4700
|
+
type: "function";
|
|
4701
|
+
function: {
|
|
4702
|
+
name: string;
|
|
4703
|
+
};
|
|
4704
|
+
};
|
|
4705
|
+
type ChatCompletionToolChoiceCustom = {
|
|
4706
|
+
type: "custom";
|
|
4707
|
+
custom: {
|
|
4708
|
+
name: string;
|
|
4709
|
+
};
|
|
4710
|
+
};
|
|
4711
|
+
type ChatCompletionToolChoiceAllowedTools = {
|
|
4712
|
+
type: "allowed_tools";
|
|
4713
|
+
allowed_tools: {
|
|
4714
|
+
mode: "auto" | "required";
|
|
4715
|
+
tools: Array<Record<string, unknown>>;
|
|
4716
|
+
};
|
|
4717
|
+
};
|
|
4718
|
+
type ChatCompletionToolChoiceOption =
|
|
4719
|
+
| "none"
|
|
4720
|
+
| "auto"
|
|
4721
|
+
| "required"
|
|
4722
|
+
| ChatCompletionToolChoiceFunction
|
|
4723
|
+
| ChatCompletionToolChoiceCustom
|
|
4724
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4725
|
+
type DeveloperMessage = {
|
|
4726
|
+
role: "developer";
|
|
4727
|
+
content:
|
|
4728
|
+
| string
|
|
4729
|
+
| Array<{
|
|
4730
|
+
type: "text";
|
|
4731
|
+
text: string;
|
|
4732
|
+
}>;
|
|
4733
|
+
name?: string;
|
|
4734
|
+
};
|
|
4735
|
+
type SystemMessage = {
|
|
4736
|
+
role: "system";
|
|
4737
|
+
content:
|
|
4738
|
+
| string
|
|
4739
|
+
| Array<{
|
|
4740
|
+
type: "text";
|
|
4741
|
+
text: string;
|
|
4742
|
+
}>;
|
|
4743
|
+
name?: string;
|
|
4744
|
+
};
|
|
4745
|
+
/**
|
|
4746
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4747
|
+
*
|
|
4748
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4749
|
+
* inside nested array items does not correctly match different branches for
|
|
4750
|
+
* different array elements, so the schema uses a single merged object.
|
|
4751
|
+
*/
|
|
4752
|
+
type UserMessageContentPart = {
|
|
4753
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4754
|
+
text?: string;
|
|
4755
|
+
image_url?: {
|
|
4756
|
+
url?: string;
|
|
4757
|
+
detail?: "auto" | "low" | "high";
|
|
4758
|
+
};
|
|
4759
|
+
input_audio?: {
|
|
4760
|
+
data?: string;
|
|
4761
|
+
format?: "wav" | "mp3";
|
|
4762
|
+
};
|
|
4763
|
+
file?: {
|
|
4764
|
+
file_data?: string;
|
|
4765
|
+
file_id?: string;
|
|
4766
|
+
filename?: string;
|
|
4767
|
+
};
|
|
4768
|
+
};
|
|
4769
|
+
type UserMessage = {
|
|
4770
|
+
role: "user";
|
|
4771
|
+
content: string | Array<UserMessageContentPart>;
|
|
4772
|
+
name?: string;
|
|
4773
|
+
};
|
|
4774
|
+
type AssistantMessageContentPart = {
|
|
4775
|
+
type: "text" | "refusal";
|
|
4776
|
+
text?: string;
|
|
4777
|
+
refusal?: string;
|
|
4778
|
+
};
|
|
4779
|
+
type AssistantMessage = {
|
|
4780
|
+
role: "assistant";
|
|
4781
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4782
|
+
refusal?: string | null;
|
|
4783
|
+
name?: string;
|
|
4784
|
+
audio?: {
|
|
4785
|
+
id: string;
|
|
4786
|
+
};
|
|
4787
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4788
|
+
function_call?: {
|
|
4789
|
+
name: string;
|
|
4790
|
+
arguments: string;
|
|
4791
|
+
};
|
|
4792
|
+
};
|
|
4793
|
+
type ToolMessage = {
|
|
4794
|
+
role: "tool";
|
|
4795
|
+
content:
|
|
4796
|
+
| string
|
|
4797
|
+
| Array<{
|
|
4798
|
+
type: "text";
|
|
4799
|
+
text: string;
|
|
4800
|
+
}>;
|
|
4801
|
+
tool_call_id: string;
|
|
4802
|
+
};
|
|
4803
|
+
type FunctionMessage = {
|
|
4804
|
+
role: "function";
|
|
4805
|
+
content: string;
|
|
4806
|
+
name: string;
|
|
4807
|
+
};
|
|
4808
|
+
type ChatCompletionMessageParam =
|
|
4809
|
+
| DeveloperMessage
|
|
4810
|
+
| SystemMessage
|
|
4811
|
+
| UserMessage
|
|
4812
|
+
| AssistantMessage
|
|
4813
|
+
| ToolMessage
|
|
4814
|
+
| FunctionMessage;
|
|
4815
|
+
type ChatCompletionsResponseFormatText = {
|
|
4816
|
+
type: "text";
|
|
4817
|
+
};
|
|
4818
|
+
type ChatCompletionsResponseFormatJSONObject = {
|
|
4819
|
+
type: "json_object";
|
|
4820
|
+
};
|
|
4821
|
+
type ResponseFormatJSONSchema = {
|
|
4822
|
+
type: "json_schema";
|
|
4823
|
+
json_schema: {
|
|
4824
|
+
name: string;
|
|
4825
|
+
description?: string;
|
|
4826
|
+
schema?: Record<string, unknown>;
|
|
4827
|
+
strict?: boolean | null;
|
|
4828
|
+
};
|
|
4829
|
+
};
|
|
4830
|
+
type ResponseFormat =
|
|
4831
|
+
| ChatCompletionsResponseFormatText
|
|
4832
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4833
|
+
| ResponseFormatJSONSchema;
|
|
4834
|
+
type ChatCompletionsStreamOptions = {
|
|
4835
|
+
include_usage?: boolean;
|
|
4836
|
+
include_obfuscation?: boolean;
|
|
4837
|
+
};
|
|
4838
|
+
type PredictionContent = {
|
|
4839
|
+
type: "content";
|
|
4840
|
+
content:
|
|
4841
|
+
| string
|
|
4842
|
+
| Array<{
|
|
4843
|
+
type: "text";
|
|
4844
|
+
text: string;
|
|
4845
|
+
}>;
|
|
4846
|
+
};
|
|
4847
|
+
type AudioParams = {
|
|
4848
|
+
voice:
|
|
4849
|
+
| string
|
|
4850
|
+
| {
|
|
4851
|
+
id: string;
|
|
4852
|
+
};
|
|
4853
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4854
|
+
};
|
|
4855
|
+
type WebSearchUserLocation = {
|
|
4856
|
+
type: "approximate";
|
|
4857
|
+
approximate: {
|
|
4858
|
+
city?: string;
|
|
4859
|
+
country?: string;
|
|
4860
|
+
region?: string;
|
|
4861
|
+
timezone?: string;
|
|
4862
|
+
};
|
|
4863
|
+
};
|
|
4864
|
+
type WebSearchOptions = {
|
|
4865
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4866
|
+
user_location?: WebSearchUserLocation;
|
|
4867
|
+
};
|
|
4868
|
+
type ChatTemplateKwargs = {
|
|
4869
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4870
|
+
enable_thinking?: boolean;
|
|
4871
|
+
/** If false, preserves reasoning context between turns. */
|
|
4872
|
+
clear_thinking?: boolean;
|
|
4873
|
+
};
|
|
4874
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4875
|
+
type ChatCompletionsCommonOptions = {
|
|
4876
|
+
model?: string;
|
|
4877
|
+
audio?: AudioParams;
|
|
4878
|
+
frequency_penalty?: number | null;
|
|
4879
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4880
|
+
logprobs?: boolean | null;
|
|
4881
|
+
top_logprobs?: number | null;
|
|
4882
|
+
max_tokens?: number | null;
|
|
4883
|
+
max_completion_tokens?: number | null;
|
|
4884
|
+
metadata?: Record<string, unknown> | null;
|
|
4885
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4886
|
+
n?: number | null;
|
|
4887
|
+
parallel_tool_calls?: boolean;
|
|
4888
|
+
prediction?: PredictionContent;
|
|
4889
|
+
presence_penalty?: number | null;
|
|
4890
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4891
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4892
|
+
response_format?: ResponseFormat;
|
|
4893
|
+
seed?: number | null;
|
|
4894
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4895
|
+
stop?: string | Array<string> | null;
|
|
4896
|
+
store?: boolean | null;
|
|
4897
|
+
stream?: boolean | null;
|
|
4898
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4899
|
+
temperature?: number | null;
|
|
4900
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4901
|
+
tools?: Array<ChatCompletionTool>;
|
|
4902
|
+
top_p?: number | null;
|
|
4903
|
+
user?: string;
|
|
4904
|
+
web_search_options?: WebSearchOptions;
|
|
4905
|
+
function_call?:
|
|
4906
|
+
| "none"
|
|
4907
|
+
| "auto"
|
|
4908
|
+
| {
|
|
4909
|
+
name: string;
|
|
4910
|
+
};
|
|
4911
|
+
functions?: Array<FunctionDefinition>;
|
|
4912
|
+
};
|
|
4913
|
+
type PromptTokensDetails = {
|
|
4914
|
+
cached_tokens?: number;
|
|
4915
|
+
audio_tokens?: number;
|
|
4916
|
+
};
|
|
4917
|
+
type CompletionTokensDetails = {
|
|
4918
|
+
reasoning_tokens?: number;
|
|
4919
|
+
audio_tokens?: number;
|
|
4920
|
+
accepted_prediction_tokens?: number;
|
|
4921
|
+
rejected_prediction_tokens?: number;
|
|
4922
|
+
};
|
|
4923
|
+
type CompletionUsage = {
|
|
4924
|
+
prompt_tokens: number;
|
|
4925
|
+
completion_tokens: number;
|
|
4926
|
+
total_tokens: number;
|
|
4927
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4928
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4929
|
+
};
|
|
4930
|
+
type ChatCompletionTopLogprob = {
|
|
4931
|
+
token: string;
|
|
4932
|
+
logprob: number;
|
|
4933
|
+
bytes: Array<number> | null;
|
|
4934
|
+
};
|
|
4935
|
+
type ChatCompletionTokenLogprob = {
|
|
4936
|
+
token: string;
|
|
4937
|
+
logprob: number;
|
|
4938
|
+
bytes: Array<number> | null;
|
|
4939
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4940
|
+
};
|
|
4941
|
+
type ChatCompletionAudio = {
|
|
4942
|
+
id: string;
|
|
4943
|
+
/** Base64 encoded audio bytes. */
|
|
4944
|
+
data: string;
|
|
4945
|
+
expires_at: number;
|
|
4946
|
+
transcript: string;
|
|
4947
|
+
};
|
|
4948
|
+
type ChatCompletionUrlCitation = {
|
|
4949
|
+
type: "url_citation";
|
|
4950
|
+
url_citation: {
|
|
4951
|
+
url: string;
|
|
4952
|
+
title: string;
|
|
4953
|
+
start_index: number;
|
|
4954
|
+
end_index: number;
|
|
4955
|
+
};
|
|
4956
|
+
};
|
|
4957
|
+
type ChatCompletionResponseMessage = {
|
|
4958
|
+
role: "assistant";
|
|
4959
|
+
content: string | null;
|
|
4960
|
+
refusal: string | null;
|
|
4961
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
4962
|
+
audio?: ChatCompletionAudio;
|
|
4963
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4964
|
+
function_call?: {
|
|
4965
|
+
name: string;
|
|
4966
|
+
arguments: string;
|
|
4967
|
+
} | null;
|
|
4968
|
+
};
|
|
4969
|
+
type ChatCompletionLogprobs = {
|
|
4970
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
4971
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
4972
|
+
};
|
|
4973
|
+
type ChatCompletionChoice = {
|
|
4974
|
+
index: number;
|
|
4975
|
+
message: ChatCompletionResponseMessage;
|
|
4976
|
+
finish_reason:
|
|
4977
|
+
| "stop"
|
|
4978
|
+
| "length"
|
|
4979
|
+
| "tool_calls"
|
|
4980
|
+
| "content_filter"
|
|
4981
|
+
| "function_call";
|
|
4982
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
4983
|
+
};
|
|
4984
|
+
type ChatCompletionsPromptInput = {
|
|
4985
|
+
prompt: string;
|
|
4986
|
+
} & ChatCompletionsCommonOptions;
|
|
4987
|
+
type ChatCompletionsMessagesInput = {
|
|
4988
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
4989
|
+
} & ChatCompletionsCommonOptions;
|
|
4990
|
+
type ChatCompletionsOutput = {
|
|
4991
|
+
id: string;
|
|
4992
|
+
object: string;
|
|
4993
|
+
created: number;
|
|
4994
|
+
model: string;
|
|
4995
|
+
choices: Array<ChatCompletionChoice>;
|
|
4996
|
+
usage?: CompletionUsage;
|
|
4997
|
+
system_fingerprint?: string | null;
|
|
4998
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4999
|
+
};
|
|
4297
5000
|
/**
|
|
4298
5001
|
* Workers AI support for OpenAI's Responses API
|
|
4299
5002
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4715,6 +5418,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4715
5418
|
type StreamOptions = {
|
|
4716
5419
|
include_obfuscation?: boolean;
|
|
4717
5420
|
};
|
|
5421
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5422
|
+
type Without<T, U> = {
|
|
5423
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5424
|
+
};
|
|
5425
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5426
|
+
type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4718
5427
|
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4719
5428
|
| {
|
|
4720
5429
|
text: string | string[];
|
|
@@ -5007,10 +5716,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5007
5716
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5008
5717
|
}
|
|
5009
5718
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5719
|
+
audio:
|
|
5720
|
+
| string
|
|
5721
|
+
| {
|
|
5722
|
+
body?: object;
|
|
5723
|
+
contentType?: string;
|
|
5724
|
+
};
|
|
5014
5725
|
/**
|
|
5015
5726
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5016
5727
|
*/
|
|
@@ -5028,9 +5739,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5028
5739
|
*/
|
|
5029
5740
|
initial_prompt?: string;
|
|
5030
5741
|
/**
|
|
5031
|
-
* The prefix
|
|
5742
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5032
5743
|
*/
|
|
5033
5744
|
prefix?: string;
|
|
5745
|
+
/**
|
|
5746
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5747
|
+
*/
|
|
5748
|
+
beam_size?: number;
|
|
5749
|
+
/**
|
|
5750
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5751
|
+
*/
|
|
5752
|
+
condition_on_previous_text?: boolean;
|
|
5753
|
+
/**
|
|
5754
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5755
|
+
*/
|
|
5756
|
+
no_speech_threshold?: number;
|
|
5757
|
+
/**
|
|
5758
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5759
|
+
*/
|
|
5760
|
+
compression_ratio_threshold?: number;
|
|
5761
|
+
/**
|
|
5762
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5763
|
+
*/
|
|
5764
|
+
log_prob_threshold?: number;
|
|
5765
|
+
/**
|
|
5766
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5767
|
+
*/
|
|
5768
|
+
hallucination_silence_threshold?: number;
|
|
5034
5769
|
}
|
|
5035
5770
|
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5036
5771
|
transcription_info?: {
|
|
@@ -5177,11 +5912,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5177
5912
|
truncate_inputs?: boolean;
|
|
5178
5913
|
}
|
|
5179
5914
|
type Ai_Cf_Baai_Bge_M3_Output =
|
|
5180
|
-
|
|
|
5915
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5181
5916
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5182
|
-
|
|
|
5917
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5183
5918
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5184
|
-
interface
|
|
5919
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5185
5920
|
response?: {
|
|
5186
5921
|
/**
|
|
5187
5922
|
* Index of the context in the request
|
|
@@ -5201,7 +5936,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5201
5936
|
*/
|
|
5202
5937
|
pooling?: "mean" | "cls";
|
|
5203
5938
|
}
|
|
5204
|
-
interface
|
|
5939
|
+
interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5205
5940
|
shape?: number[];
|
|
5206
5941
|
/**
|
|
5207
5942
|
* Embeddings of the requested text values
|
|
@@ -5306,7 +6041,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5306
6041
|
*/
|
|
5307
6042
|
role?: string;
|
|
5308
6043
|
/**
|
|
5309
|
-
* The tool call id.
|
|
6044
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5310
6045
|
*/
|
|
5311
6046
|
tool_call_id?: string;
|
|
5312
6047
|
content?:
|
|
@@ -5561,10 +6296,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5561
6296
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5562
6297
|
*/
|
|
5563
6298
|
role: string;
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
6299
|
+
content:
|
|
6300
|
+
| string
|
|
6301
|
+
| {
|
|
6302
|
+
/**
|
|
6303
|
+
* Type of the content (text)
|
|
6304
|
+
*/
|
|
6305
|
+
type?: string;
|
|
6306
|
+
/**
|
|
6307
|
+
* Text content
|
|
6308
|
+
*/
|
|
6309
|
+
text?: string;
|
|
6310
|
+
}[];
|
|
5568
6311
|
}[];
|
|
5569
6312
|
functions?: {
|
|
5570
6313
|
name: string;
|
|
@@ -6220,7 +6963,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6220
6963
|
*/
|
|
6221
6964
|
role?: string;
|
|
6222
6965
|
/**
|
|
6223
|
-
* The tool call id.
|
|
6966
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6224
6967
|
*/
|
|
6225
6968
|
tool_call_id?: string;
|
|
6226
6969
|
content?:
|
|
@@ -6347,7 +7090,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6347
7090
|
}
|
|
6348
7091
|
)[];
|
|
6349
7092
|
/**
|
|
6350
|
-
* JSON schema that should be
|
|
7093
|
+
* JSON schema that should be fufilled for the response.
|
|
6351
7094
|
*/
|
|
6352
7095
|
guided_json?: object;
|
|
6353
7096
|
/**
|
|
@@ -6621,7 +7364,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6621
7364
|
}
|
|
6622
7365
|
)[];
|
|
6623
7366
|
/**
|
|
6624
|
-
* JSON schema that should be
|
|
7367
|
+
* JSON schema that should be fufilled for the response.
|
|
6625
7368
|
*/
|
|
6626
7369
|
guided_json?: object;
|
|
6627
7370
|
/**
|
|
@@ -6714,7 +7457,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6714
7457
|
*/
|
|
6715
7458
|
prompt: string;
|
|
6716
7459
|
/**
|
|
6717
|
-
* JSON schema that should be
|
|
7460
|
+
* JSON schema that should be fufilled for the response.
|
|
6718
7461
|
*/
|
|
6719
7462
|
guided_json?: object;
|
|
6720
7463
|
/**
|
|
@@ -6878,7 +7621,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6878
7621
|
}
|
|
6879
7622
|
)[];
|
|
6880
7623
|
/**
|
|
6881
|
-
* JSON schema that should be
|
|
7624
|
+
* JSON schema that should be fufilled for the response.
|
|
6882
7625
|
*/
|
|
6883
7626
|
guided_json?: object;
|
|
6884
7627
|
/**
|
|
@@ -7159,7 +7902,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7159
7902
|
)[];
|
|
7160
7903
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7161
7904
|
/**
|
|
7162
|
-
* JSON schema that should be
|
|
7905
|
+
* JSON schema that should be fufilled for the response.
|
|
7163
7906
|
*/
|
|
7164
7907
|
guided_json?: object;
|
|
7165
7908
|
/**
|
|
@@ -7398,7 +8141,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7398
8141
|
)[];
|
|
7399
8142
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7400
8143
|
/**
|
|
7401
|
-
* JSON schema that should be
|
|
8144
|
+
* JSON schema that should be fufilled for the response.
|
|
7402
8145
|
*/
|
|
7403
8146
|
guided_json?: object;
|
|
7404
8147
|
/**
|
|
@@ -7563,10 +8306,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7563
8306
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7564
8307
|
*/
|
|
7565
8308
|
role: string;
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
8309
|
+
content:
|
|
8310
|
+
| string
|
|
8311
|
+
| {
|
|
8312
|
+
/**
|
|
8313
|
+
* Type of the content (text)
|
|
8314
|
+
*/
|
|
8315
|
+
type?: string;
|
|
8316
|
+
/**
|
|
8317
|
+
* Text content
|
|
8318
|
+
*/
|
|
8319
|
+
text?: string;
|
|
8320
|
+
}[];
|
|
7570
8321
|
}[];
|
|
7571
8322
|
functions?: {
|
|
7572
8323
|
name: string;
|
|
@@ -7778,10 +8529,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7778
8529
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7779
8530
|
*/
|
|
7780
8531
|
role: string;
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
8532
|
+
content:
|
|
8533
|
+
| string
|
|
8534
|
+
| {
|
|
8535
|
+
/**
|
|
8536
|
+
* Type of the content (text)
|
|
8537
|
+
*/
|
|
8538
|
+
type?: string;
|
|
8539
|
+
/**
|
|
8540
|
+
* Text content
|
|
8541
|
+
*/
|
|
8542
|
+
text?: string;
|
|
8543
|
+
}[];
|
|
7785
8544
|
}[];
|
|
7786
8545
|
functions?: {
|
|
7787
8546
|
name: string;
|
|
@@ -8349,12 +9108,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8349
9108
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8350
9109
|
}
|
|
8351
9110
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8352
|
-
inputs: ResponsesInput
|
|
8353
|
-
postProcessedOutputs: ResponsesOutput
|
|
9111
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9112
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8354
9113
|
}
|
|
8355
9114
|
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8356
|
-
inputs: ResponsesInput
|
|
8357
|
-
postProcessedOutputs: ResponsesOutput
|
|
9115
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9116
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8358
9117
|
}
|
|
8359
9118
|
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8360
9119
|
/**
|
|
@@ -8486,7 +9245,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8486
9245
|
*/
|
|
8487
9246
|
text: string | string[];
|
|
8488
9247
|
/**
|
|
8489
|
-
* Target
|
|
9248
|
+
* Target langauge to translate to
|
|
8490
9249
|
*/
|
|
8491
9250
|
target_language:
|
|
8492
9251
|
| "asm_Beng"
|
|
@@ -8602,10 +9361,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8602
9361
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8603
9362
|
*/
|
|
8604
9363
|
role: string;
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
9364
|
+
content:
|
|
9365
|
+
| string
|
|
9366
|
+
| {
|
|
9367
|
+
/**
|
|
9368
|
+
* Type of the content (text)
|
|
9369
|
+
*/
|
|
9370
|
+
type?: string;
|
|
9371
|
+
/**
|
|
9372
|
+
* Text content
|
|
9373
|
+
*/
|
|
9374
|
+
text?: string;
|
|
9375
|
+
}[];
|
|
8609
9376
|
}[];
|
|
8610
9377
|
functions?: {
|
|
8611
9378
|
name: string;
|
|
@@ -8817,10 +9584,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8817
9584
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8818
9585
|
*/
|
|
8819
9586
|
role: string;
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
9587
|
+
content:
|
|
9588
|
+
| string
|
|
9589
|
+
| {
|
|
9590
|
+
/**
|
|
9591
|
+
* Type of the content (text)
|
|
9592
|
+
*/
|
|
9593
|
+
type?: string;
|
|
9594
|
+
/**
|
|
9595
|
+
* Text content
|
|
9596
|
+
*/
|
|
9597
|
+
text?: string;
|
|
9598
|
+
}[];
|
|
8824
9599
|
}[];
|
|
8825
9600
|
functions?: {
|
|
8826
9601
|
name: string;
|
|
@@ -9375,6 +10150,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9375
10150
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9376
10151
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9377
10152
|
}
|
|
10153
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10154
|
+
multipart: {
|
|
10155
|
+
body?: object;
|
|
10156
|
+
contentType?: string;
|
|
10157
|
+
};
|
|
10158
|
+
}
|
|
10159
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10160
|
+
/**
|
|
10161
|
+
* Generated image as Base64 string.
|
|
10162
|
+
*/
|
|
10163
|
+
image?: string;
|
|
10164
|
+
}
|
|
10165
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10166
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10167
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10168
|
+
}
|
|
10169
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10170
|
+
multipart: {
|
|
10171
|
+
body?: object;
|
|
10172
|
+
contentType?: string;
|
|
10173
|
+
};
|
|
10174
|
+
}
|
|
10175
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10176
|
+
/**
|
|
10177
|
+
* Generated image as Base64 string.
|
|
10178
|
+
*/
|
|
10179
|
+
image?: string;
|
|
10180
|
+
}
|
|
10181
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10182
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10183
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10184
|
+
}
|
|
10185
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10186
|
+
multipart: {
|
|
10187
|
+
body?: object;
|
|
10188
|
+
contentType?: string;
|
|
10189
|
+
};
|
|
10190
|
+
}
|
|
10191
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10192
|
+
/**
|
|
10193
|
+
* Generated image as Base64 string.
|
|
10194
|
+
*/
|
|
10195
|
+
image?: string;
|
|
10196
|
+
}
|
|
10197
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10198
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10199
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10200
|
+
}
|
|
10201
|
+
declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10202
|
+
inputs: ChatCompletionsInput;
|
|
10203
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10204
|
+
}
|
|
10205
|
+
declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10206
|
+
inputs: ChatCompletionsInput;
|
|
10207
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10208
|
+
}
|
|
10209
|
+
declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10210
|
+
inputs: ChatCompletionsInput;
|
|
10211
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10212
|
+
}
|
|
9378
10213
|
interface AiModels {
|
|
9379
10214
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9380
10215
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9393,7 +10228,6 @@ interface AiModels {
|
|
|
9393
10228
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9394
10229
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9395
10230
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9396
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9397
10231
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9398
10232
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9399
10233
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9460,6 +10294,12 @@ interface AiModels {
|
|
|
9460
10294
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9461
10295
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9462
10296
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10297
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10298
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10299
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10300
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10301
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10302
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9463
10303
|
}
|
|
9464
10304
|
type AiOptions = {
|
|
9465
10305
|
/**
|
|
@@ -9485,6 +10325,7 @@ type AiOptions = {
|
|
|
9485
10325
|
returnRawResponse?: boolean;
|
|
9486
10326
|
prefix?: string;
|
|
9487
10327
|
extraHeaders?: object;
|
|
10328
|
+
signal?: AbortSignal;
|
|
9488
10329
|
};
|
|
9489
10330
|
type AiModelsSearchParams = {
|
|
9490
10331
|
author?: string;
|
|
@@ -9511,6 +10352,16 @@ type AiModelsSearchObject = {
|
|
|
9511
10352
|
value: string;
|
|
9512
10353
|
}[];
|
|
9513
10354
|
};
|
|
10355
|
+
type ChatCompletionsBase = XOR<
|
|
10356
|
+
ChatCompletionsPromptInput,
|
|
10357
|
+
ChatCompletionsMessagesInput
|
|
10358
|
+
>;
|
|
10359
|
+
type ChatCompletionsInput = XOR<
|
|
10360
|
+
ChatCompletionsBase,
|
|
10361
|
+
{
|
|
10362
|
+
requests: ChatCompletionsBase[];
|
|
10363
|
+
}
|
|
10364
|
+
>;
|
|
9514
10365
|
interface InferenceUpstreamError extends Error {}
|
|
9515
10366
|
interface AiInternalError extends Error {}
|
|
9516
10367
|
type AiModelListType = Record<string, any>;
|
|
@@ -9518,46 +10369,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
9518
10369
|
aiGatewayLogId: string | null;
|
|
9519
10370
|
gateway(gatewayId: string): AiGateway;
|
|
9520
10371
|
/**
|
|
9521
|
-
*
|
|
9522
|
-
*
|
|
9523
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9524
|
-
* - Account-level operations: `list()`, `create()`
|
|
9525
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9526
|
-
*
|
|
9527
|
-
* @example
|
|
9528
|
-
* ```typescript
|
|
9529
|
-
* // List all AI Search instances
|
|
9530
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9531
|
-
*
|
|
9532
|
-
* // Search an instance
|
|
9533
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9534
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9535
|
-
* ai_search_options: {
|
|
9536
|
-
* retrieval: { max_num_results: 10 }
|
|
9537
|
-
* }
|
|
9538
|
-
* });
|
|
9539
|
-
*
|
|
9540
|
-
* // Generate chat completions with AI Search context
|
|
9541
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9542
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9543
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9544
|
-
* });
|
|
9545
|
-
* ```
|
|
10372
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10373
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9546
10374
|
*/
|
|
9547
|
-
aiSearch():
|
|
10375
|
+
aiSearch(): AiSearchNamespace;
|
|
9548
10376
|
/**
|
|
9549
10377
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9550
|
-
* Use `
|
|
9551
|
-
*
|
|
9552
|
-
* Migration guide:
|
|
9553
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9554
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9555
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10378
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10379
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9556
10380
|
*
|
|
9557
|
-
*
|
|
9558
|
-
*
|
|
9559
|
-
* @see AiSearchAccountService
|
|
9560
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10381
|
+
* @param autoragId Instance ID
|
|
9561
10382
|
*/
|
|
9562
10383
|
autorag(autoragId: string): AutoRAG;
|
|
9563
10384
|
run<
|
|
@@ -9716,22 +10537,23 @@ declare abstract class AiGateway {
|
|
|
9716
10537
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9717
10538
|
}
|
|
9718
10539
|
/**
|
|
9719
|
-
* @deprecated
|
|
9720
|
-
*
|
|
10540
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10541
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9721
10542
|
*/
|
|
9722
10543
|
interface AutoRAGInternalError extends Error {}
|
|
9723
10544
|
/**
|
|
9724
|
-
* @deprecated
|
|
9725
|
-
*
|
|
10545
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10546
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9726
10547
|
*/
|
|
9727
10548
|
interface AutoRAGNotFoundError extends Error {}
|
|
9728
10549
|
/**
|
|
9729
|
-
* @deprecated
|
|
10550
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10551
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9730
10552
|
*/
|
|
9731
10553
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
9732
10554
|
/**
|
|
9733
|
-
* @deprecated
|
|
9734
|
-
*
|
|
10555
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10556
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9735
10557
|
*/
|
|
9736
10558
|
interface AutoRAGNameNotSetError extends Error {}
|
|
9737
10559
|
type ComparisonFilter = {
|
|
@@ -9744,9 +10566,8 @@ type CompoundFilter = {
|
|
|
9744
10566
|
filters: ComparisonFilter[];
|
|
9745
10567
|
};
|
|
9746
10568
|
/**
|
|
9747
|
-
* @deprecated
|
|
9748
|
-
*
|
|
9749
|
-
* @see AiSearchSearchRequest
|
|
10569
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10570
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9750
10571
|
*/
|
|
9751
10572
|
type AutoRagSearchRequest = {
|
|
9752
10573
|
query: string;
|
|
@@ -9763,18 +10584,16 @@ type AutoRagSearchRequest = {
|
|
|
9763
10584
|
rewrite_query?: boolean;
|
|
9764
10585
|
};
|
|
9765
10586
|
/**
|
|
9766
|
-
* @deprecated
|
|
9767
|
-
*
|
|
9768
|
-
* @see AiSearchChatCompletionsRequest
|
|
10587
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10588
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9769
10589
|
*/
|
|
9770
10590
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9771
10591
|
stream?: boolean;
|
|
9772
10592
|
system_prompt?: string;
|
|
9773
10593
|
};
|
|
9774
10594
|
/**
|
|
9775
|
-
* @deprecated
|
|
9776
|
-
*
|
|
9777
|
-
* @see AiSearchChatCompletionsRequest
|
|
10595
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10596
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9778
10597
|
*/
|
|
9779
10598
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
9780
10599
|
AutoRagAiSearchRequest,
|
|
@@ -9783,9 +10602,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9783
10602
|
stream: true;
|
|
9784
10603
|
};
|
|
9785
10604
|
/**
|
|
9786
|
-
* @deprecated
|
|
9787
|
-
*
|
|
9788
|
-
* @see AiSearchSearchResponse
|
|
10605
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10606
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9789
10607
|
*/
|
|
9790
10608
|
type AutoRagSearchResponse = {
|
|
9791
10609
|
object: "vector_store.search_results.page";
|
|
@@ -9804,9 +10622,8 @@ type AutoRagSearchResponse = {
|
|
|
9804
10622
|
next_page: string | null;
|
|
9805
10623
|
};
|
|
9806
10624
|
/**
|
|
9807
|
-
* @deprecated
|
|
9808
|
-
*
|
|
9809
|
-
* @see AiSearchListResponse
|
|
10625
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10626
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9810
10627
|
*/
|
|
9811
10628
|
type AutoRagListResponse = {
|
|
9812
10629
|
id: string;
|
|
@@ -9818,49 +10635,40 @@ type AutoRagListResponse = {
|
|
|
9818
10635
|
status: string;
|
|
9819
10636
|
}[];
|
|
9820
10637
|
/**
|
|
9821
|
-
* @deprecated
|
|
9822
|
-
*
|
|
10638
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10639
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9823
10640
|
*/
|
|
9824
10641
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9825
10642
|
response: string;
|
|
9826
10643
|
};
|
|
9827
10644
|
/**
|
|
9828
|
-
* @deprecated
|
|
9829
|
-
*
|
|
9830
|
-
*
|
|
9831
|
-
* Migration guide:
|
|
9832
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9833
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9834
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9835
|
-
*
|
|
9836
|
-
* @see AiSearchAccountService
|
|
9837
|
-
* @see AiSearchInstanceService
|
|
10645
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10646
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9838
10647
|
*/
|
|
9839
10648
|
declare abstract class AutoRAG {
|
|
9840
10649
|
/**
|
|
9841
|
-
* @deprecated Use
|
|
9842
|
-
*
|
|
10650
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10651
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9843
10652
|
*/
|
|
9844
10653
|
list(): Promise<AutoRagListResponse>;
|
|
9845
10654
|
/**
|
|
9846
|
-
* @deprecated Use
|
|
9847
|
-
*
|
|
9848
|
-
* @see AiSearchInstanceService.search
|
|
10655
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10656
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9849
10657
|
*/
|
|
9850
10658
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9851
10659
|
/**
|
|
9852
|
-
* @deprecated Use
|
|
9853
|
-
*
|
|
10660
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10661
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9854
10662
|
*/
|
|
9855
10663
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9856
10664
|
/**
|
|
9857
|
-
* @deprecated Use
|
|
9858
|
-
*
|
|
10665
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10666
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9859
10667
|
*/
|
|
9860
10668
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9861
10669
|
/**
|
|
9862
|
-
* @deprecated Use
|
|
9863
|
-
*
|
|
10670
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10671
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9864
10672
|
*/
|
|
9865
10673
|
aiSearch(
|
|
9866
10674
|
params: AutoRagAiSearchRequest,
|
|
@@ -9985,6 +10793,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
9985
10793
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
9986
10794
|
*/
|
|
9987
10795
|
cacheTtlByStatus?: Record<string, number>;
|
|
10796
|
+
/**
|
|
10797
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10798
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10799
|
+
*
|
|
10800
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10801
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10802
|
+
*
|
|
10803
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10804
|
+
*/
|
|
10805
|
+
cacheControl?: string;
|
|
10806
|
+
/**
|
|
10807
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10808
|
+
*/
|
|
10809
|
+
cacheReserveEligible?: boolean;
|
|
10810
|
+
/**
|
|
10811
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10812
|
+
*/
|
|
10813
|
+
respectStrongEtag?: boolean;
|
|
10814
|
+
/**
|
|
10815
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10816
|
+
*/
|
|
10817
|
+
stripEtags?: boolean;
|
|
10818
|
+
/**
|
|
10819
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10820
|
+
*/
|
|
10821
|
+
stripLastModified?: boolean;
|
|
10822
|
+
/**
|
|
10823
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10824
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10825
|
+
*/
|
|
10826
|
+
cacheDeceptionArmor?: boolean;
|
|
10827
|
+
/**
|
|
10828
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10829
|
+
*/
|
|
10830
|
+
cacheReserveMinimumFileSize?: number;
|
|
9988
10831
|
scrapeShield?: boolean;
|
|
9989
10832
|
apps?: boolean;
|
|
9990
10833
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11897,6 +12740,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11897
12740
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11898
12741
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11899
12742
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12743
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11900
12744
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11901
12745
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11902
12746
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11917,6 +12761,7 @@ declare namespace CloudflareWorkersModule {
|
|
|
11917
12761
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11918
12762
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11919
12763
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12764
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11920
12765
|
webSocketMessage?(
|
|
11921
12766
|
ws: WebSocket,
|
|
11922
12767
|
message: string | ArrayBuffer,
|
|
@@ -12067,17 +12912,6 @@ interface StreamBinding {
|
|
|
12067
12912
|
* @returns A handle for per-video operations.
|
|
12068
12913
|
*/
|
|
12069
12914
|
video(id: string): StreamVideoHandle;
|
|
12070
|
-
/**
|
|
12071
|
-
* Uploads a new video from a File.
|
|
12072
|
-
* @param file The video file to upload.
|
|
12073
|
-
* @returns The uploaded video details.
|
|
12074
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12075
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12076
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12077
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12078
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12079
|
-
*/
|
|
12080
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12081
12915
|
/**
|
|
12082
12916
|
* Uploads a new video from a provided URL.
|
|
12083
12917
|
* @param url The URL to upload from.
|
|
@@ -12927,6 +13761,9 @@ declare namespace TailStream {
|
|
|
12927
13761
|
readonly type: "fetch";
|
|
12928
13762
|
readonly statusCode: number;
|
|
12929
13763
|
}
|
|
13764
|
+
interface ConnectEventInfo {
|
|
13765
|
+
readonly type: "connect";
|
|
13766
|
+
}
|
|
12930
13767
|
type EventOutcome =
|
|
12931
13768
|
| "ok"
|
|
12932
13769
|
| "canceled"
|
|
@@ -12957,6 +13794,7 @@ declare namespace TailStream {
|
|
|
12957
13794
|
readonly scriptVersion?: ScriptVersion;
|
|
12958
13795
|
readonly info:
|
|
12959
13796
|
| FetchEventInfo
|
|
13797
|
+
| ConnectEventInfo
|
|
12960
13798
|
| JsRpcEventInfo
|
|
12961
13799
|
| ScheduledEventInfo
|
|
12962
13800
|
| AlarmEventInfo
|