@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/2023-07-01/index.ts
CHANGED
|
@@ -488,6 +488,11 @@ export type ExportedHandlerFetchHandler<
|
|
|
488
488
|
env: Env,
|
|
489
489
|
ctx: ExecutionContext<Props>,
|
|
490
490
|
) => Response | Promise<Response>;
|
|
491
|
+
export type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
|
|
492
|
+
socket: Socket,
|
|
493
|
+
env: Env,
|
|
494
|
+
ctx: ExecutionContext<Props>,
|
|
495
|
+
) => void | Promise<void>;
|
|
491
496
|
export type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
|
|
492
497
|
events: TraceItem[],
|
|
493
498
|
env: Env,
|
|
@@ -529,6 +534,7 @@ export interface ExportedHandler<
|
|
|
529
534
|
Props = unknown,
|
|
530
535
|
> {
|
|
531
536
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
|
|
537
|
+
connect?: ExportedHandlerConnectHandler<Env, Props>;
|
|
532
538
|
tail?: ExportedHandlerTailHandler<Env, Props>;
|
|
533
539
|
trace?: ExportedHandlerTraceHandler<Env, Props>;
|
|
534
540
|
tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
|
|
@@ -548,12 +554,14 @@ export declare abstract class Navigator {
|
|
|
548
554
|
export interface AlarmInvocationInfo {
|
|
549
555
|
readonly isRetry: boolean;
|
|
550
556
|
readonly retryCount: number;
|
|
557
|
+
readonly scheduledTime: number;
|
|
551
558
|
}
|
|
552
559
|
export interface Cloudflare {
|
|
553
560
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
554
561
|
}
|
|
555
562
|
export interface DurableObject {
|
|
556
563
|
fetch(request: Request): Response | Promise<Response>;
|
|
564
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
557
565
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
558
566
|
webSocketMessage?(
|
|
559
567
|
ws: WebSocket,
|
|
@@ -571,7 +579,7 @@ export type DurableObjectStub<
|
|
|
571
579
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
572
580
|
> = Fetcher<
|
|
573
581
|
T,
|
|
574
|
-
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
582
|
+
"alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
575
583
|
> & {
|
|
576
584
|
readonly id: DurableObjectId;
|
|
577
585
|
readonly name?: string;
|
|
@@ -580,6 +588,7 @@ export interface DurableObjectId {
|
|
|
580
588
|
toString(): string;
|
|
581
589
|
equals(other: DurableObjectId): boolean;
|
|
582
590
|
readonly name?: string;
|
|
591
|
+
readonly jurisdiction?: string;
|
|
583
592
|
}
|
|
584
593
|
export declare abstract class DurableObjectNamespace<
|
|
585
594
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
@@ -3100,6 +3109,11 @@ export interface QueuingStrategyInit {
|
|
|
3100
3109
|
*/
|
|
3101
3110
|
highWaterMark: number;
|
|
3102
3111
|
}
|
|
3112
|
+
export interface TracePreviewInfo {
|
|
3113
|
+
id: string;
|
|
3114
|
+
slug: string;
|
|
3115
|
+
name: string;
|
|
3116
|
+
}
|
|
3103
3117
|
export interface ScriptVersion {
|
|
3104
3118
|
id?: string;
|
|
3105
3119
|
tag?: string;
|
|
@@ -3114,6 +3128,7 @@ export interface TraceItem {
|
|
|
3114
3128
|
| (
|
|
3115
3129
|
| TraceItemFetchEventInfo
|
|
3116
3130
|
| TraceItemJsRpcEventInfo
|
|
3131
|
+
| TraceItemConnectEventInfo
|
|
3117
3132
|
| TraceItemScheduledEventInfo
|
|
3118
3133
|
| TraceItemAlarmEventInfo
|
|
3119
3134
|
| TraceItemQueueEventInfo
|
|
@@ -3132,6 +3147,8 @@ export interface TraceItem {
|
|
|
3132
3147
|
readonly scriptVersion?: ScriptVersion;
|
|
3133
3148
|
readonly dispatchNamespace?: string;
|
|
3134
3149
|
readonly scriptTags?: string[];
|
|
3150
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3151
|
+
readonly preview?: TracePreviewInfo;
|
|
3135
3152
|
readonly durableObjectId?: string;
|
|
3136
3153
|
readonly outcome: string;
|
|
3137
3154
|
readonly executionModel: string;
|
|
@@ -3142,6 +3159,7 @@ export interface TraceItem {
|
|
|
3142
3159
|
export interface TraceItemAlarmEventInfo {
|
|
3143
3160
|
readonly scheduledTime: Date;
|
|
3144
3161
|
}
|
|
3162
|
+
export interface TraceItemConnectEventInfo {}
|
|
3145
3163
|
export interface TraceItemCustomEventInfo {}
|
|
3146
3164
|
export interface TraceItemScheduledEventInfo {
|
|
3147
3165
|
readonly scheduledTime: number;
|
|
@@ -3762,7 +3780,7 @@ export interface ContainerStartupOptions {
|
|
|
3762
3780
|
entrypoint?: string[];
|
|
3763
3781
|
enableInternet: boolean;
|
|
3764
3782
|
env?: Record<string, string>;
|
|
3765
|
-
|
|
3783
|
+
labels?: Record<string, string>;
|
|
3766
3784
|
}
|
|
3767
3785
|
/**
|
|
3768
3786
|
* 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.
|
|
@@ -3889,11 +3907,10 @@ export declare abstract class Performance {
|
|
|
3889
3907
|
*/
|
|
3890
3908
|
toJSON(): object;
|
|
3891
3909
|
}
|
|
3892
|
-
// AI Search
|
|
3910
|
+
// ============ AI Search Error Interfaces ============
|
|
3893
3911
|
export interface AiSearchInternalError extends Error {}
|
|
3894
3912
|
export interface AiSearchNotFoundError extends Error {}
|
|
3895
|
-
|
|
3896
|
-
// AI Search V2 Request Types
|
|
3913
|
+
// ============ AI Search Request Types ============
|
|
3897
3914
|
export type AiSearchSearchRequest = {
|
|
3898
3915
|
messages: Array<{
|
|
3899
3916
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3918,9 +3935,8 @@ export type AiSearchSearchRequest = {
|
|
|
3918
3935
|
[key: string]: unknown;
|
|
3919
3936
|
};
|
|
3920
3937
|
reranking?: {
|
|
3921
|
-
/** Enable reranking (default false) */
|
|
3922
3938
|
enabled?: boolean;
|
|
3923
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3939
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3924
3940
|
/** Match threshold (0-1, default 0.4) */
|
|
3925
3941
|
match_threshold?: number;
|
|
3926
3942
|
[key: string]: unknown;
|
|
@@ -3932,6 +3948,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3932
3948
|
messages: Array<{
|
|
3933
3949
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3934
3950
|
content: string | null;
|
|
3951
|
+
[key: string]: unknown;
|
|
3935
3952
|
}>;
|
|
3936
3953
|
model?: string;
|
|
3937
3954
|
stream?: boolean;
|
|
@@ -3952,7 +3969,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3952
3969
|
};
|
|
3953
3970
|
reranking?: {
|
|
3954
3971
|
enabled?: boolean;
|
|
3955
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3972
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3956
3973
|
match_threshold?: number;
|
|
3957
3974
|
[key: string]: unknown;
|
|
3958
3975
|
};
|
|
@@ -3960,7 +3977,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3960
3977
|
};
|
|
3961
3978
|
[key: string]: unknown;
|
|
3962
3979
|
};
|
|
3963
|
-
// AI Search
|
|
3980
|
+
// ============ AI Search Response Types ============
|
|
3964
3981
|
export type AiSearchSearchResponse = {
|
|
3965
3982
|
search_query: string;
|
|
3966
3983
|
chunks: Array<{
|
|
@@ -3979,26 +3996,65 @@ export type AiSearchSearchResponse = {
|
|
|
3979
3996
|
keyword_score?: number;
|
|
3980
3997
|
/** Vector similarity score (0-1) */
|
|
3981
3998
|
vector_score?: number;
|
|
3999
|
+
[key: string]: unknown;
|
|
4000
|
+
};
|
|
4001
|
+
}>;
|
|
4002
|
+
};
|
|
4003
|
+
export type AiSearchChatCompletionsResponse = {
|
|
4004
|
+
id?: string;
|
|
4005
|
+
object?: string;
|
|
4006
|
+
model?: string;
|
|
4007
|
+
choices: Array<{
|
|
4008
|
+
index?: number;
|
|
4009
|
+
message: {
|
|
4010
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4011
|
+
content: string | null;
|
|
4012
|
+
[key: string]: unknown;
|
|
3982
4013
|
};
|
|
4014
|
+
[key: string]: unknown;
|
|
3983
4015
|
}>;
|
|
4016
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4017
|
+
[key: string]: unknown;
|
|
3984
4018
|
};
|
|
3985
|
-
export type
|
|
4019
|
+
export type AiSearchStatsResponse = {
|
|
4020
|
+
queued?: number;
|
|
4021
|
+
running?: number;
|
|
4022
|
+
completed?: number;
|
|
4023
|
+
error?: number;
|
|
4024
|
+
skipped?: number;
|
|
4025
|
+
outdated?: number;
|
|
4026
|
+
last_activity?: string;
|
|
4027
|
+
};
|
|
4028
|
+
// ============ AI Search Instance Info Types ============
|
|
4029
|
+
export type AiSearchInstanceInfo = {
|
|
3986
4030
|
id: string;
|
|
3987
|
-
|
|
3988
|
-
account_id?: string;
|
|
3989
|
-
account_tag?: string;
|
|
3990
|
-
/** Whether the instance is enabled (default true) */
|
|
3991
|
-
enable?: boolean;
|
|
3992
|
-
type?: "r2" | "web-crawler";
|
|
4031
|
+
type?: "r2" | "web-crawler" | string;
|
|
3993
4032
|
source?: string;
|
|
4033
|
+
paused?: boolean;
|
|
4034
|
+
status?: string;
|
|
4035
|
+
namespace?: string;
|
|
4036
|
+
created_at?: string;
|
|
4037
|
+
modified_at?: string;
|
|
3994
4038
|
[key: string]: unknown;
|
|
3995
|
-
}
|
|
4039
|
+
};
|
|
4040
|
+
export type AiSearchListResponse = {
|
|
4041
|
+
result: AiSearchInstanceInfo[];
|
|
4042
|
+
result_info?: {
|
|
4043
|
+
count: number;
|
|
4044
|
+
page: number;
|
|
4045
|
+
per_page: number;
|
|
4046
|
+
total_count: number;
|
|
4047
|
+
};
|
|
4048
|
+
};
|
|
4049
|
+
// ============ AI Search Config Types ============
|
|
3996
4050
|
export type AiSearchConfig = {
|
|
3997
4051
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3998
4052
|
id: string;
|
|
3999
|
-
type
|
|
4000
|
-
|
|
4001
|
-
|
|
4053
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4054
|
+
type?: "r2" | "web-crawler" | string;
|
|
4055
|
+
/** Source URL (required for web-crawler type). */
|
|
4056
|
+
source?: string;
|
|
4057
|
+
source_params?: unknown;
|
|
4002
4058
|
/** Token ID (UUID format) */
|
|
4003
4059
|
token_id?: string;
|
|
4004
4060
|
ai_gateway_id?: string;
|
|
@@ -4008,54 +4064,307 @@ export type AiSearchConfig = {
|
|
|
4008
4064
|
reranking?: boolean;
|
|
4009
4065
|
embedding_model?: string;
|
|
4010
4066
|
ai_search_model?: string;
|
|
4067
|
+
[key: string]: unknown;
|
|
4011
4068
|
};
|
|
4012
|
-
|
|
4069
|
+
// ============ AI Search Item Types ============
|
|
4070
|
+
export type AiSearchItemInfo = {
|
|
4013
4071
|
id: string;
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4072
|
+
key: string;
|
|
4073
|
+
status:
|
|
4074
|
+
| "completed"
|
|
4075
|
+
| "error"
|
|
4076
|
+
| "skipped"
|
|
4077
|
+
| "queued"
|
|
4078
|
+
| "processing"
|
|
4079
|
+
| "outdated";
|
|
4080
|
+
metadata?: Record<string, unknown>;
|
|
4017
4081
|
[key: string]: unknown;
|
|
4018
4082
|
};
|
|
4019
|
-
|
|
4020
|
-
|
|
4083
|
+
export type AiSearchItemContentResult = {
|
|
4084
|
+
body: ReadableStream;
|
|
4085
|
+
contentType: string;
|
|
4086
|
+
filename: string;
|
|
4087
|
+
size: number;
|
|
4088
|
+
};
|
|
4089
|
+
export type AiSearchUploadItemOptions = {
|
|
4090
|
+
metadata?: Record<string, unknown>;
|
|
4091
|
+
};
|
|
4092
|
+
export type AiSearchListItemsParams = {
|
|
4093
|
+
page?: number;
|
|
4094
|
+
per_page?: number;
|
|
4095
|
+
};
|
|
4096
|
+
export type AiSearchListItemsResponse = {
|
|
4097
|
+
result: AiSearchItemInfo[];
|
|
4098
|
+
result_info?: {
|
|
4099
|
+
count: number;
|
|
4100
|
+
page: number;
|
|
4101
|
+
per_page: number;
|
|
4102
|
+
total_count: number;
|
|
4103
|
+
};
|
|
4104
|
+
};
|
|
4105
|
+
// ============ AI Search Job Types ============
|
|
4106
|
+
export type AiSearchJobInfo = {
|
|
4107
|
+
id: string;
|
|
4108
|
+
source: "user" | "schedule";
|
|
4109
|
+
description?: string;
|
|
4110
|
+
last_seen_at?: string;
|
|
4111
|
+
started_at?: string;
|
|
4112
|
+
ended_at?: string;
|
|
4113
|
+
end_reason?: string;
|
|
4114
|
+
};
|
|
4115
|
+
export type AiSearchJobLog = {
|
|
4116
|
+
id: number;
|
|
4117
|
+
message: string;
|
|
4118
|
+
message_type: number;
|
|
4119
|
+
created_at: number;
|
|
4120
|
+
};
|
|
4121
|
+
export type AiSearchCreateJobParams = {
|
|
4122
|
+
description?: string;
|
|
4123
|
+
};
|
|
4124
|
+
export type AiSearchListJobsParams = {
|
|
4125
|
+
page?: number;
|
|
4126
|
+
per_page?: number;
|
|
4127
|
+
};
|
|
4128
|
+
export type AiSearchListJobsResponse = {
|
|
4129
|
+
result: AiSearchJobInfo[];
|
|
4130
|
+
result_info?: {
|
|
4131
|
+
count: number;
|
|
4132
|
+
page: number;
|
|
4133
|
+
per_page: number;
|
|
4134
|
+
total_count: number;
|
|
4135
|
+
};
|
|
4136
|
+
};
|
|
4137
|
+
export type AiSearchJobLogsParams = {
|
|
4138
|
+
page?: number;
|
|
4139
|
+
per_page?: number;
|
|
4140
|
+
};
|
|
4141
|
+
export type AiSearchJobLogsResponse = {
|
|
4142
|
+
result: AiSearchJobLog[];
|
|
4143
|
+
result_info?: {
|
|
4144
|
+
count: number;
|
|
4145
|
+
page: number;
|
|
4146
|
+
per_page: number;
|
|
4147
|
+
total_count: number;
|
|
4148
|
+
};
|
|
4149
|
+
};
|
|
4150
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4151
|
+
/**
|
|
4152
|
+
* Single item service for an AI Search instance.
|
|
4153
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4154
|
+
*/
|
|
4155
|
+
export declare abstract class AiSearchItem {
|
|
4156
|
+
/** Get metadata about this item. */
|
|
4157
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4158
|
+
/**
|
|
4159
|
+
* Download the item's content.
|
|
4160
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4161
|
+
*/
|
|
4162
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4163
|
+
}
|
|
4164
|
+
/**
|
|
4165
|
+
* Items collection service for an AI Search instance.
|
|
4166
|
+
* Provides list, upload, and access to individual items.
|
|
4167
|
+
*/
|
|
4168
|
+
export declare abstract class AiSearchItems {
|
|
4169
|
+
/** List items in this instance. */
|
|
4170
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4171
|
+
/**
|
|
4172
|
+
* Upload a file as an item.
|
|
4173
|
+
* @param name Filename for the uploaded item.
|
|
4174
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4175
|
+
* @param options Optional metadata to attach to the item.
|
|
4176
|
+
* @returns The created item info.
|
|
4177
|
+
*/
|
|
4178
|
+
upload(
|
|
4179
|
+
name: string,
|
|
4180
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4181
|
+
options?: AiSearchUploadItemOptions,
|
|
4182
|
+
): Promise<AiSearchItemInfo>;
|
|
4183
|
+
/**
|
|
4184
|
+
* Upload a file and poll until processing completes.
|
|
4185
|
+
* @param name Filename for the uploaded item.
|
|
4186
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4187
|
+
* @param options Optional metadata to attach to the item.
|
|
4188
|
+
* @returns The item info after processing completes (or timeout).
|
|
4189
|
+
*/
|
|
4190
|
+
uploadAndPoll(
|
|
4191
|
+
name: string,
|
|
4192
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4193
|
+
options?: AiSearchUploadItemOptions,
|
|
4194
|
+
): Promise<AiSearchItemInfo>;
|
|
4195
|
+
/**
|
|
4196
|
+
* Get an item by ID.
|
|
4197
|
+
* @param itemId The item identifier.
|
|
4198
|
+
* @returns Item service for info, delete, and download operations.
|
|
4199
|
+
*/
|
|
4200
|
+
get(itemId: string): AiSearchItem;
|
|
4201
|
+
/** Delete this item from the instance.
|
|
4202
|
+
* @param itemId The item identifier.
|
|
4203
|
+
*/
|
|
4204
|
+
delete(itemId: string): Promise<void>;
|
|
4205
|
+
}
|
|
4206
|
+
/**
|
|
4207
|
+
* Single job service for an AI Search instance.
|
|
4208
|
+
* Provides info and logs for a specific job.
|
|
4209
|
+
*/
|
|
4210
|
+
export declare abstract class AiSearchJob {
|
|
4211
|
+
/** Get metadata about this job. */
|
|
4212
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4213
|
+
/** Get logs for this job. */
|
|
4214
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4215
|
+
}
|
|
4216
|
+
/**
|
|
4217
|
+
* Jobs collection service for an AI Search instance.
|
|
4218
|
+
* Provides list, create, and access to individual jobs.
|
|
4219
|
+
*/
|
|
4220
|
+
export declare abstract class AiSearchJobs {
|
|
4221
|
+
/** List jobs for this instance. */
|
|
4222
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4223
|
+
/**
|
|
4224
|
+
* Create a new indexing job.
|
|
4225
|
+
* @param params Optional job parameters.
|
|
4226
|
+
* @returns The created job info.
|
|
4227
|
+
*/
|
|
4228
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4229
|
+
/**
|
|
4230
|
+
* Get a job by ID.
|
|
4231
|
+
* @param jobId The job identifier.
|
|
4232
|
+
* @returns Job service for info and logs operations.
|
|
4233
|
+
*/
|
|
4234
|
+
get(jobId: string): AiSearchJob;
|
|
4235
|
+
}
|
|
4236
|
+
// ============ AI Search Binding Classes ============
|
|
4237
|
+
/**
|
|
4238
|
+
* Instance-level AI Search service.
|
|
4239
|
+
*
|
|
4240
|
+
* Used as:
|
|
4241
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4242
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4243
|
+
*
|
|
4244
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4245
|
+
*
|
|
4246
|
+
* @example
|
|
4247
|
+
* ```ts
|
|
4248
|
+
* // Via namespace binding
|
|
4249
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4250
|
+
* const results = await instance.search({
|
|
4251
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4252
|
+
* });
|
|
4253
|
+
*
|
|
4254
|
+
* // Via single instance binding
|
|
4255
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4256
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4257
|
+
* });
|
|
4258
|
+
* ```
|
|
4259
|
+
*/
|
|
4260
|
+
export declare abstract class AiSearchInstance {
|
|
4021
4261
|
/**
|
|
4022
4262
|
* Search the AI Search instance for relevant chunks.
|
|
4023
|
-
* @param params Search request with messages and AI search options
|
|
4024
|
-
* @returns Search response with matching chunks
|
|
4263
|
+
* @param params Search request with messages and optional AI search options.
|
|
4264
|
+
* @returns Search response with matching chunks and search query.
|
|
4025
4265
|
*/
|
|
4026
4266
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4267
|
+
/**
|
|
4268
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4269
|
+
* @param params Chat completions request with stream: true.
|
|
4270
|
+
* @returns ReadableStream of server-sent events.
|
|
4271
|
+
*/
|
|
4272
|
+
chatCompletions(
|
|
4273
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4274
|
+
stream: true;
|
|
4275
|
+
},
|
|
4276
|
+
): Promise<ReadableStream>;
|
|
4027
4277
|
/**
|
|
4028
4278
|
* Generate chat completions with AI Search context.
|
|
4029
|
-
* @param params Chat completions request
|
|
4030
|
-
* @returns
|
|
4279
|
+
* @param params Chat completions request.
|
|
4280
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4031
4281
|
*/
|
|
4032
4282
|
chatCompletions(
|
|
4033
4283
|
params: AiSearchChatCompletionsRequest,
|
|
4034
|
-
): Promise<
|
|
4284
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4035
4285
|
/**
|
|
4036
|
-
*
|
|
4286
|
+
* Update the instance configuration.
|
|
4287
|
+
* @param config Partial configuration to update.
|
|
4288
|
+
* @returns Updated instance info.
|
|
4037
4289
|
*/
|
|
4038
|
-
|
|
4290
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4291
|
+
/** Get metadata about this instance. */
|
|
4292
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4293
|
+
/**
|
|
4294
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4295
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4296
|
+
*/
|
|
4297
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4298
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4299
|
+
get items(): AiSearchItems;
|
|
4300
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4301
|
+
get jobs(): AiSearchJobs;
|
|
4039
4302
|
}
|
|
4040
|
-
|
|
4041
|
-
|
|
4303
|
+
/**
|
|
4304
|
+
* Namespace-level AI Search service.
|
|
4305
|
+
*
|
|
4306
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4307
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4308
|
+
*
|
|
4309
|
+
* @example
|
|
4310
|
+
* ```ts
|
|
4311
|
+
* // Access an instance within the namespace
|
|
4312
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4313
|
+
* const results = await blog.search({
|
|
4314
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4315
|
+
* });
|
|
4316
|
+
*
|
|
4317
|
+
* // List all instances in the namespace
|
|
4318
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4319
|
+
*
|
|
4320
|
+
* // Create a new instance with built-in storage
|
|
4321
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4322
|
+
* id: "tenant-123",
|
|
4323
|
+
* });
|
|
4324
|
+
*
|
|
4325
|
+
* // Upload items into the instance
|
|
4326
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4327
|
+
*
|
|
4328
|
+
* // Delete an instance
|
|
4329
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4330
|
+
* ```
|
|
4331
|
+
*/
|
|
4332
|
+
export declare abstract class AiSearchNamespace {
|
|
4042
4333
|
/**
|
|
4043
|
-
*
|
|
4044
|
-
* @
|
|
4334
|
+
* Get an instance by name within the bound namespace.
|
|
4335
|
+
* @param name Instance name.
|
|
4336
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4337
|
+
*/
|
|
4338
|
+
get(name: string): AiSearchInstance;
|
|
4339
|
+
/**
|
|
4340
|
+
* List all instances in the bound namespace.
|
|
4341
|
+
* @returns Array of instance metadata.
|
|
4045
4342
|
*/
|
|
4046
4343
|
list(): Promise<AiSearchListResponse>;
|
|
4047
4344
|
/**
|
|
4048
|
-
*
|
|
4049
|
-
* @param
|
|
4050
|
-
* @returns Instance service for
|
|
4345
|
+
* Create a new instance within the bound namespace.
|
|
4346
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4347
|
+
* @returns Instance service for the newly created instance.
|
|
4348
|
+
*
|
|
4349
|
+
* @example
|
|
4350
|
+
* ```ts
|
|
4351
|
+
* // Create with built-in storage (upload items manually)
|
|
4352
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4353
|
+
*
|
|
4354
|
+
* // Create with web crawler source
|
|
4355
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4356
|
+
* id: "docs-search",
|
|
4357
|
+
* type: "web-crawler",
|
|
4358
|
+
* source: "https://developers.cloudflare.com",
|
|
4359
|
+
* });
|
|
4360
|
+
* ```
|
|
4051
4361
|
*/
|
|
4052
|
-
|
|
4362
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4053
4363
|
/**
|
|
4054
|
-
*
|
|
4055
|
-
* @param
|
|
4056
|
-
* @returns Instance service for performing operations
|
|
4364
|
+
* Delete an instance from the bound namespace.
|
|
4365
|
+
* @param name Instance name to delete.
|
|
4057
4366
|
*/
|
|
4058
|
-
|
|
4367
|
+
delete(name: string): Promise<void>;
|
|
4059
4368
|
}
|
|
4060
4369
|
export type AiImageClassificationInput = {
|
|
4061
4370
|
image: number[];
|
|
@@ -4331,6 +4640,402 @@ export declare abstract class BaseAiTranslation {
|
|
|
4331
4640
|
inputs: AiTranslationInput;
|
|
4332
4641
|
postProcessedOutputs: AiTranslationOutput;
|
|
4333
4642
|
}
|
|
4643
|
+
/**
|
|
4644
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4645
|
+
*/
|
|
4646
|
+
export type ChatCompletionContentPartText = {
|
|
4647
|
+
type: "text";
|
|
4648
|
+
text: string;
|
|
4649
|
+
};
|
|
4650
|
+
export type ChatCompletionContentPartImage = {
|
|
4651
|
+
type: "image_url";
|
|
4652
|
+
image_url: {
|
|
4653
|
+
url: string;
|
|
4654
|
+
detail?: "auto" | "low" | "high";
|
|
4655
|
+
};
|
|
4656
|
+
};
|
|
4657
|
+
export type ChatCompletionContentPartInputAudio = {
|
|
4658
|
+
type: "input_audio";
|
|
4659
|
+
input_audio: {
|
|
4660
|
+
/** Base64 encoded audio data. */
|
|
4661
|
+
data: string;
|
|
4662
|
+
format: "wav" | "mp3";
|
|
4663
|
+
};
|
|
4664
|
+
};
|
|
4665
|
+
export type ChatCompletionContentPartFile = {
|
|
4666
|
+
type: "file";
|
|
4667
|
+
file: {
|
|
4668
|
+
/** Base64 encoded file data. */
|
|
4669
|
+
file_data?: string;
|
|
4670
|
+
/** The ID of an uploaded file. */
|
|
4671
|
+
file_id?: string;
|
|
4672
|
+
filename?: string;
|
|
4673
|
+
};
|
|
4674
|
+
};
|
|
4675
|
+
export type ChatCompletionContentPartRefusal = {
|
|
4676
|
+
type: "refusal";
|
|
4677
|
+
refusal: string;
|
|
4678
|
+
};
|
|
4679
|
+
export type ChatCompletionContentPart =
|
|
4680
|
+
| ChatCompletionContentPartText
|
|
4681
|
+
| ChatCompletionContentPartImage
|
|
4682
|
+
| ChatCompletionContentPartInputAudio
|
|
4683
|
+
| ChatCompletionContentPartFile;
|
|
4684
|
+
export type FunctionDefinition = {
|
|
4685
|
+
name: string;
|
|
4686
|
+
description?: string;
|
|
4687
|
+
parameters?: Record<string, unknown>;
|
|
4688
|
+
strict?: boolean | null;
|
|
4689
|
+
};
|
|
4690
|
+
export type ChatCompletionFunctionTool = {
|
|
4691
|
+
type: "function";
|
|
4692
|
+
function: FunctionDefinition;
|
|
4693
|
+
};
|
|
4694
|
+
export type ChatCompletionCustomToolGrammarFormat = {
|
|
4695
|
+
type: "grammar";
|
|
4696
|
+
grammar: {
|
|
4697
|
+
definition: string;
|
|
4698
|
+
syntax: "lark" | "regex";
|
|
4699
|
+
};
|
|
4700
|
+
};
|
|
4701
|
+
export type ChatCompletionCustomToolTextFormat = {
|
|
4702
|
+
type: "text";
|
|
4703
|
+
};
|
|
4704
|
+
export type ChatCompletionCustomToolFormat =
|
|
4705
|
+
| ChatCompletionCustomToolTextFormat
|
|
4706
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4707
|
+
export type ChatCompletionCustomTool = {
|
|
4708
|
+
type: "custom";
|
|
4709
|
+
custom: {
|
|
4710
|
+
name: string;
|
|
4711
|
+
description?: string;
|
|
4712
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4713
|
+
};
|
|
4714
|
+
};
|
|
4715
|
+
export type ChatCompletionTool =
|
|
4716
|
+
| ChatCompletionFunctionTool
|
|
4717
|
+
| ChatCompletionCustomTool;
|
|
4718
|
+
export type ChatCompletionMessageFunctionToolCall = {
|
|
4719
|
+
id: string;
|
|
4720
|
+
type: "function";
|
|
4721
|
+
function: {
|
|
4722
|
+
name: string;
|
|
4723
|
+
/** JSON-encoded arguments string. */
|
|
4724
|
+
arguments: string;
|
|
4725
|
+
};
|
|
4726
|
+
};
|
|
4727
|
+
export type ChatCompletionMessageCustomToolCall = {
|
|
4728
|
+
id: string;
|
|
4729
|
+
type: "custom";
|
|
4730
|
+
custom: {
|
|
4731
|
+
name: string;
|
|
4732
|
+
input: string;
|
|
4733
|
+
};
|
|
4734
|
+
};
|
|
4735
|
+
export type ChatCompletionMessageToolCall =
|
|
4736
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4737
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4738
|
+
export type ChatCompletionToolChoiceFunction = {
|
|
4739
|
+
type: "function";
|
|
4740
|
+
function: {
|
|
4741
|
+
name: string;
|
|
4742
|
+
};
|
|
4743
|
+
};
|
|
4744
|
+
export type ChatCompletionToolChoiceCustom = {
|
|
4745
|
+
type: "custom";
|
|
4746
|
+
custom: {
|
|
4747
|
+
name: string;
|
|
4748
|
+
};
|
|
4749
|
+
};
|
|
4750
|
+
export type ChatCompletionToolChoiceAllowedTools = {
|
|
4751
|
+
type: "allowed_tools";
|
|
4752
|
+
allowed_tools: {
|
|
4753
|
+
mode: "auto" | "required";
|
|
4754
|
+
tools: Array<Record<string, unknown>>;
|
|
4755
|
+
};
|
|
4756
|
+
};
|
|
4757
|
+
export type ChatCompletionToolChoiceOption =
|
|
4758
|
+
| "none"
|
|
4759
|
+
| "auto"
|
|
4760
|
+
| "required"
|
|
4761
|
+
| ChatCompletionToolChoiceFunction
|
|
4762
|
+
| ChatCompletionToolChoiceCustom
|
|
4763
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4764
|
+
export type DeveloperMessage = {
|
|
4765
|
+
role: "developer";
|
|
4766
|
+
content:
|
|
4767
|
+
| string
|
|
4768
|
+
| Array<{
|
|
4769
|
+
type: "text";
|
|
4770
|
+
text: string;
|
|
4771
|
+
}>;
|
|
4772
|
+
name?: string;
|
|
4773
|
+
};
|
|
4774
|
+
export type SystemMessage = {
|
|
4775
|
+
role: "system";
|
|
4776
|
+
content:
|
|
4777
|
+
| string
|
|
4778
|
+
| Array<{
|
|
4779
|
+
type: "text";
|
|
4780
|
+
text: string;
|
|
4781
|
+
}>;
|
|
4782
|
+
name?: string;
|
|
4783
|
+
};
|
|
4784
|
+
/**
|
|
4785
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4786
|
+
*
|
|
4787
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4788
|
+
* inside nested array items does not correctly match different branches for
|
|
4789
|
+
* different array elements, so the schema uses a single merged object.
|
|
4790
|
+
*/
|
|
4791
|
+
export type UserMessageContentPart = {
|
|
4792
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4793
|
+
text?: string;
|
|
4794
|
+
image_url?: {
|
|
4795
|
+
url?: string;
|
|
4796
|
+
detail?: "auto" | "low" | "high";
|
|
4797
|
+
};
|
|
4798
|
+
input_audio?: {
|
|
4799
|
+
data?: string;
|
|
4800
|
+
format?: "wav" | "mp3";
|
|
4801
|
+
};
|
|
4802
|
+
file?: {
|
|
4803
|
+
file_data?: string;
|
|
4804
|
+
file_id?: string;
|
|
4805
|
+
filename?: string;
|
|
4806
|
+
};
|
|
4807
|
+
};
|
|
4808
|
+
export type UserMessage = {
|
|
4809
|
+
role: "user";
|
|
4810
|
+
content: string | Array<UserMessageContentPart>;
|
|
4811
|
+
name?: string;
|
|
4812
|
+
};
|
|
4813
|
+
export type AssistantMessageContentPart = {
|
|
4814
|
+
type: "text" | "refusal";
|
|
4815
|
+
text?: string;
|
|
4816
|
+
refusal?: string;
|
|
4817
|
+
};
|
|
4818
|
+
export type AssistantMessage = {
|
|
4819
|
+
role: "assistant";
|
|
4820
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4821
|
+
refusal?: string | null;
|
|
4822
|
+
name?: string;
|
|
4823
|
+
audio?: {
|
|
4824
|
+
id: string;
|
|
4825
|
+
};
|
|
4826
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4827
|
+
function_call?: {
|
|
4828
|
+
name: string;
|
|
4829
|
+
arguments: string;
|
|
4830
|
+
};
|
|
4831
|
+
};
|
|
4832
|
+
export type ToolMessage = {
|
|
4833
|
+
role: "tool";
|
|
4834
|
+
content:
|
|
4835
|
+
| string
|
|
4836
|
+
| Array<{
|
|
4837
|
+
type: "text";
|
|
4838
|
+
text: string;
|
|
4839
|
+
}>;
|
|
4840
|
+
tool_call_id: string;
|
|
4841
|
+
};
|
|
4842
|
+
export type FunctionMessage = {
|
|
4843
|
+
role: "function";
|
|
4844
|
+
content: string;
|
|
4845
|
+
name: string;
|
|
4846
|
+
};
|
|
4847
|
+
export type ChatCompletionMessageParam =
|
|
4848
|
+
| DeveloperMessage
|
|
4849
|
+
| SystemMessage
|
|
4850
|
+
| UserMessage
|
|
4851
|
+
| AssistantMessage
|
|
4852
|
+
| ToolMessage
|
|
4853
|
+
| FunctionMessage;
|
|
4854
|
+
export type ChatCompletionsResponseFormatText = {
|
|
4855
|
+
type: "text";
|
|
4856
|
+
};
|
|
4857
|
+
export type ChatCompletionsResponseFormatJSONObject = {
|
|
4858
|
+
type: "json_object";
|
|
4859
|
+
};
|
|
4860
|
+
export type ResponseFormatJSONSchema = {
|
|
4861
|
+
type: "json_schema";
|
|
4862
|
+
json_schema: {
|
|
4863
|
+
name: string;
|
|
4864
|
+
description?: string;
|
|
4865
|
+
schema?: Record<string, unknown>;
|
|
4866
|
+
strict?: boolean | null;
|
|
4867
|
+
};
|
|
4868
|
+
};
|
|
4869
|
+
export type ResponseFormat =
|
|
4870
|
+
| ChatCompletionsResponseFormatText
|
|
4871
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4872
|
+
| ResponseFormatJSONSchema;
|
|
4873
|
+
export type ChatCompletionsStreamOptions = {
|
|
4874
|
+
include_usage?: boolean;
|
|
4875
|
+
include_obfuscation?: boolean;
|
|
4876
|
+
};
|
|
4877
|
+
export type PredictionContent = {
|
|
4878
|
+
type: "content";
|
|
4879
|
+
content:
|
|
4880
|
+
| string
|
|
4881
|
+
| Array<{
|
|
4882
|
+
type: "text";
|
|
4883
|
+
text: string;
|
|
4884
|
+
}>;
|
|
4885
|
+
};
|
|
4886
|
+
export type AudioParams = {
|
|
4887
|
+
voice:
|
|
4888
|
+
| string
|
|
4889
|
+
| {
|
|
4890
|
+
id: string;
|
|
4891
|
+
};
|
|
4892
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4893
|
+
};
|
|
4894
|
+
export type WebSearchUserLocation = {
|
|
4895
|
+
type: "approximate";
|
|
4896
|
+
approximate: {
|
|
4897
|
+
city?: string;
|
|
4898
|
+
country?: string;
|
|
4899
|
+
region?: string;
|
|
4900
|
+
timezone?: string;
|
|
4901
|
+
};
|
|
4902
|
+
};
|
|
4903
|
+
export type WebSearchOptions = {
|
|
4904
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4905
|
+
user_location?: WebSearchUserLocation;
|
|
4906
|
+
};
|
|
4907
|
+
export type ChatTemplateKwargs = {
|
|
4908
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4909
|
+
enable_thinking?: boolean;
|
|
4910
|
+
/** If false, preserves reasoning context between turns. */
|
|
4911
|
+
clear_thinking?: boolean;
|
|
4912
|
+
};
|
|
4913
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4914
|
+
export type ChatCompletionsCommonOptions = {
|
|
4915
|
+
model?: string;
|
|
4916
|
+
audio?: AudioParams;
|
|
4917
|
+
frequency_penalty?: number | null;
|
|
4918
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4919
|
+
logprobs?: boolean | null;
|
|
4920
|
+
top_logprobs?: number | null;
|
|
4921
|
+
max_tokens?: number | null;
|
|
4922
|
+
max_completion_tokens?: number | null;
|
|
4923
|
+
metadata?: Record<string, unknown> | null;
|
|
4924
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4925
|
+
n?: number | null;
|
|
4926
|
+
parallel_tool_calls?: boolean;
|
|
4927
|
+
prediction?: PredictionContent;
|
|
4928
|
+
presence_penalty?: number | null;
|
|
4929
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4930
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4931
|
+
response_format?: ResponseFormat;
|
|
4932
|
+
seed?: number | null;
|
|
4933
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4934
|
+
stop?: string | Array<string> | null;
|
|
4935
|
+
store?: boolean | null;
|
|
4936
|
+
stream?: boolean | null;
|
|
4937
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4938
|
+
temperature?: number | null;
|
|
4939
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4940
|
+
tools?: Array<ChatCompletionTool>;
|
|
4941
|
+
top_p?: number | null;
|
|
4942
|
+
user?: string;
|
|
4943
|
+
web_search_options?: WebSearchOptions;
|
|
4944
|
+
function_call?:
|
|
4945
|
+
| "none"
|
|
4946
|
+
| "auto"
|
|
4947
|
+
| {
|
|
4948
|
+
name: string;
|
|
4949
|
+
};
|
|
4950
|
+
functions?: Array<FunctionDefinition>;
|
|
4951
|
+
};
|
|
4952
|
+
export type PromptTokensDetails = {
|
|
4953
|
+
cached_tokens?: number;
|
|
4954
|
+
audio_tokens?: number;
|
|
4955
|
+
};
|
|
4956
|
+
export type CompletionTokensDetails = {
|
|
4957
|
+
reasoning_tokens?: number;
|
|
4958
|
+
audio_tokens?: number;
|
|
4959
|
+
accepted_prediction_tokens?: number;
|
|
4960
|
+
rejected_prediction_tokens?: number;
|
|
4961
|
+
};
|
|
4962
|
+
export type CompletionUsage = {
|
|
4963
|
+
prompt_tokens: number;
|
|
4964
|
+
completion_tokens: number;
|
|
4965
|
+
total_tokens: number;
|
|
4966
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4967
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4968
|
+
};
|
|
4969
|
+
export type ChatCompletionTopLogprob = {
|
|
4970
|
+
token: string;
|
|
4971
|
+
logprob: number;
|
|
4972
|
+
bytes: Array<number> | null;
|
|
4973
|
+
};
|
|
4974
|
+
export type ChatCompletionTokenLogprob = {
|
|
4975
|
+
token: string;
|
|
4976
|
+
logprob: number;
|
|
4977
|
+
bytes: Array<number> | null;
|
|
4978
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4979
|
+
};
|
|
4980
|
+
export type ChatCompletionAudio = {
|
|
4981
|
+
id: string;
|
|
4982
|
+
/** Base64 encoded audio bytes. */
|
|
4983
|
+
data: string;
|
|
4984
|
+
expires_at: number;
|
|
4985
|
+
transcript: string;
|
|
4986
|
+
};
|
|
4987
|
+
export type ChatCompletionUrlCitation = {
|
|
4988
|
+
type: "url_citation";
|
|
4989
|
+
url_citation: {
|
|
4990
|
+
url: string;
|
|
4991
|
+
title: string;
|
|
4992
|
+
start_index: number;
|
|
4993
|
+
end_index: number;
|
|
4994
|
+
};
|
|
4995
|
+
};
|
|
4996
|
+
export type ChatCompletionResponseMessage = {
|
|
4997
|
+
role: "assistant";
|
|
4998
|
+
content: string | null;
|
|
4999
|
+
refusal: string | null;
|
|
5000
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
5001
|
+
audio?: ChatCompletionAudio;
|
|
5002
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
5003
|
+
function_call?: {
|
|
5004
|
+
name: string;
|
|
5005
|
+
arguments: string;
|
|
5006
|
+
} | null;
|
|
5007
|
+
};
|
|
5008
|
+
export type ChatCompletionLogprobs = {
|
|
5009
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
5010
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
5011
|
+
};
|
|
5012
|
+
export type ChatCompletionChoice = {
|
|
5013
|
+
index: number;
|
|
5014
|
+
message: ChatCompletionResponseMessage;
|
|
5015
|
+
finish_reason:
|
|
5016
|
+
| "stop"
|
|
5017
|
+
| "length"
|
|
5018
|
+
| "tool_calls"
|
|
5019
|
+
| "content_filter"
|
|
5020
|
+
| "function_call";
|
|
5021
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
5022
|
+
};
|
|
5023
|
+
export type ChatCompletionsPromptInput = {
|
|
5024
|
+
prompt: string;
|
|
5025
|
+
} & ChatCompletionsCommonOptions;
|
|
5026
|
+
export type ChatCompletionsMessagesInput = {
|
|
5027
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
5028
|
+
} & ChatCompletionsCommonOptions;
|
|
5029
|
+
export type ChatCompletionsOutput = {
|
|
5030
|
+
id: string;
|
|
5031
|
+
object: string;
|
|
5032
|
+
created: number;
|
|
5033
|
+
model: string;
|
|
5034
|
+
choices: Array<ChatCompletionChoice>;
|
|
5035
|
+
usage?: CompletionUsage;
|
|
5036
|
+
system_fingerprint?: string | null;
|
|
5037
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
5038
|
+
};
|
|
4334
5039
|
/**
|
|
4335
5040
|
* Workers AI support for OpenAI's Responses API
|
|
4336
5041
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4753,6 +5458,12 @@ export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4753
5458
|
export type StreamOptions = {
|
|
4754
5459
|
include_obfuscation?: boolean;
|
|
4755
5460
|
};
|
|
5461
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5462
|
+
export type Without<T, U> = {
|
|
5463
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5464
|
+
};
|
|
5465
|
+
/** Either T or U, but not both (mutually exclusive) */
|
|
5466
|
+
export type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4756
5467
|
export type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4757
5468
|
| {
|
|
4758
5469
|
text: string | string[];
|
|
@@ -5045,10 +5756,12 @@ export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5045
5756
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5046
5757
|
}
|
|
5047
5758
|
export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5759
|
+
audio:
|
|
5760
|
+
| string
|
|
5761
|
+
| {
|
|
5762
|
+
body?: object;
|
|
5763
|
+
contentType?: string;
|
|
5764
|
+
};
|
|
5052
5765
|
/**
|
|
5053
5766
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5054
5767
|
*/
|
|
@@ -5066,9 +5779,33 @@ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5066
5779
|
*/
|
|
5067
5780
|
initial_prompt?: string;
|
|
5068
5781
|
/**
|
|
5069
|
-
* The prefix
|
|
5782
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5070
5783
|
*/
|
|
5071
5784
|
prefix?: string;
|
|
5785
|
+
/**
|
|
5786
|
+
* The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
|
|
5787
|
+
*/
|
|
5788
|
+
beam_size?: number;
|
|
5789
|
+
/**
|
|
5790
|
+
* Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
|
|
5791
|
+
*/
|
|
5792
|
+
condition_on_previous_text?: boolean;
|
|
5793
|
+
/**
|
|
5794
|
+
* Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
|
|
5795
|
+
*/
|
|
5796
|
+
no_speech_threshold?: number;
|
|
5797
|
+
/**
|
|
5798
|
+
* Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
|
|
5799
|
+
*/
|
|
5800
|
+
compression_ratio_threshold?: number;
|
|
5801
|
+
/**
|
|
5802
|
+
* Threshold for filtering out segments with low average log probability, indicating low confidence.
|
|
5803
|
+
*/
|
|
5804
|
+
log_prob_threshold?: number;
|
|
5805
|
+
/**
|
|
5806
|
+
* Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
|
|
5807
|
+
*/
|
|
5808
|
+
hallucination_silence_threshold?: number;
|
|
5072
5809
|
}
|
|
5073
5810
|
export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5074
5811
|
transcription_info?: {
|
|
@@ -5215,11 +5952,11 @@ export interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5215
5952
|
truncate_inputs?: boolean;
|
|
5216
5953
|
}
|
|
5217
5954
|
export type Ai_Cf_Baai_Bge_M3_Output =
|
|
5218
|
-
|
|
|
5955
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5219
5956
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5220
|
-
|
|
|
5957
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5221
5958
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5222
|
-
export interface
|
|
5959
|
+
export interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5223
5960
|
response?: {
|
|
5224
5961
|
/**
|
|
5225
5962
|
* Index of the context in the request
|
|
@@ -5239,7 +5976,7 @@ export interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5239
5976
|
*/
|
|
5240
5977
|
pooling?: "mean" | "cls";
|
|
5241
5978
|
}
|
|
5242
|
-
export interface
|
|
5979
|
+
export interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5243
5980
|
shape?: number[];
|
|
5244
5981
|
/**
|
|
5245
5982
|
* Embeddings of the requested text values
|
|
@@ -5344,7 +6081,7 @@ export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5344
6081
|
*/
|
|
5345
6082
|
role?: string;
|
|
5346
6083
|
/**
|
|
5347
|
-
* The tool call id.
|
|
6084
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5348
6085
|
*/
|
|
5349
6086
|
tool_call_id?: string;
|
|
5350
6087
|
content?:
|
|
@@ -5599,10 +6336,18 @@ export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5599
6336
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5600
6337
|
*/
|
|
5601
6338
|
role: string;
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
6339
|
+
content:
|
|
6340
|
+
| string
|
|
6341
|
+
| {
|
|
6342
|
+
/**
|
|
6343
|
+
* Type of the content (text)
|
|
6344
|
+
*/
|
|
6345
|
+
type?: string;
|
|
6346
|
+
/**
|
|
6347
|
+
* Text content
|
|
6348
|
+
*/
|
|
6349
|
+
text?: string;
|
|
6350
|
+
}[];
|
|
5606
6351
|
}[];
|
|
5607
6352
|
functions?: {
|
|
5608
6353
|
name: string;
|
|
@@ -6258,7 +7003,7 @@ export interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6258
7003
|
*/
|
|
6259
7004
|
role?: string;
|
|
6260
7005
|
/**
|
|
6261
|
-
* The tool call id.
|
|
7006
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6262
7007
|
*/
|
|
6263
7008
|
tool_call_id?: string;
|
|
6264
7009
|
content?:
|
|
@@ -6385,7 +7130,7 @@ export interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6385
7130
|
}
|
|
6386
7131
|
)[];
|
|
6387
7132
|
/**
|
|
6388
|
-
* JSON schema that should be
|
|
7133
|
+
* JSON schema that should be fufilled for the response.
|
|
6389
7134
|
*/
|
|
6390
7135
|
guided_json?: object;
|
|
6391
7136
|
/**
|
|
@@ -6659,7 +7404,7 @@ export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6659
7404
|
}
|
|
6660
7405
|
)[];
|
|
6661
7406
|
/**
|
|
6662
|
-
* JSON schema that should be
|
|
7407
|
+
* JSON schema that should be fufilled for the response.
|
|
6663
7408
|
*/
|
|
6664
7409
|
guided_json?: object;
|
|
6665
7410
|
/**
|
|
@@ -6752,7 +7497,7 @@ export interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6752
7497
|
*/
|
|
6753
7498
|
prompt: string;
|
|
6754
7499
|
/**
|
|
6755
|
-
* JSON schema that should be
|
|
7500
|
+
* JSON schema that should be fufilled for the response.
|
|
6756
7501
|
*/
|
|
6757
7502
|
guided_json?: object;
|
|
6758
7503
|
/**
|
|
@@ -6916,7 +7661,7 @@ export interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6916
7661
|
}
|
|
6917
7662
|
)[];
|
|
6918
7663
|
/**
|
|
6919
|
-
* JSON schema that should be
|
|
7664
|
+
* JSON schema that should be fufilled for the response.
|
|
6920
7665
|
*/
|
|
6921
7666
|
guided_json?: object;
|
|
6922
7667
|
/**
|
|
@@ -7197,7 +7942,7 @@ export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7197
7942
|
)[];
|
|
7198
7943
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7199
7944
|
/**
|
|
7200
|
-
* JSON schema that should be
|
|
7945
|
+
* JSON schema that should be fufilled for the response.
|
|
7201
7946
|
*/
|
|
7202
7947
|
guided_json?: object;
|
|
7203
7948
|
/**
|
|
@@ -7436,7 +8181,7 @@ export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7436
8181
|
)[];
|
|
7437
8182
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7438
8183
|
/**
|
|
7439
|
-
* JSON schema that should be
|
|
8184
|
+
* JSON schema that should be fufilled for the response.
|
|
7440
8185
|
*/
|
|
7441
8186
|
guided_json?: object;
|
|
7442
8187
|
/**
|
|
@@ -7601,10 +8346,18 @@ export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7601
8346
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7602
8347
|
*/
|
|
7603
8348
|
role: string;
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
8349
|
+
content:
|
|
8350
|
+
| string
|
|
8351
|
+
| {
|
|
8352
|
+
/**
|
|
8353
|
+
* Type of the content (text)
|
|
8354
|
+
*/
|
|
8355
|
+
type?: string;
|
|
8356
|
+
/**
|
|
8357
|
+
* Text content
|
|
8358
|
+
*/
|
|
8359
|
+
text?: string;
|
|
8360
|
+
}[];
|
|
7608
8361
|
}[];
|
|
7609
8362
|
functions?: {
|
|
7610
8363
|
name: string;
|
|
@@ -7816,10 +8569,18 @@ export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7816
8569
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7817
8570
|
*/
|
|
7818
8571
|
role: string;
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
8572
|
+
content:
|
|
8573
|
+
| string
|
|
8574
|
+
| {
|
|
8575
|
+
/**
|
|
8576
|
+
* Type of the content (text)
|
|
8577
|
+
*/
|
|
8578
|
+
type?: string;
|
|
8579
|
+
/**
|
|
8580
|
+
* Text content
|
|
8581
|
+
*/
|
|
8582
|
+
text?: string;
|
|
8583
|
+
}[];
|
|
7823
8584
|
}[];
|
|
7824
8585
|
functions?: {
|
|
7825
8586
|
name: string;
|
|
@@ -8387,12 +9148,12 @@ export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8387
9148
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8388
9149
|
}
|
|
8389
9150
|
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8390
|
-
inputs: ResponsesInput
|
|
8391
|
-
postProcessedOutputs: ResponsesOutput
|
|
9151
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9152
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8392
9153
|
}
|
|
8393
9154
|
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8394
|
-
inputs: ResponsesInput
|
|
8395
|
-
postProcessedOutputs: ResponsesOutput
|
|
9155
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9156
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8396
9157
|
}
|
|
8397
9158
|
export interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8398
9159
|
/**
|
|
@@ -8524,7 +9285,7 @@ export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8524
9285
|
*/
|
|
8525
9286
|
text: string | string[];
|
|
8526
9287
|
/**
|
|
8527
|
-
* Target
|
|
9288
|
+
* Target langauge to translate to
|
|
8528
9289
|
*/
|
|
8529
9290
|
target_language:
|
|
8530
9291
|
| "asm_Beng"
|
|
@@ -8640,10 +9401,18 @@ export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8640
9401
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8641
9402
|
*/
|
|
8642
9403
|
role: string;
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
9404
|
+
content:
|
|
9405
|
+
| string
|
|
9406
|
+
| {
|
|
9407
|
+
/**
|
|
9408
|
+
* Type of the content (text)
|
|
9409
|
+
*/
|
|
9410
|
+
type?: string;
|
|
9411
|
+
/**
|
|
9412
|
+
* Text content
|
|
9413
|
+
*/
|
|
9414
|
+
text?: string;
|
|
9415
|
+
}[];
|
|
8647
9416
|
}[];
|
|
8648
9417
|
functions?: {
|
|
8649
9418
|
name: string;
|
|
@@ -8855,10 +9624,18 @@ export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8855
9624
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8856
9625
|
*/
|
|
8857
9626
|
role: string;
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
9627
|
+
content:
|
|
9628
|
+
| string
|
|
9629
|
+
| {
|
|
9630
|
+
/**
|
|
9631
|
+
* Type of the content (text)
|
|
9632
|
+
*/
|
|
9633
|
+
type?: string;
|
|
9634
|
+
/**
|
|
9635
|
+
* Text content
|
|
9636
|
+
*/
|
|
9637
|
+
text?: string;
|
|
9638
|
+
}[];
|
|
8862
9639
|
}[];
|
|
8863
9640
|
functions?: {
|
|
8864
9641
|
name: string;
|
|
@@ -9413,6 +10190,66 @@ export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9413
10190
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9414
10191
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9415
10192
|
}
|
|
10193
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10194
|
+
multipart: {
|
|
10195
|
+
body?: object;
|
|
10196
|
+
contentType?: string;
|
|
10197
|
+
};
|
|
10198
|
+
}
|
|
10199
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10200
|
+
/**
|
|
10201
|
+
* Generated image as Base64 string.
|
|
10202
|
+
*/
|
|
10203
|
+
image?: string;
|
|
10204
|
+
}
|
|
10205
|
+
export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
|
|
10206
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
|
|
10207
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
|
|
10208
|
+
}
|
|
10209
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10210
|
+
multipart: {
|
|
10211
|
+
body?: object;
|
|
10212
|
+
contentType?: string;
|
|
10213
|
+
};
|
|
10214
|
+
}
|
|
10215
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10216
|
+
/**
|
|
10217
|
+
* Generated image as Base64 string.
|
|
10218
|
+
*/
|
|
10219
|
+
image?: string;
|
|
10220
|
+
}
|
|
10221
|
+
export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
|
|
10222
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
|
|
10223
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
|
|
10224
|
+
}
|
|
10225
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10226
|
+
multipart: {
|
|
10227
|
+
body?: object;
|
|
10228
|
+
contentType?: string;
|
|
10229
|
+
};
|
|
10230
|
+
}
|
|
10231
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10232
|
+
/**
|
|
10233
|
+
* Generated image as Base64 string.
|
|
10234
|
+
*/
|
|
10235
|
+
image?: string;
|
|
10236
|
+
}
|
|
10237
|
+
export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
|
|
10238
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
|
|
10239
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
|
|
10240
|
+
}
|
|
10241
|
+
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10242
|
+
inputs: ChatCompletionsInput;
|
|
10243
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10244
|
+
}
|
|
10245
|
+
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10246
|
+
inputs: ChatCompletionsInput;
|
|
10247
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10248
|
+
}
|
|
10249
|
+
export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10250
|
+
inputs: ChatCompletionsInput;
|
|
10251
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10252
|
+
}
|
|
9416
10253
|
export interface AiModels {
|
|
9417
10254
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9418
10255
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9431,7 +10268,6 @@ export interface AiModels {
|
|
|
9431
10268
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9432
10269
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9433
10270
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9434
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9435
10271
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9436
10272
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9437
10273
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9498,6 +10334,12 @@ export interface AiModels {
|
|
|
9498
10334
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9499
10335
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9500
10336
|
"@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
|
|
10337
|
+
"@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
|
|
10338
|
+
"@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
|
|
10339
|
+
"@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
|
|
10340
|
+
"@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
|
|
10341
|
+
"@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
|
|
10342
|
+
"@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
|
|
9501
10343
|
}
|
|
9502
10344
|
export type AiOptions = {
|
|
9503
10345
|
/**
|
|
@@ -9523,6 +10365,7 @@ export type AiOptions = {
|
|
|
9523
10365
|
returnRawResponse?: boolean;
|
|
9524
10366
|
prefix?: string;
|
|
9525
10367
|
extraHeaders?: object;
|
|
10368
|
+
signal?: AbortSignal;
|
|
9526
10369
|
};
|
|
9527
10370
|
export type AiModelsSearchParams = {
|
|
9528
10371
|
author?: string;
|
|
@@ -9549,6 +10392,16 @@ export type AiModelsSearchObject = {
|
|
|
9549
10392
|
value: string;
|
|
9550
10393
|
}[];
|
|
9551
10394
|
};
|
|
10395
|
+
export type ChatCompletionsBase = XOR<
|
|
10396
|
+
ChatCompletionsPromptInput,
|
|
10397
|
+
ChatCompletionsMessagesInput
|
|
10398
|
+
>;
|
|
10399
|
+
export type ChatCompletionsInput = XOR<
|
|
10400
|
+
ChatCompletionsBase,
|
|
10401
|
+
{
|
|
10402
|
+
requests: ChatCompletionsBase[];
|
|
10403
|
+
}
|
|
10404
|
+
>;
|
|
9552
10405
|
export interface InferenceUpstreamError extends Error {}
|
|
9553
10406
|
export interface AiInternalError extends Error {}
|
|
9554
10407
|
export type AiModelListType = Record<string, any>;
|
|
@@ -9558,46 +10411,16 @@ export declare abstract class Ai<
|
|
|
9558
10411
|
aiGatewayLogId: string | null;
|
|
9559
10412
|
gateway(gatewayId: string): AiGateway;
|
|
9560
10413
|
/**
|
|
9561
|
-
*
|
|
9562
|
-
*
|
|
9563
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9564
|
-
* - Account-level operations: `list()`, `create()`
|
|
9565
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9566
|
-
*
|
|
9567
|
-
* @example
|
|
9568
|
-
* ```typescript
|
|
9569
|
-
* // List all AI Search instances
|
|
9570
|
-
* const instances = await env.AI.aiSearch.list();
|
|
9571
|
-
*
|
|
9572
|
-
* // Search an instance
|
|
9573
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9574
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9575
|
-
* ai_search_options: {
|
|
9576
|
-
* retrieval: { max_num_results: 10 }
|
|
9577
|
-
* }
|
|
9578
|
-
* });
|
|
9579
|
-
*
|
|
9580
|
-
* // Generate chat completions with AI Search context
|
|
9581
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9582
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9583
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9584
|
-
* });
|
|
9585
|
-
* ```
|
|
10414
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10415
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9586
10416
|
*/
|
|
9587
|
-
aiSearch():
|
|
10417
|
+
aiSearch(): AiSearchNamespace;
|
|
9588
10418
|
/**
|
|
9589
10419
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9590
|
-
* Use `
|
|
9591
|
-
*
|
|
9592
|
-
* Migration guide:
|
|
9593
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9594
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9595
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10420
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10421
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9596
10422
|
*
|
|
9597
|
-
*
|
|
9598
|
-
*
|
|
9599
|
-
* @see AiSearchAccountService
|
|
9600
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10423
|
+
* @param autoragId Instance ID
|
|
9601
10424
|
*/
|
|
9602
10425
|
autorag(autoragId: string): AutoRAG;
|
|
9603
10426
|
run<
|
|
@@ -9756,22 +10579,23 @@ export declare abstract class AiGateway {
|
|
|
9756
10579
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9757
10580
|
}
|
|
9758
10581
|
/**
|
|
9759
|
-
* @deprecated
|
|
9760
|
-
*
|
|
10582
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10583
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9761
10584
|
*/
|
|
9762
10585
|
export interface AutoRAGInternalError extends Error {}
|
|
9763
10586
|
/**
|
|
9764
|
-
* @deprecated
|
|
9765
|
-
*
|
|
10587
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10588
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9766
10589
|
*/
|
|
9767
10590
|
export interface AutoRAGNotFoundError extends Error {}
|
|
9768
10591
|
/**
|
|
9769
|
-
* @deprecated
|
|
10592
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10593
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9770
10594
|
*/
|
|
9771
10595
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
9772
10596
|
/**
|
|
9773
|
-
* @deprecated
|
|
9774
|
-
*
|
|
10597
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10598
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9775
10599
|
*/
|
|
9776
10600
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
9777
10601
|
export type ComparisonFilter = {
|
|
@@ -9784,9 +10608,8 @@ export type CompoundFilter = {
|
|
|
9784
10608
|
filters: ComparisonFilter[];
|
|
9785
10609
|
};
|
|
9786
10610
|
/**
|
|
9787
|
-
* @deprecated
|
|
9788
|
-
*
|
|
9789
|
-
* @see AiSearchSearchRequest
|
|
10611
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10612
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9790
10613
|
*/
|
|
9791
10614
|
export type AutoRagSearchRequest = {
|
|
9792
10615
|
query: string;
|
|
@@ -9803,18 +10626,16 @@ export type AutoRagSearchRequest = {
|
|
|
9803
10626
|
rewrite_query?: boolean;
|
|
9804
10627
|
};
|
|
9805
10628
|
/**
|
|
9806
|
-
* @deprecated
|
|
9807
|
-
*
|
|
9808
|
-
* @see AiSearchChatCompletionsRequest
|
|
10629
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10630
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9809
10631
|
*/
|
|
9810
10632
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9811
10633
|
stream?: boolean;
|
|
9812
10634
|
system_prompt?: string;
|
|
9813
10635
|
};
|
|
9814
10636
|
/**
|
|
9815
|
-
* @deprecated
|
|
9816
|
-
*
|
|
9817
|
-
* @see AiSearchChatCompletionsRequest
|
|
10637
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10638
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9818
10639
|
*/
|
|
9819
10640
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
9820
10641
|
AutoRagAiSearchRequest,
|
|
@@ -9823,9 +10644,8 @@ export type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9823
10644
|
stream: true;
|
|
9824
10645
|
};
|
|
9825
10646
|
/**
|
|
9826
|
-
* @deprecated
|
|
9827
|
-
*
|
|
9828
|
-
* @see AiSearchSearchResponse
|
|
10647
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10648
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9829
10649
|
*/
|
|
9830
10650
|
export type AutoRagSearchResponse = {
|
|
9831
10651
|
object: "vector_store.search_results.page";
|
|
@@ -9844,9 +10664,8 @@ export type AutoRagSearchResponse = {
|
|
|
9844
10664
|
next_page: string | null;
|
|
9845
10665
|
};
|
|
9846
10666
|
/**
|
|
9847
|
-
* @deprecated
|
|
9848
|
-
*
|
|
9849
|
-
* @see AiSearchListResponse
|
|
10667
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10668
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9850
10669
|
*/
|
|
9851
10670
|
export type AutoRagListResponse = {
|
|
9852
10671
|
id: string;
|
|
@@ -9858,49 +10677,40 @@ export type AutoRagListResponse = {
|
|
|
9858
10677
|
status: string;
|
|
9859
10678
|
}[];
|
|
9860
10679
|
/**
|
|
9861
|
-
* @deprecated
|
|
9862
|
-
*
|
|
10680
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10681
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9863
10682
|
*/
|
|
9864
10683
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9865
10684
|
response: string;
|
|
9866
10685
|
};
|
|
9867
10686
|
/**
|
|
9868
|
-
* @deprecated
|
|
9869
|
-
*
|
|
9870
|
-
*
|
|
9871
|
-
* Migration guide:
|
|
9872
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9873
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9874
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9875
|
-
*
|
|
9876
|
-
* @see AiSearchAccountService
|
|
9877
|
-
* @see AiSearchInstanceService
|
|
10687
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10688
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9878
10689
|
*/
|
|
9879
10690
|
export declare abstract class AutoRAG {
|
|
9880
10691
|
/**
|
|
9881
|
-
* @deprecated Use
|
|
9882
|
-
*
|
|
10692
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10693
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9883
10694
|
*/
|
|
9884
10695
|
list(): Promise<AutoRagListResponse>;
|
|
9885
10696
|
/**
|
|
9886
|
-
* @deprecated Use
|
|
9887
|
-
*
|
|
9888
|
-
* @see AiSearchInstanceService.search
|
|
10697
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10698
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9889
10699
|
*/
|
|
9890
10700
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9891
10701
|
/**
|
|
9892
|
-
* @deprecated Use
|
|
9893
|
-
*
|
|
10702
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10703
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9894
10704
|
*/
|
|
9895
10705
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9896
10706
|
/**
|
|
9897
|
-
* @deprecated Use
|
|
9898
|
-
*
|
|
10707
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10708
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9899
10709
|
*/
|
|
9900
10710
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9901
10711
|
/**
|
|
9902
|
-
* @deprecated Use
|
|
9903
|
-
*
|
|
10712
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10713
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9904
10714
|
*/
|
|
9905
10715
|
aiSearch(
|
|
9906
10716
|
params: AutoRagAiSearchRequest,
|
|
@@ -10025,6 +10835,41 @@ export interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
10025
10835
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
10026
10836
|
*/
|
|
10027
10837
|
cacheTtlByStatus?: Record<string, number>;
|
|
10838
|
+
/**
|
|
10839
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10840
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10841
|
+
*
|
|
10842
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10843
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10844
|
+
*
|
|
10845
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10846
|
+
*/
|
|
10847
|
+
cacheControl?: string;
|
|
10848
|
+
/**
|
|
10849
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10850
|
+
*/
|
|
10851
|
+
cacheReserveEligible?: boolean;
|
|
10852
|
+
/**
|
|
10853
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10854
|
+
*/
|
|
10855
|
+
respectStrongEtag?: boolean;
|
|
10856
|
+
/**
|
|
10857
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10858
|
+
*/
|
|
10859
|
+
stripEtags?: boolean;
|
|
10860
|
+
/**
|
|
10861
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10862
|
+
*/
|
|
10863
|
+
stripLastModified?: boolean;
|
|
10864
|
+
/**
|
|
10865
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10866
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10867
|
+
*/
|
|
10868
|
+
cacheDeceptionArmor?: boolean;
|
|
10869
|
+
/**
|
|
10870
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10871
|
+
*/
|
|
10872
|
+
cacheReserveMinimumFileSize?: number;
|
|
10028
10873
|
scrapeShield?: boolean;
|
|
10029
10874
|
apps?: boolean;
|
|
10030
10875
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11893,6 +12738,7 @@ export declare namespace CloudflareWorkersModule {
|
|
|
11893
12738
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11894
12739
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11895
12740
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12741
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11896
12742
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11897
12743
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11898
12744
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11913,6 +12759,7 @@ export declare namespace CloudflareWorkersModule {
|
|
|
11913
12759
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11914
12760
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11915
12761
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12762
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11916
12763
|
webSocketMessage?(
|
|
11917
12764
|
ws: WebSocket,
|
|
11918
12765
|
message: string | ArrayBuffer,
|
|
@@ -12053,17 +12900,6 @@ export interface StreamBinding {
|
|
|
12053
12900
|
* @returns A handle for per-video operations.
|
|
12054
12901
|
*/
|
|
12055
12902
|
video(id: string): StreamVideoHandle;
|
|
12056
|
-
/**
|
|
12057
|
-
* Uploads a new video from a File.
|
|
12058
|
-
* @param file The video file to upload.
|
|
12059
|
-
* @returns The uploaded video details.
|
|
12060
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12061
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12062
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12063
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12064
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12065
|
-
*/
|
|
12066
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12067
12903
|
/**
|
|
12068
12904
|
* Uploads a new video from a provided URL.
|
|
12069
12905
|
* @param url The URL to upload from.
|
|
@@ -12913,6 +13749,9 @@ export declare namespace TailStream {
|
|
|
12913
13749
|
readonly type: "fetch";
|
|
12914
13750
|
readonly statusCode: number;
|
|
12915
13751
|
}
|
|
13752
|
+
interface ConnectEventInfo {
|
|
13753
|
+
readonly type: "connect";
|
|
13754
|
+
}
|
|
12916
13755
|
type EventOutcome =
|
|
12917
13756
|
| "ok"
|
|
12918
13757
|
| "canceled"
|
|
@@ -12943,6 +13782,7 @@ export declare namespace TailStream {
|
|
|
12943
13782
|
readonly scriptVersion?: ScriptVersion;
|
|
12944
13783
|
readonly info:
|
|
12945
13784
|
| FetchEventInfo
|
|
13785
|
+
| ConnectEventInfo
|
|
12946
13786
|
| JsRpcEventInfo
|
|
12947
13787
|
| ScheduledEventInfo
|
|
12948
13788
|
| AlarmEventInfo
|