@cloudflare/workers-types 4.20260317.1 → 4.20260331.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2021-11-03/index.d.ts +1018 -180
- package/2021-11-03/index.ts +1020 -180
- package/2022-01-31/index.d.ts +1018 -180
- package/2022-01-31/index.ts +1020 -180
- package/2022-03-21/index.d.ts +1018 -180
- package/2022-03-21/index.ts +1020 -180
- package/2022-08-04/index.d.ts +1018 -180
- package/2022-08-04/index.ts +1020 -180
- package/2022-10-31/index.d.ts +1018 -180
- package/2022-10-31/index.ts +1020 -180
- package/2022-11-30/index.d.ts +1018 -180
- package/2022-11-30/index.ts +1020 -180
- package/2023-03-01/index.d.ts +1018 -180
- package/2023-03-01/index.ts +1020 -180
- package/2023-07-01/index.d.ts +1018 -180
- package/2023-07-01/index.ts +1020 -180
- package/experimental/index.d.ts +1089 -181
- package/experimental/index.ts +1091 -181
- package/index.d.ts +1018 -180
- package/index.ts +1020 -180
- package/latest/index.d.ts +1018 -180
- package/latest/index.ts +1020 -180
- package/oldest/index.d.ts +1018 -180
- package/oldest/index.ts +1020 -180
- package/package.json +1 -1
package/2022-01-31/index.ts
CHANGED
|
@@ -480,6 +480,11 @@ export type ExportedHandlerFetchHandler<
|
|
|
480
480
|
env: Env,
|
|
481
481
|
ctx: ExecutionContext<Props>,
|
|
482
482
|
) => Response | Promise<Response>;
|
|
483
|
+
export type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
|
|
484
|
+
socket: Socket,
|
|
485
|
+
env: Env,
|
|
486
|
+
ctx: ExecutionContext<Props>,
|
|
487
|
+
) => void | Promise<void>;
|
|
483
488
|
export type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
|
|
484
489
|
events: TraceItem[],
|
|
485
490
|
env: Env,
|
|
@@ -521,6 +526,7 @@ export interface ExportedHandler<
|
|
|
521
526
|
Props = unknown,
|
|
522
527
|
> {
|
|
523
528
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
|
|
529
|
+
connect?: ExportedHandlerConnectHandler<Env, Props>;
|
|
524
530
|
tail?: ExportedHandlerTailHandler<Env, Props>;
|
|
525
531
|
trace?: ExportedHandlerTraceHandler<Env, Props>;
|
|
526
532
|
tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
|
|
@@ -535,12 +541,14 @@ export interface StructuredSerializeOptions {
|
|
|
535
541
|
export interface AlarmInvocationInfo {
|
|
536
542
|
readonly isRetry: boolean;
|
|
537
543
|
readonly retryCount: number;
|
|
544
|
+
readonly scheduledTime: number;
|
|
538
545
|
}
|
|
539
546
|
export interface Cloudflare {
|
|
540
547
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
541
548
|
}
|
|
542
549
|
export interface DurableObject {
|
|
543
550
|
fetch(request: Request): Response | Promise<Response>;
|
|
551
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
544
552
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
545
553
|
webSocketMessage?(
|
|
546
554
|
ws: WebSocket,
|
|
@@ -558,7 +566,7 @@ export type DurableObjectStub<
|
|
|
558
566
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
559
567
|
> = Fetcher<
|
|
560
568
|
T,
|
|
561
|
-
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
569
|
+
"alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
|
|
562
570
|
> & {
|
|
563
571
|
readonly id: DurableObjectId;
|
|
564
572
|
readonly name?: string;
|
|
@@ -567,6 +575,7 @@ export interface DurableObjectId {
|
|
|
567
575
|
toString(): string;
|
|
568
576
|
equals(other: DurableObjectId): boolean;
|
|
569
577
|
readonly name?: string;
|
|
578
|
+
readonly jurisdiction?: string;
|
|
570
579
|
}
|
|
571
580
|
export declare abstract class DurableObjectNamespace<
|
|
572
581
|
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
@@ -3080,6 +3089,11 @@ export interface QueuingStrategyInit {
|
|
|
3080
3089
|
*/
|
|
3081
3090
|
highWaterMark: number;
|
|
3082
3091
|
}
|
|
3092
|
+
export interface TracePreviewInfo {
|
|
3093
|
+
id: string;
|
|
3094
|
+
slug: string;
|
|
3095
|
+
name: string;
|
|
3096
|
+
}
|
|
3083
3097
|
export interface ScriptVersion {
|
|
3084
3098
|
id?: string;
|
|
3085
3099
|
tag?: string;
|
|
@@ -3094,6 +3108,7 @@ export interface TraceItem {
|
|
|
3094
3108
|
| (
|
|
3095
3109
|
| TraceItemFetchEventInfo
|
|
3096
3110
|
| TraceItemJsRpcEventInfo
|
|
3111
|
+
| TraceItemConnectEventInfo
|
|
3097
3112
|
| TraceItemScheduledEventInfo
|
|
3098
3113
|
| TraceItemAlarmEventInfo
|
|
3099
3114
|
| TraceItemQueueEventInfo
|
|
@@ -3112,6 +3127,8 @@ export interface TraceItem {
|
|
|
3112
3127
|
readonly scriptVersion?: ScriptVersion;
|
|
3113
3128
|
readonly dispatchNamespace?: string;
|
|
3114
3129
|
readonly scriptTags?: string[];
|
|
3130
|
+
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3131
|
+
readonly preview?: TracePreviewInfo;
|
|
3115
3132
|
readonly durableObjectId?: string;
|
|
3116
3133
|
readonly outcome: string;
|
|
3117
3134
|
readonly executionModel: string;
|
|
@@ -3122,6 +3139,7 @@ export interface TraceItem {
|
|
|
3122
3139
|
export interface TraceItemAlarmEventInfo {
|
|
3123
3140
|
readonly scheduledTime: Date;
|
|
3124
3141
|
}
|
|
3142
|
+
export interface TraceItemConnectEventInfo {}
|
|
3125
3143
|
export interface TraceItemCustomEventInfo {}
|
|
3126
3144
|
export interface TraceItemScheduledEventInfo {
|
|
3127
3145
|
readonly scheduledTime: number;
|
|
@@ -3722,7 +3740,7 @@ export interface ContainerStartupOptions {
|
|
|
3722
3740
|
entrypoint?: string[];
|
|
3723
3741
|
enableInternet: boolean;
|
|
3724
3742
|
env?: Record<string, string>;
|
|
3725
|
-
|
|
3743
|
+
labels?: Record<string, string>;
|
|
3726
3744
|
}
|
|
3727
3745
|
/**
|
|
3728
3746
|
* 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.
|
|
@@ -3849,11 +3867,10 @@ export declare abstract class Performance {
|
|
|
3849
3867
|
*/
|
|
3850
3868
|
toJSON(): object;
|
|
3851
3869
|
}
|
|
3852
|
-
// AI Search
|
|
3870
|
+
// ============ AI Search Error Interfaces ============
|
|
3853
3871
|
export interface AiSearchInternalError extends Error {}
|
|
3854
3872
|
export interface AiSearchNotFoundError extends Error {}
|
|
3855
|
-
|
|
3856
|
-
// AI Search V2 Request Types
|
|
3873
|
+
// ============ AI Search Request Types ============
|
|
3857
3874
|
export type AiSearchSearchRequest = {
|
|
3858
3875
|
messages: Array<{
|
|
3859
3876
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -3878,9 +3895,8 @@ export type AiSearchSearchRequest = {
|
|
|
3878
3895
|
[key: string]: unknown;
|
|
3879
3896
|
};
|
|
3880
3897
|
reranking?: {
|
|
3881
|
-
/** Enable reranking (default false) */
|
|
3882
3898
|
enabled?: boolean;
|
|
3883
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3899
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3884
3900
|
/** Match threshold (0-1, default 0.4) */
|
|
3885
3901
|
match_threshold?: number;
|
|
3886
3902
|
[key: string]: unknown;
|
|
@@ -3892,6 +3908,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3892
3908
|
messages: Array<{
|
|
3893
3909
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3894
3910
|
content: string | null;
|
|
3911
|
+
[key: string]: unknown;
|
|
3895
3912
|
}>;
|
|
3896
3913
|
model?: string;
|
|
3897
3914
|
stream?: boolean;
|
|
@@ -3912,7 +3929,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3912
3929
|
};
|
|
3913
3930
|
reranking?: {
|
|
3914
3931
|
enabled?: boolean;
|
|
3915
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
3932
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
3916
3933
|
match_threshold?: number;
|
|
3917
3934
|
[key: string]: unknown;
|
|
3918
3935
|
};
|
|
@@ -3920,7 +3937,7 @@ export type AiSearchChatCompletionsRequest = {
|
|
|
3920
3937
|
};
|
|
3921
3938
|
[key: string]: unknown;
|
|
3922
3939
|
};
|
|
3923
|
-
// AI Search
|
|
3940
|
+
// ============ AI Search Response Types ============
|
|
3924
3941
|
export type AiSearchSearchResponse = {
|
|
3925
3942
|
search_query: string;
|
|
3926
3943
|
chunks: Array<{
|
|
@@ -3939,26 +3956,65 @@ export type AiSearchSearchResponse = {
|
|
|
3939
3956
|
keyword_score?: number;
|
|
3940
3957
|
/** Vector similarity score (0-1) */
|
|
3941
3958
|
vector_score?: number;
|
|
3959
|
+
[key: string]: unknown;
|
|
3960
|
+
};
|
|
3961
|
+
}>;
|
|
3962
|
+
};
|
|
3963
|
+
export type AiSearchChatCompletionsResponse = {
|
|
3964
|
+
id?: string;
|
|
3965
|
+
object?: string;
|
|
3966
|
+
model?: string;
|
|
3967
|
+
choices: Array<{
|
|
3968
|
+
index?: number;
|
|
3969
|
+
message: {
|
|
3970
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3971
|
+
content: string | null;
|
|
3972
|
+
[key: string]: unknown;
|
|
3942
3973
|
};
|
|
3974
|
+
[key: string]: unknown;
|
|
3943
3975
|
}>;
|
|
3976
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
3977
|
+
[key: string]: unknown;
|
|
3944
3978
|
};
|
|
3945
|
-
export type
|
|
3979
|
+
export type AiSearchStatsResponse = {
|
|
3980
|
+
queued?: number;
|
|
3981
|
+
running?: number;
|
|
3982
|
+
completed?: number;
|
|
3983
|
+
error?: number;
|
|
3984
|
+
skipped?: number;
|
|
3985
|
+
outdated?: number;
|
|
3986
|
+
last_activity?: string;
|
|
3987
|
+
};
|
|
3988
|
+
// ============ AI Search Instance Info Types ============
|
|
3989
|
+
export type AiSearchInstanceInfo = {
|
|
3946
3990
|
id: string;
|
|
3947
|
-
|
|
3948
|
-
account_id?: string;
|
|
3949
|
-
account_tag?: string;
|
|
3950
|
-
/** Whether the instance is enabled (default true) */
|
|
3951
|
-
enable?: boolean;
|
|
3952
|
-
type?: "r2" | "web-crawler";
|
|
3991
|
+
type?: "r2" | "web-crawler" | string;
|
|
3953
3992
|
source?: string;
|
|
3993
|
+
paused?: boolean;
|
|
3994
|
+
status?: string;
|
|
3995
|
+
namespace?: string;
|
|
3996
|
+
created_at?: string;
|
|
3997
|
+
modified_at?: string;
|
|
3954
3998
|
[key: string]: unknown;
|
|
3955
|
-
}
|
|
3999
|
+
};
|
|
4000
|
+
export type AiSearchListResponse = {
|
|
4001
|
+
result: AiSearchInstanceInfo[];
|
|
4002
|
+
result_info?: {
|
|
4003
|
+
count: number;
|
|
4004
|
+
page: number;
|
|
4005
|
+
per_page: number;
|
|
4006
|
+
total_count: number;
|
|
4007
|
+
};
|
|
4008
|
+
};
|
|
4009
|
+
// ============ AI Search Config Types ============
|
|
3956
4010
|
export type AiSearchConfig = {
|
|
3957
4011
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3958
4012
|
id: string;
|
|
3959
|
-
type
|
|
3960
|
-
|
|
3961
|
-
|
|
4013
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4014
|
+
type?: "r2" | "web-crawler" | string;
|
|
4015
|
+
/** Source URL (required for web-crawler type). */
|
|
4016
|
+
source?: string;
|
|
4017
|
+
source_params?: unknown;
|
|
3962
4018
|
/** Token ID (UUID format) */
|
|
3963
4019
|
token_id?: string;
|
|
3964
4020
|
ai_gateway_id?: string;
|
|
@@ -3968,54 +4024,307 @@ export type AiSearchConfig = {
|
|
|
3968
4024
|
reranking?: boolean;
|
|
3969
4025
|
embedding_model?: string;
|
|
3970
4026
|
ai_search_model?: string;
|
|
4027
|
+
[key: string]: unknown;
|
|
3971
4028
|
};
|
|
3972
|
-
|
|
4029
|
+
// ============ AI Search Item Types ============
|
|
4030
|
+
export type AiSearchItemInfo = {
|
|
3973
4031
|
id: string;
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
4032
|
+
key: string;
|
|
4033
|
+
status:
|
|
4034
|
+
| "completed"
|
|
4035
|
+
| "error"
|
|
4036
|
+
| "skipped"
|
|
4037
|
+
| "queued"
|
|
4038
|
+
| "processing"
|
|
4039
|
+
| "outdated";
|
|
4040
|
+
metadata?: Record<string, unknown>;
|
|
3977
4041
|
[key: string]: unknown;
|
|
3978
4042
|
};
|
|
3979
|
-
|
|
3980
|
-
|
|
4043
|
+
export type AiSearchItemContentResult = {
|
|
4044
|
+
body: ReadableStream;
|
|
4045
|
+
contentType: string;
|
|
4046
|
+
filename: string;
|
|
4047
|
+
size: number;
|
|
4048
|
+
};
|
|
4049
|
+
export type AiSearchUploadItemOptions = {
|
|
4050
|
+
metadata?: Record<string, unknown>;
|
|
4051
|
+
};
|
|
4052
|
+
export type AiSearchListItemsParams = {
|
|
4053
|
+
page?: number;
|
|
4054
|
+
per_page?: number;
|
|
4055
|
+
};
|
|
4056
|
+
export type AiSearchListItemsResponse = {
|
|
4057
|
+
result: AiSearchItemInfo[];
|
|
4058
|
+
result_info?: {
|
|
4059
|
+
count: number;
|
|
4060
|
+
page: number;
|
|
4061
|
+
per_page: number;
|
|
4062
|
+
total_count: number;
|
|
4063
|
+
};
|
|
4064
|
+
};
|
|
4065
|
+
// ============ AI Search Job Types ============
|
|
4066
|
+
export type AiSearchJobInfo = {
|
|
4067
|
+
id: string;
|
|
4068
|
+
source: "user" | "schedule";
|
|
4069
|
+
description?: string;
|
|
4070
|
+
last_seen_at?: string;
|
|
4071
|
+
started_at?: string;
|
|
4072
|
+
ended_at?: string;
|
|
4073
|
+
end_reason?: string;
|
|
4074
|
+
};
|
|
4075
|
+
export type AiSearchJobLog = {
|
|
4076
|
+
id: number;
|
|
4077
|
+
message: string;
|
|
4078
|
+
message_type: number;
|
|
4079
|
+
created_at: number;
|
|
4080
|
+
};
|
|
4081
|
+
export type AiSearchCreateJobParams = {
|
|
4082
|
+
description?: string;
|
|
4083
|
+
};
|
|
4084
|
+
export type AiSearchListJobsParams = {
|
|
4085
|
+
page?: number;
|
|
4086
|
+
per_page?: number;
|
|
4087
|
+
};
|
|
4088
|
+
export type AiSearchListJobsResponse = {
|
|
4089
|
+
result: AiSearchJobInfo[];
|
|
4090
|
+
result_info?: {
|
|
4091
|
+
count: number;
|
|
4092
|
+
page: number;
|
|
4093
|
+
per_page: number;
|
|
4094
|
+
total_count: number;
|
|
4095
|
+
};
|
|
4096
|
+
};
|
|
4097
|
+
export type AiSearchJobLogsParams = {
|
|
4098
|
+
page?: number;
|
|
4099
|
+
per_page?: number;
|
|
4100
|
+
};
|
|
4101
|
+
export type AiSearchJobLogsResponse = {
|
|
4102
|
+
result: AiSearchJobLog[];
|
|
4103
|
+
result_info?: {
|
|
4104
|
+
count: number;
|
|
4105
|
+
page: number;
|
|
4106
|
+
per_page: number;
|
|
4107
|
+
total_count: number;
|
|
4108
|
+
};
|
|
4109
|
+
};
|
|
4110
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4111
|
+
/**
|
|
4112
|
+
* Single item service for an AI Search instance.
|
|
4113
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4114
|
+
*/
|
|
4115
|
+
export declare abstract class AiSearchItem {
|
|
4116
|
+
/** Get metadata about this item. */
|
|
4117
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4118
|
+
/**
|
|
4119
|
+
* Download the item's content.
|
|
4120
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4121
|
+
*/
|
|
4122
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4123
|
+
}
|
|
4124
|
+
/**
|
|
4125
|
+
* Items collection service for an AI Search instance.
|
|
4126
|
+
* Provides list, upload, and access to individual items.
|
|
4127
|
+
*/
|
|
4128
|
+
export declare abstract class AiSearchItems {
|
|
4129
|
+
/** List items in this instance. */
|
|
4130
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4131
|
+
/**
|
|
4132
|
+
* Upload a file as an item.
|
|
4133
|
+
* @param name Filename for the uploaded item.
|
|
4134
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4135
|
+
* @param options Optional metadata to attach to the item.
|
|
4136
|
+
* @returns The created item info.
|
|
4137
|
+
*/
|
|
4138
|
+
upload(
|
|
4139
|
+
name: string,
|
|
4140
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4141
|
+
options?: AiSearchUploadItemOptions,
|
|
4142
|
+
): Promise<AiSearchItemInfo>;
|
|
4143
|
+
/**
|
|
4144
|
+
* Upload a file and poll until processing completes.
|
|
4145
|
+
* @param name Filename for the uploaded item.
|
|
4146
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4147
|
+
* @param options Optional metadata to attach to the item.
|
|
4148
|
+
* @returns The item info after processing completes (or timeout).
|
|
4149
|
+
*/
|
|
4150
|
+
uploadAndPoll(
|
|
4151
|
+
name: string,
|
|
4152
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4153
|
+
options?: AiSearchUploadItemOptions,
|
|
4154
|
+
): Promise<AiSearchItemInfo>;
|
|
4155
|
+
/**
|
|
4156
|
+
* Get an item by ID.
|
|
4157
|
+
* @param itemId The item identifier.
|
|
4158
|
+
* @returns Item service for info, delete, and download operations.
|
|
4159
|
+
*/
|
|
4160
|
+
get(itemId: string): AiSearchItem;
|
|
4161
|
+
/** Delete this item from the instance.
|
|
4162
|
+
* @param itemId The item identifier.
|
|
4163
|
+
*/
|
|
4164
|
+
delete(itemId: string): Promise<void>;
|
|
4165
|
+
}
|
|
4166
|
+
/**
|
|
4167
|
+
* Single job service for an AI Search instance.
|
|
4168
|
+
* Provides info and logs for a specific job.
|
|
4169
|
+
*/
|
|
4170
|
+
export declare abstract class AiSearchJob {
|
|
4171
|
+
/** Get metadata about this job. */
|
|
4172
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4173
|
+
/** Get logs for this job. */
|
|
4174
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4175
|
+
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Jobs collection service for an AI Search instance.
|
|
4178
|
+
* Provides list, create, and access to individual jobs.
|
|
4179
|
+
*/
|
|
4180
|
+
export declare abstract class AiSearchJobs {
|
|
4181
|
+
/** List jobs for this instance. */
|
|
4182
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4183
|
+
/**
|
|
4184
|
+
* Create a new indexing job.
|
|
4185
|
+
* @param params Optional job parameters.
|
|
4186
|
+
* @returns The created job info.
|
|
4187
|
+
*/
|
|
4188
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4189
|
+
/**
|
|
4190
|
+
* Get a job by ID.
|
|
4191
|
+
* @param jobId The job identifier.
|
|
4192
|
+
* @returns Job service for info and logs operations.
|
|
4193
|
+
*/
|
|
4194
|
+
get(jobId: string): AiSearchJob;
|
|
4195
|
+
}
|
|
4196
|
+
// ============ AI Search Binding Classes ============
|
|
4197
|
+
/**
|
|
4198
|
+
* Instance-level AI Search service.
|
|
4199
|
+
*
|
|
4200
|
+
* Used as:
|
|
4201
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4202
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4203
|
+
*
|
|
4204
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4205
|
+
*
|
|
4206
|
+
* @example
|
|
4207
|
+
* ```ts
|
|
4208
|
+
* // Via namespace binding
|
|
4209
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
4210
|
+
* const results = await instance.search({
|
|
4211
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4212
|
+
* });
|
|
4213
|
+
*
|
|
4214
|
+
* // Via single instance binding
|
|
4215
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
4216
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4217
|
+
* });
|
|
4218
|
+
* ```
|
|
4219
|
+
*/
|
|
4220
|
+
export declare abstract class AiSearchInstance {
|
|
3981
4221
|
/**
|
|
3982
4222
|
* Search the AI Search instance for relevant chunks.
|
|
3983
|
-
* @param params Search request with messages and AI search options
|
|
3984
|
-
* @returns Search response with matching chunks
|
|
4223
|
+
* @param params Search request with messages and optional AI search options.
|
|
4224
|
+
* @returns Search response with matching chunks and search query.
|
|
3985
4225
|
*/
|
|
3986
4226
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
4227
|
+
/**
|
|
4228
|
+
* Generate chat completions with AI Search context (streaming).
|
|
4229
|
+
* @param params Chat completions request with stream: true.
|
|
4230
|
+
* @returns ReadableStream of server-sent events.
|
|
4231
|
+
*/
|
|
4232
|
+
chatCompletions(
|
|
4233
|
+
params: AiSearchChatCompletionsRequest & {
|
|
4234
|
+
stream: true;
|
|
4235
|
+
},
|
|
4236
|
+
): Promise<ReadableStream>;
|
|
3987
4237
|
/**
|
|
3988
4238
|
* Generate chat completions with AI Search context.
|
|
3989
|
-
* @param params Chat completions request
|
|
3990
|
-
* @returns
|
|
4239
|
+
* @param params Chat completions request.
|
|
4240
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
3991
4241
|
*/
|
|
3992
4242
|
chatCompletions(
|
|
3993
4243
|
params: AiSearchChatCompletionsRequest,
|
|
3994
|
-
): Promise<
|
|
4244
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
3995
4245
|
/**
|
|
3996
|
-
*
|
|
4246
|
+
* Update the instance configuration.
|
|
4247
|
+
* @param config Partial configuration to update.
|
|
4248
|
+
* @returns Updated instance info.
|
|
3997
4249
|
*/
|
|
3998
|
-
|
|
4250
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
4251
|
+
/** Get metadata about this instance. */
|
|
4252
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
4253
|
+
/**
|
|
4254
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
4255
|
+
* @returns Statistics with counts per status and last activity time.
|
|
4256
|
+
*/
|
|
4257
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
4258
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
4259
|
+
get items(): AiSearchItems;
|
|
4260
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
4261
|
+
get jobs(): AiSearchJobs;
|
|
3999
4262
|
}
|
|
4000
|
-
|
|
4001
|
-
|
|
4263
|
+
/**
|
|
4264
|
+
* Namespace-level AI Search service.
|
|
4265
|
+
*
|
|
4266
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
4267
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
4268
|
+
*
|
|
4269
|
+
* @example
|
|
4270
|
+
* ```ts
|
|
4271
|
+
* // Access an instance within the namespace
|
|
4272
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
4273
|
+
* const results = await blog.search({
|
|
4274
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
4275
|
+
* });
|
|
4276
|
+
*
|
|
4277
|
+
* // List all instances in the namespace
|
|
4278
|
+
* const instances = await env.AI_SEARCH.list();
|
|
4279
|
+
*
|
|
4280
|
+
* // Create a new instance with built-in storage
|
|
4281
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
4282
|
+
* id: "tenant-123",
|
|
4283
|
+
* });
|
|
4284
|
+
*
|
|
4285
|
+
* // Upload items into the instance
|
|
4286
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
4287
|
+
*
|
|
4288
|
+
* // Delete an instance
|
|
4289
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
4290
|
+
* ```
|
|
4291
|
+
*/
|
|
4292
|
+
export declare abstract class AiSearchNamespace {
|
|
4002
4293
|
/**
|
|
4003
|
-
*
|
|
4004
|
-
* @
|
|
4294
|
+
* Get an instance by name within the bound namespace.
|
|
4295
|
+
* @param name Instance name.
|
|
4296
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
4297
|
+
*/
|
|
4298
|
+
get(name: string): AiSearchInstance;
|
|
4299
|
+
/**
|
|
4300
|
+
* List all instances in the bound namespace.
|
|
4301
|
+
* @returns Array of instance metadata.
|
|
4005
4302
|
*/
|
|
4006
4303
|
list(): Promise<AiSearchListResponse>;
|
|
4007
4304
|
/**
|
|
4008
|
-
*
|
|
4009
|
-
* @param
|
|
4010
|
-
* @returns Instance service for
|
|
4305
|
+
* Create a new instance within the bound namespace.
|
|
4306
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
4307
|
+
* @returns Instance service for the newly created instance.
|
|
4308
|
+
*
|
|
4309
|
+
* @example
|
|
4310
|
+
* ```ts
|
|
4311
|
+
* // Create with built-in storage (upload items manually)
|
|
4312
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
4313
|
+
*
|
|
4314
|
+
* // Create with web crawler source
|
|
4315
|
+
* const instance = await env.AI_SEARCH.create({
|
|
4316
|
+
* id: "docs-search",
|
|
4317
|
+
* type: "web-crawler",
|
|
4318
|
+
* source: "https://developers.cloudflare.com",
|
|
4319
|
+
* });
|
|
4320
|
+
* ```
|
|
4011
4321
|
*/
|
|
4012
|
-
|
|
4322
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4013
4323
|
/**
|
|
4014
|
-
*
|
|
4015
|
-
* @param
|
|
4016
|
-
* @returns Instance service for performing operations
|
|
4324
|
+
* Delete an instance from the bound namespace.
|
|
4325
|
+
* @param name Instance name to delete.
|
|
4017
4326
|
*/
|
|
4018
|
-
|
|
4327
|
+
delete(name: string): Promise<void>;
|
|
4019
4328
|
}
|
|
4020
4329
|
export type AiImageClassificationInput = {
|
|
4021
4330
|
image: number[];
|
|
@@ -4291,6 +4600,402 @@ export declare abstract class BaseAiTranslation {
|
|
|
4291
4600
|
inputs: AiTranslationInput;
|
|
4292
4601
|
postProcessedOutputs: AiTranslationOutput;
|
|
4293
4602
|
}
|
|
4603
|
+
/**
|
|
4604
|
+
* Workers AI support for OpenAI's Chat Completions API
|
|
4605
|
+
*/
|
|
4606
|
+
export type ChatCompletionContentPartText = {
|
|
4607
|
+
type: "text";
|
|
4608
|
+
text: string;
|
|
4609
|
+
};
|
|
4610
|
+
export type ChatCompletionContentPartImage = {
|
|
4611
|
+
type: "image_url";
|
|
4612
|
+
image_url: {
|
|
4613
|
+
url: string;
|
|
4614
|
+
detail?: "auto" | "low" | "high";
|
|
4615
|
+
};
|
|
4616
|
+
};
|
|
4617
|
+
export type ChatCompletionContentPartInputAudio = {
|
|
4618
|
+
type: "input_audio";
|
|
4619
|
+
input_audio: {
|
|
4620
|
+
/** Base64 encoded audio data. */
|
|
4621
|
+
data: string;
|
|
4622
|
+
format: "wav" | "mp3";
|
|
4623
|
+
};
|
|
4624
|
+
};
|
|
4625
|
+
export type ChatCompletionContentPartFile = {
|
|
4626
|
+
type: "file";
|
|
4627
|
+
file: {
|
|
4628
|
+
/** Base64 encoded file data. */
|
|
4629
|
+
file_data?: string;
|
|
4630
|
+
/** The ID of an uploaded file. */
|
|
4631
|
+
file_id?: string;
|
|
4632
|
+
filename?: string;
|
|
4633
|
+
};
|
|
4634
|
+
};
|
|
4635
|
+
export type ChatCompletionContentPartRefusal = {
|
|
4636
|
+
type: "refusal";
|
|
4637
|
+
refusal: string;
|
|
4638
|
+
};
|
|
4639
|
+
export type ChatCompletionContentPart =
|
|
4640
|
+
| ChatCompletionContentPartText
|
|
4641
|
+
| ChatCompletionContentPartImage
|
|
4642
|
+
| ChatCompletionContentPartInputAudio
|
|
4643
|
+
| ChatCompletionContentPartFile;
|
|
4644
|
+
export type FunctionDefinition = {
|
|
4645
|
+
name: string;
|
|
4646
|
+
description?: string;
|
|
4647
|
+
parameters?: Record<string, unknown>;
|
|
4648
|
+
strict?: boolean | null;
|
|
4649
|
+
};
|
|
4650
|
+
export type ChatCompletionFunctionTool = {
|
|
4651
|
+
type: "function";
|
|
4652
|
+
function: FunctionDefinition;
|
|
4653
|
+
};
|
|
4654
|
+
export type ChatCompletionCustomToolGrammarFormat = {
|
|
4655
|
+
type: "grammar";
|
|
4656
|
+
grammar: {
|
|
4657
|
+
definition: string;
|
|
4658
|
+
syntax: "lark" | "regex";
|
|
4659
|
+
};
|
|
4660
|
+
};
|
|
4661
|
+
export type ChatCompletionCustomToolTextFormat = {
|
|
4662
|
+
type: "text";
|
|
4663
|
+
};
|
|
4664
|
+
export type ChatCompletionCustomToolFormat =
|
|
4665
|
+
| ChatCompletionCustomToolTextFormat
|
|
4666
|
+
| ChatCompletionCustomToolGrammarFormat;
|
|
4667
|
+
export type ChatCompletionCustomTool = {
|
|
4668
|
+
type: "custom";
|
|
4669
|
+
custom: {
|
|
4670
|
+
name: string;
|
|
4671
|
+
description?: string;
|
|
4672
|
+
format?: ChatCompletionCustomToolFormat;
|
|
4673
|
+
};
|
|
4674
|
+
};
|
|
4675
|
+
export type ChatCompletionTool =
|
|
4676
|
+
| ChatCompletionFunctionTool
|
|
4677
|
+
| ChatCompletionCustomTool;
|
|
4678
|
+
export type ChatCompletionMessageFunctionToolCall = {
|
|
4679
|
+
id: string;
|
|
4680
|
+
type: "function";
|
|
4681
|
+
function: {
|
|
4682
|
+
name: string;
|
|
4683
|
+
/** JSON-encoded arguments string. */
|
|
4684
|
+
arguments: string;
|
|
4685
|
+
};
|
|
4686
|
+
};
|
|
4687
|
+
export type ChatCompletionMessageCustomToolCall = {
|
|
4688
|
+
id: string;
|
|
4689
|
+
type: "custom";
|
|
4690
|
+
custom: {
|
|
4691
|
+
name: string;
|
|
4692
|
+
input: string;
|
|
4693
|
+
};
|
|
4694
|
+
};
|
|
4695
|
+
export type ChatCompletionMessageToolCall =
|
|
4696
|
+
| ChatCompletionMessageFunctionToolCall
|
|
4697
|
+
| ChatCompletionMessageCustomToolCall;
|
|
4698
|
+
export type ChatCompletionToolChoiceFunction = {
|
|
4699
|
+
type: "function";
|
|
4700
|
+
function: {
|
|
4701
|
+
name: string;
|
|
4702
|
+
};
|
|
4703
|
+
};
|
|
4704
|
+
export type ChatCompletionToolChoiceCustom = {
|
|
4705
|
+
type: "custom";
|
|
4706
|
+
custom: {
|
|
4707
|
+
name: string;
|
|
4708
|
+
};
|
|
4709
|
+
};
|
|
4710
|
+
export type ChatCompletionToolChoiceAllowedTools = {
|
|
4711
|
+
type: "allowed_tools";
|
|
4712
|
+
allowed_tools: {
|
|
4713
|
+
mode: "auto" | "required";
|
|
4714
|
+
tools: Array<Record<string, unknown>>;
|
|
4715
|
+
};
|
|
4716
|
+
};
|
|
4717
|
+
export type ChatCompletionToolChoiceOption =
|
|
4718
|
+
| "none"
|
|
4719
|
+
| "auto"
|
|
4720
|
+
| "required"
|
|
4721
|
+
| ChatCompletionToolChoiceFunction
|
|
4722
|
+
| ChatCompletionToolChoiceCustom
|
|
4723
|
+
| ChatCompletionToolChoiceAllowedTools;
|
|
4724
|
+
export type DeveloperMessage = {
|
|
4725
|
+
role: "developer";
|
|
4726
|
+
content:
|
|
4727
|
+
| string
|
|
4728
|
+
| Array<{
|
|
4729
|
+
type: "text";
|
|
4730
|
+
text: string;
|
|
4731
|
+
}>;
|
|
4732
|
+
name?: string;
|
|
4733
|
+
};
|
|
4734
|
+
export type SystemMessage = {
|
|
4735
|
+
role: "system";
|
|
4736
|
+
content:
|
|
4737
|
+
| string
|
|
4738
|
+
| Array<{
|
|
4739
|
+
type: "text";
|
|
4740
|
+
text: string;
|
|
4741
|
+
}>;
|
|
4742
|
+
name?: string;
|
|
4743
|
+
};
|
|
4744
|
+
/**
|
|
4745
|
+
* Permissive merged content part used inside UserMessage arrays.
|
|
4746
|
+
*
|
|
4747
|
+
* Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
|
|
4748
|
+
* inside nested array items does not correctly match different branches for
|
|
4749
|
+
* different array elements, so the schema uses a single merged object.
|
|
4750
|
+
*/
|
|
4751
|
+
export type UserMessageContentPart = {
|
|
4752
|
+
type: "text" | "image_url" | "input_audio" | "file";
|
|
4753
|
+
text?: string;
|
|
4754
|
+
image_url?: {
|
|
4755
|
+
url?: string;
|
|
4756
|
+
detail?: "auto" | "low" | "high";
|
|
4757
|
+
};
|
|
4758
|
+
input_audio?: {
|
|
4759
|
+
data?: string;
|
|
4760
|
+
format?: "wav" | "mp3";
|
|
4761
|
+
};
|
|
4762
|
+
file?: {
|
|
4763
|
+
file_data?: string;
|
|
4764
|
+
file_id?: string;
|
|
4765
|
+
filename?: string;
|
|
4766
|
+
};
|
|
4767
|
+
};
|
|
4768
|
+
export type UserMessage = {
|
|
4769
|
+
role: "user";
|
|
4770
|
+
content: string | Array<UserMessageContentPart>;
|
|
4771
|
+
name?: string;
|
|
4772
|
+
};
|
|
4773
|
+
export type AssistantMessageContentPart = {
|
|
4774
|
+
type: "text" | "refusal";
|
|
4775
|
+
text?: string;
|
|
4776
|
+
refusal?: string;
|
|
4777
|
+
};
|
|
4778
|
+
export type AssistantMessage = {
|
|
4779
|
+
role: "assistant";
|
|
4780
|
+
content?: string | null | Array<AssistantMessageContentPart>;
|
|
4781
|
+
refusal?: string | null;
|
|
4782
|
+
name?: string;
|
|
4783
|
+
audio?: {
|
|
4784
|
+
id: string;
|
|
4785
|
+
};
|
|
4786
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4787
|
+
function_call?: {
|
|
4788
|
+
name: string;
|
|
4789
|
+
arguments: string;
|
|
4790
|
+
};
|
|
4791
|
+
};
|
|
4792
|
+
export type ToolMessage = {
|
|
4793
|
+
role: "tool";
|
|
4794
|
+
content:
|
|
4795
|
+
| string
|
|
4796
|
+
| Array<{
|
|
4797
|
+
type: "text";
|
|
4798
|
+
text: string;
|
|
4799
|
+
}>;
|
|
4800
|
+
tool_call_id: string;
|
|
4801
|
+
};
|
|
4802
|
+
export type FunctionMessage = {
|
|
4803
|
+
role: "function";
|
|
4804
|
+
content: string;
|
|
4805
|
+
name: string;
|
|
4806
|
+
};
|
|
4807
|
+
export type ChatCompletionMessageParam =
|
|
4808
|
+
| DeveloperMessage
|
|
4809
|
+
| SystemMessage
|
|
4810
|
+
| UserMessage
|
|
4811
|
+
| AssistantMessage
|
|
4812
|
+
| ToolMessage
|
|
4813
|
+
| FunctionMessage;
|
|
4814
|
+
export type ChatCompletionsResponseFormatText = {
|
|
4815
|
+
type: "text";
|
|
4816
|
+
};
|
|
4817
|
+
export type ChatCompletionsResponseFormatJSONObject = {
|
|
4818
|
+
type: "json_object";
|
|
4819
|
+
};
|
|
4820
|
+
export type ResponseFormatJSONSchema = {
|
|
4821
|
+
type: "json_schema";
|
|
4822
|
+
json_schema: {
|
|
4823
|
+
name: string;
|
|
4824
|
+
description?: string;
|
|
4825
|
+
schema?: Record<string, unknown>;
|
|
4826
|
+
strict?: boolean | null;
|
|
4827
|
+
};
|
|
4828
|
+
};
|
|
4829
|
+
export type ResponseFormat =
|
|
4830
|
+
| ChatCompletionsResponseFormatText
|
|
4831
|
+
| ChatCompletionsResponseFormatJSONObject
|
|
4832
|
+
| ResponseFormatJSONSchema;
|
|
4833
|
+
export type ChatCompletionsStreamOptions = {
|
|
4834
|
+
include_usage?: boolean;
|
|
4835
|
+
include_obfuscation?: boolean;
|
|
4836
|
+
};
|
|
4837
|
+
export type PredictionContent = {
|
|
4838
|
+
type: "content";
|
|
4839
|
+
content:
|
|
4840
|
+
| string
|
|
4841
|
+
| Array<{
|
|
4842
|
+
type: "text";
|
|
4843
|
+
text: string;
|
|
4844
|
+
}>;
|
|
4845
|
+
};
|
|
4846
|
+
export type AudioParams = {
|
|
4847
|
+
voice:
|
|
4848
|
+
| string
|
|
4849
|
+
| {
|
|
4850
|
+
id: string;
|
|
4851
|
+
};
|
|
4852
|
+
format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
|
|
4853
|
+
};
|
|
4854
|
+
export type WebSearchUserLocation = {
|
|
4855
|
+
type: "approximate";
|
|
4856
|
+
approximate: {
|
|
4857
|
+
city?: string;
|
|
4858
|
+
country?: string;
|
|
4859
|
+
region?: string;
|
|
4860
|
+
timezone?: string;
|
|
4861
|
+
};
|
|
4862
|
+
};
|
|
4863
|
+
export type WebSearchOptions = {
|
|
4864
|
+
search_context_size?: "low" | "medium" | "high";
|
|
4865
|
+
user_location?: WebSearchUserLocation;
|
|
4866
|
+
};
|
|
4867
|
+
export type ChatTemplateKwargs = {
|
|
4868
|
+
/** Whether to enable reasoning, enabled by default. */
|
|
4869
|
+
enable_thinking?: boolean;
|
|
4870
|
+
/** If false, preserves reasoning context between turns. */
|
|
4871
|
+
clear_thinking?: boolean;
|
|
4872
|
+
};
|
|
4873
|
+
/** Shared optional properties used by both Prompt and Messages input branches. */
|
|
4874
|
+
export type ChatCompletionsCommonOptions = {
|
|
4875
|
+
model?: string;
|
|
4876
|
+
audio?: AudioParams;
|
|
4877
|
+
frequency_penalty?: number | null;
|
|
4878
|
+
logit_bias?: Record<string, unknown> | null;
|
|
4879
|
+
logprobs?: boolean | null;
|
|
4880
|
+
top_logprobs?: number | null;
|
|
4881
|
+
max_tokens?: number | null;
|
|
4882
|
+
max_completion_tokens?: number | null;
|
|
4883
|
+
metadata?: Record<string, unknown> | null;
|
|
4884
|
+
modalities?: Array<"text" | "audio"> | null;
|
|
4885
|
+
n?: number | null;
|
|
4886
|
+
parallel_tool_calls?: boolean;
|
|
4887
|
+
prediction?: PredictionContent;
|
|
4888
|
+
presence_penalty?: number | null;
|
|
4889
|
+
reasoning_effort?: "low" | "medium" | "high" | null;
|
|
4890
|
+
chat_template_kwargs?: ChatTemplateKwargs;
|
|
4891
|
+
response_format?: ResponseFormat;
|
|
4892
|
+
seed?: number | null;
|
|
4893
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4894
|
+
stop?: string | Array<string> | null;
|
|
4895
|
+
store?: boolean | null;
|
|
4896
|
+
stream?: boolean | null;
|
|
4897
|
+
stream_options?: ChatCompletionsStreamOptions;
|
|
4898
|
+
temperature?: number | null;
|
|
4899
|
+
tool_choice?: ChatCompletionToolChoiceOption;
|
|
4900
|
+
tools?: Array<ChatCompletionTool>;
|
|
4901
|
+
top_p?: number | null;
|
|
4902
|
+
user?: string;
|
|
4903
|
+
web_search_options?: WebSearchOptions;
|
|
4904
|
+
function_call?:
|
|
4905
|
+
| "none"
|
|
4906
|
+
| "auto"
|
|
4907
|
+
| {
|
|
4908
|
+
name: string;
|
|
4909
|
+
};
|
|
4910
|
+
functions?: Array<FunctionDefinition>;
|
|
4911
|
+
};
|
|
4912
|
+
export type PromptTokensDetails = {
|
|
4913
|
+
cached_tokens?: number;
|
|
4914
|
+
audio_tokens?: number;
|
|
4915
|
+
};
|
|
4916
|
+
export type CompletionTokensDetails = {
|
|
4917
|
+
reasoning_tokens?: number;
|
|
4918
|
+
audio_tokens?: number;
|
|
4919
|
+
accepted_prediction_tokens?: number;
|
|
4920
|
+
rejected_prediction_tokens?: number;
|
|
4921
|
+
};
|
|
4922
|
+
export type CompletionUsage = {
|
|
4923
|
+
prompt_tokens: number;
|
|
4924
|
+
completion_tokens: number;
|
|
4925
|
+
total_tokens: number;
|
|
4926
|
+
prompt_tokens_details?: PromptTokensDetails;
|
|
4927
|
+
completion_tokens_details?: CompletionTokensDetails;
|
|
4928
|
+
};
|
|
4929
|
+
export type ChatCompletionTopLogprob = {
|
|
4930
|
+
token: string;
|
|
4931
|
+
logprob: number;
|
|
4932
|
+
bytes: Array<number> | null;
|
|
4933
|
+
};
|
|
4934
|
+
export type ChatCompletionTokenLogprob = {
|
|
4935
|
+
token: string;
|
|
4936
|
+
logprob: number;
|
|
4937
|
+
bytes: Array<number> | null;
|
|
4938
|
+
top_logprobs: Array<ChatCompletionTopLogprob>;
|
|
4939
|
+
};
|
|
4940
|
+
export type ChatCompletionAudio = {
|
|
4941
|
+
id: string;
|
|
4942
|
+
/** Base64 encoded audio bytes. */
|
|
4943
|
+
data: string;
|
|
4944
|
+
expires_at: number;
|
|
4945
|
+
transcript: string;
|
|
4946
|
+
};
|
|
4947
|
+
export type ChatCompletionUrlCitation = {
|
|
4948
|
+
type: "url_citation";
|
|
4949
|
+
url_citation: {
|
|
4950
|
+
url: string;
|
|
4951
|
+
title: string;
|
|
4952
|
+
start_index: number;
|
|
4953
|
+
end_index: number;
|
|
4954
|
+
};
|
|
4955
|
+
};
|
|
4956
|
+
export type ChatCompletionResponseMessage = {
|
|
4957
|
+
role: "assistant";
|
|
4958
|
+
content: string | null;
|
|
4959
|
+
refusal: string | null;
|
|
4960
|
+
annotations?: Array<ChatCompletionUrlCitation>;
|
|
4961
|
+
audio?: ChatCompletionAudio;
|
|
4962
|
+
tool_calls?: Array<ChatCompletionMessageToolCall>;
|
|
4963
|
+
function_call?: {
|
|
4964
|
+
name: string;
|
|
4965
|
+
arguments: string;
|
|
4966
|
+
} | null;
|
|
4967
|
+
};
|
|
4968
|
+
export type ChatCompletionLogprobs = {
|
|
4969
|
+
content: Array<ChatCompletionTokenLogprob> | null;
|
|
4970
|
+
refusal?: Array<ChatCompletionTokenLogprob> | null;
|
|
4971
|
+
};
|
|
4972
|
+
export type ChatCompletionChoice = {
|
|
4973
|
+
index: number;
|
|
4974
|
+
message: ChatCompletionResponseMessage;
|
|
4975
|
+
finish_reason:
|
|
4976
|
+
| "stop"
|
|
4977
|
+
| "length"
|
|
4978
|
+
| "tool_calls"
|
|
4979
|
+
| "content_filter"
|
|
4980
|
+
| "function_call";
|
|
4981
|
+
logprobs: ChatCompletionLogprobs | null;
|
|
4982
|
+
};
|
|
4983
|
+
export type ChatCompletionsPromptInput = {
|
|
4984
|
+
prompt: string;
|
|
4985
|
+
} & ChatCompletionsCommonOptions;
|
|
4986
|
+
export type ChatCompletionsMessagesInput = {
|
|
4987
|
+
messages: Array<ChatCompletionMessageParam>;
|
|
4988
|
+
} & ChatCompletionsCommonOptions;
|
|
4989
|
+
export type ChatCompletionsOutput = {
|
|
4990
|
+
id: string;
|
|
4991
|
+
object: string;
|
|
4992
|
+
created: number;
|
|
4993
|
+
model: string;
|
|
4994
|
+
choices: Array<ChatCompletionChoice>;
|
|
4995
|
+
usage?: CompletionUsage;
|
|
4996
|
+
system_fingerprint?: string | null;
|
|
4997
|
+
service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
|
|
4998
|
+
};
|
|
4294
4999
|
/**
|
|
4295
5000
|
* Workers AI support for OpenAI's Responses API
|
|
4296
5001
|
* Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
|
|
@@ -4713,6 +5418,12 @@ export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
|
4713
5418
|
export type StreamOptions = {
|
|
4714
5419
|
include_obfuscation?: boolean;
|
|
4715
5420
|
};
|
|
5421
|
+
/** Marks keys from T that aren't in U as optional never */
|
|
5422
|
+
export 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
|
+
export type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
|
|
4716
5427
|
export type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
|
|
4717
5428
|
| {
|
|
4718
5429
|
text: string | string[];
|
|
@@ -5005,10 +5716,12 @@ export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
|
5005
5716
|
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
5006
5717
|
}
|
|
5007
5718
|
export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5719
|
+
audio:
|
|
5720
|
+
| string
|
|
5721
|
+
| {
|
|
5722
|
+
body?: object;
|
|
5723
|
+
contentType?: string;
|
|
5724
|
+
};
|
|
5012
5725
|
/**
|
|
5013
5726
|
* Supported tasks are 'translate' or 'transcribe'.
|
|
5014
5727
|
*/
|
|
@@ -5026,9 +5739,33 @@ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
|
5026
5739
|
*/
|
|
5027
5740
|
initial_prompt?: string;
|
|
5028
5741
|
/**
|
|
5029
|
-
* The prefix
|
|
5742
|
+
* The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
|
|
5030
5743
|
*/
|
|
5031
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;
|
|
5032
5769
|
}
|
|
5033
5770
|
export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
5034
5771
|
transcription_info?: {
|
|
@@ -5175,11 +5912,11 @@ export interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
|
|
|
5175
5912
|
truncate_inputs?: boolean;
|
|
5176
5913
|
}
|
|
5177
5914
|
export type Ai_Cf_Baai_Bge_M3_Output =
|
|
5178
|
-
|
|
|
5915
|
+
| Ai_Cf_Baai_Bge_M3_Output_Query
|
|
5179
5916
|
| Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
|
|
5180
|
-
|
|
|
5917
|
+
| Ai_Cf_Baai_Bge_M3_Output_Embedding
|
|
5181
5918
|
| Ai_Cf_Baai_Bge_M3_AsyncResponse;
|
|
5182
|
-
export interface
|
|
5919
|
+
export interface Ai_Cf_Baai_Bge_M3_Output_Query {
|
|
5183
5920
|
response?: {
|
|
5184
5921
|
/**
|
|
5185
5922
|
* Index of the context in the request
|
|
@@ -5199,7 +5936,7 @@ export interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
|
|
|
5199
5936
|
*/
|
|
5200
5937
|
pooling?: "mean" | "cls";
|
|
5201
5938
|
}
|
|
5202
|
-
export interface
|
|
5939
|
+
export interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
|
|
5203
5940
|
shape?: number[];
|
|
5204
5941
|
/**
|
|
5205
5942
|
* Embeddings of the requested text values
|
|
@@ -5304,7 +6041,7 @@ export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
|
|
|
5304
6041
|
*/
|
|
5305
6042
|
role?: string;
|
|
5306
6043
|
/**
|
|
5307
|
-
* The tool call id.
|
|
6044
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
5308
6045
|
*/
|
|
5309
6046
|
tool_call_id?: string;
|
|
5310
6047
|
content?:
|
|
@@ -5559,10 +6296,18 @@ export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
|
|
|
5559
6296
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
5560
6297
|
*/
|
|
5561
6298
|
role: string;
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
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
|
+
}[];
|
|
5566
6311
|
}[];
|
|
5567
6312
|
functions?: {
|
|
5568
6313
|
name: string;
|
|
@@ -6218,7 +6963,7 @@ export interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6218
6963
|
*/
|
|
6219
6964
|
role?: string;
|
|
6220
6965
|
/**
|
|
6221
|
-
* The tool call id.
|
|
6966
|
+
* The tool call id. If you don't know what to put here you can fall back to 000000001
|
|
6222
6967
|
*/
|
|
6223
6968
|
tool_call_id?: string;
|
|
6224
6969
|
content?:
|
|
@@ -6345,7 +7090,7 @@ export interface Ai_Cf_Qwen_Qwq_32B_Messages {
|
|
|
6345
7090
|
}
|
|
6346
7091
|
)[];
|
|
6347
7092
|
/**
|
|
6348
|
-
* JSON schema that should be
|
|
7093
|
+
* JSON schema that should be fufilled for the response.
|
|
6349
7094
|
*/
|
|
6350
7095
|
guided_json?: object;
|
|
6351
7096
|
/**
|
|
@@ -6619,7 +7364,7 @@ export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
|
|
|
6619
7364
|
}
|
|
6620
7365
|
)[];
|
|
6621
7366
|
/**
|
|
6622
|
-
* JSON schema that should be
|
|
7367
|
+
* JSON schema that should be fufilled for the response.
|
|
6623
7368
|
*/
|
|
6624
7369
|
guided_json?: object;
|
|
6625
7370
|
/**
|
|
@@ -6712,7 +7457,7 @@ export interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
|
|
|
6712
7457
|
*/
|
|
6713
7458
|
prompt: string;
|
|
6714
7459
|
/**
|
|
6715
|
-
* JSON schema that should be
|
|
7460
|
+
* JSON schema that should be fufilled for the response.
|
|
6716
7461
|
*/
|
|
6717
7462
|
guided_json?: object;
|
|
6718
7463
|
/**
|
|
@@ -6876,7 +7621,7 @@ export interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
|
|
|
6876
7621
|
}
|
|
6877
7622
|
)[];
|
|
6878
7623
|
/**
|
|
6879
|
-
* JSON schema that should be
|
|
7624
|
+
* JSON schema that should be fufilled for the response.
|
|
6880
7625
|
*/
|
|
6881
7626
|
guided_json?: object;
|
|
6882
7627
|
/**
|
|
@@ -7157,7 +7902,7 @@ export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
|
|
|
7157
7902
|
)[];
|
|
7158
7903
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7159
7904
|
/**
|
|
7160
|
-
* JSON schema that should be
|
|
7905
|
+
* JSON schema that should be fufilled for the response.
|
|
7161
7906
|
*/
|
|
7162
7907
|
guided_json?: object;
|
|
7163
7908
|
/**
|
|
@@ -7396,7 +8141,7 @@ export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
|
|
|
7396
8141
|
)[];
|
|
7397
8142
|
response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
|
|
7398
8143
|
/**
|
|
7399
|
-
* JSON schema that should be
|
|
8144
|
+
* JSON schema that should be fufilled for the response.
|
|
7400
8145
|
*/
|
|
7401
8146
|
guided_json?: object;
|
|
7402
8147
|
/**
|
|
@@ -7561,10 +8306,18 @@ export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
|
|
|
7561
8306
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7562
8307
|
*/
|
|
7563
8308
|
role: string;
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
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
|
+
}[];
|
|
7568
8321
|
}[];
|
|
7569
8322
|
functions?: {
|
|
7570
8323
|
name: string;
|
|
@@ -7776,10 +8529,18 @@ export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
|
|
|
7776
8529
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
7777
8530
|
*/
|
|
7778
8531
|
role: string;
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
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
|
+
}[];
|
|
7783
8544
|
}[];
|
|
7784
8545
|
functions?: {
|
|
7785
8546
|
name: string;
|
|
@@ -8347,12 +9108,12 @@ export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
|
|
|
8347
9108
|
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
|
|
8348
9109
|
}
|
|
8349
9110
|
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
|
|
8350
|
-
inputs: ResponsesInput
|
|
8351
|
-
postProcessedOutputs: ResponsesOutput
|
|
9111
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9112
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8352
9113
|
}
|
|
8353
9114
|
export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
|
|
8354
|
-
inputs: ResponsesInput
|
|
8355
|
-
postProcessedOutputs: ResponsesOutput
|
|
9115
|
+
inputs: XOR<ResponsesInput, ChatCompletionsInput>;
|
|
9116
|
+
postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
|
|
8356
9117
|
}
|
|
8357
9118
|
export interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
|
|
8358
9119
|
/**
|
|
@@ -8484,7 +9245,7 @@ export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
|
|
|
8484
9245
|
*/
|
|
8485
9246
|
text: string | string[];
|
|
8486
9247
|
/**
|
|
8487
|
-
* Target
|
|
9248
|
+
* Target langauge to translate to
|
|
8488
9249
|
*/
|
|
8489
9250
|
target_language:
|
|
8490
9251
|
| "asm_Beng"
|
|
@@ -8600,10 +9361,18 @@ export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
|
|
|
8600
9361
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8601
9362
|
*/
|
|
8602
9363
|
role: string;
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
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
|
+
}[];
|
|
8607
9376
|
}[];
|
|
8608
9377
|
functions?: {
|
|
8609
9378
|
name: string;
|
|
@@ -8815,10 +9584,18 @@ export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
|
|
|
8815
9584
|
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
8816
9585
|
*/
|
|
8817
9586
|
role: string;
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
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
|
+
}[];
|
|
8822
9599
|
}[];
|
|
8823
9600
|
functions?: {
|
|
8824
9601
|
name: string;
|
|
@@ -9373,6 +10150,66 @@ export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
|
|
|
9373
10150
|
inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
|
|
9374
10151
|
postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
|
|
9375
10152
|
}
|
|
10153
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
|
|
10154
|
+
multipart: {
|
|
10155
|
+
body?: object;
|
|
10156
|
+
contentType?: string;
|
|
10157
|
+
};
|
|
10158
|
+
}
|
|
10159
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
|
|
10160
|
+
/**
|
|
10161
|
+
* Generated image as Base64 string.
|
|
10162
|
+
*/
|
|
10163
|
+
image?: string;
|
|
10164
|
+
}
|
|
10165
|
+
export 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
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
|
|
10170
|
+
multipart: {
|
|
10171
|
+
body?: object;
|
|
10172
|
+
contentType?: string;
|
|
10173
|
+
};
|
|
10174
|
+
}
|
|
10175
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
|
|
10176
|
+
/**
|
|
10177
|
+
* Generated image as Base64 string.
|
|
10178
|
+
*/
|
|
10179
|
+
image?: string;
|
|
10180
|
+
}
|
|
10181
|
+
export 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
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
|
|
10186
|
+
multipart: {
|
|
10187
|
+
body?: object;
|
|
10188
|
+
contentType?: string;
|
|
10189
|
+
};
|
|
10190
|
+
}
|
|
10191
|
+
export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
|
|
10192
|
+
/**
|
|
10193
|
+
* Generated image as Base64 string.
|
|
10194
|
+
*/
|
|
10195
|
+
image?: string;
|
|
10196
|
+
}
|
|
10197
|
+
export 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
|
+
export declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
|
|
10202
|
+
inputs: ChatCompletionsInput;
|
|
10203
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10204
|
+
}
|
|
10205
|
+
export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
|
|
10206
|
+
inputs: ChatCompletionsInput;
|
|
10207
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10208
|
+
}
|
|
10209
|
+
export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
|
|
10210
|
+
inputs: ChatCompletionsInput;
|
|
10211
|
+
postProcessedOutputs: ChatCompletionsOutput;
|
|
10212
|
+
}
|
|
9376
10213
|
export interface AiModels {
|
|
9377
10214
|
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
9378
10215
|
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
@@ -9391,7 +10228,6 @@ export interface AiModels {
|
|
|
9391
10228
|
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
9392
10229
|
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
9393
10230
|
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
9394
|
-
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
9395
10231
|
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
9396
10232
|
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
9397
10233
|
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
@@ -9458,6 +10294,12 @@ export interface AiModels {
|
|
|
9458
10294
|
"@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
|
|
9459
10295
|
"@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
|
|
9460
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;
|
|
9461
10303
|
}
|
|
9462
10304
|
export type AiOptions = {
|
|
9463
10305
|
/**
|
|
@@ -9483,6 +10325,7 @@ export type AiOptions = {
|
|
|
9483
10325
|
returnRawResponse?: boolean;
|
|
9484
10326
|
prefix?: string;
|
|
9485
10327
|
extraHeaders?: object;
|
|
10328
|
+
signal?: AbortSignal;
|
|
9486
10329
|
};
|
|
9487
10330
|
export type AiModelsSearchParams = {
|
|
9488
10331
|
author?: string;
|
|
@@ -9509,6 +10352,16 @@ export type AiModelsSearchObject = {
|
|
|
9509
10352
|
value: string;
|
|
9510
10353
|
}[];
|
|
9511
10354
|
};
|
|
10355
|
+
export type ChatCompletionsBase = XOR<
|
|
10356
|
+
ChatCompletionsPromptInput,
|
|
10357
|
+
ChatCompletionsMessagesInput
|
|
10358
|
+
>;
|
|
10359
|
+
export type ChatCompletionsInput = XOR<
|
|
10360
|
+
ChatCompletionsBase,
|
|
10361
|
+
{
|
|
10362
|
+
requests: ChatCompletionsBase[];
|
|
10363
|
+
}
|
|
10364
|
+
>;
|
|
9512
10365
|
export interface InferenceUpstreamError extends Error {}
|
|
9513
10366
|
export interface AiInternalError extends Error {}
|
|
9514
10367
|
export type AiModelListType = Record<string, any>;
|
|
@@ -9518,46 +10371,16 @@ export declare abstract class Ai<
|
|
|
9518
10371
|
aiGatewayLogId: string | null;
|
|
9519
10372
|
gateway(gatewayId: string): AiGateway;
|
|
9520
10373
|
/**
|
|
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
|
-
* ```
|
|
10374
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10375
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9546
10376
|
*/
|
|
9547
|
-
aiSearch():
|
|
10377
|
+
aiSearch(): AiSearchNamespace;
|
|
9548
10378
|
/**
|
|
9549
10379
|
* @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(...)`
|
|
10380
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
10381
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9556
10382
|
*
|
|
9557
|
-
*
|
|
9558
|
-
*
|
|
9559
|
-
* @see AiSearchAccountService
|
|
9560
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
10383
|
+
* @param autoragId Instance ID
|
|
9561
10384
|
*/
|
|
9562
10385
|
autorag(autoragId: string): AutoRAG;
|
|
9563
10386
|
run<
|
|
@@ -9716,22 +10539,23 @@ export declare abstract class AiGateway {
|
|
|
9716
10539
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9717
10540
|
}
|
|
9718
10541
|
/**
|
|
9719
|
-
* @deprecated
|
|
9720
|
-
*
|
|
10542
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10543
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9721
10544
|
*/
|
|
9722
10545
|
export interface AutoRAGInternalError extends Error {}
|
|
9723
10546
|
/**
|
|
9724
|
-
* @deprecated
|
|
9725
|
-
*
|
|
10547
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10548
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9726
10549
|
*/
|
|
9727
10550
|
export interface AutoRAGNotFoundError extends Error {}
|
|
9728
10551
|
/**
|
|
9729
|
-
* @deprecated
|
|
10552
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10553
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9730
10554
|
*/
|
|
9731
10555
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
9732
10556
|
/**
|
|
9733
|
-
* @deprecated
|
|
9734
|
-
*
|
|
10557
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10558
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9735
10559
|
*/
|
|
9736
10560
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
9737
10561
|
export type ComparisonFilter = {
|
|
@@ -9744,9 +10568,8 @@ export type CompoundFilter = {
|
|
|
9744
10568
|
filters: ComparisonFilter[];
|
|
9745
10569
|
};
|
|
9746
10570
|
/**
|
|
9747
|
-
* @deprecated
|
|
9748
|
-
*
|
|
9749
|
-
* @see AiSearchSearchRequest
|
|
10571
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10572
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9750
10573
|
*/
|
|
9751
10574
|
export type AutoRagSearchRequest = {
|
|
9752
10575
|
query: string;
|
|
@@ -9763,18 +10586,16 @@ export type AutoRagSearchRequest = {
|
|
|
9763
10586
|
rewrite_query?: boolean;
|
|
9764
10587
|
};
|
|
9765
10588
|
/**
|
|
9766
|
-
* @deprecated
|
|
9767
|
-
*
|
|
9768
|
-
* @see AiSearchChatCompletionsRequest
|
|
10589
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10590
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9769
10591
|
*/
|
|
9770
10592
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9771
10593
|
stream?: boolean;
|
|
9772
10594
|
system_prompt?: string;
|
|
9773
10595
|
};
|
|
9774
10596
|
/**
|
|
9775
|
-
* @deprecated
|
|
9776
|
-
*
|
|
9777
|
-
* @see AiSearchChatCompletionsRequest
|
|
10597
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10598
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9778
10599
|
*/
|
|
9779
10600
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
9780
10601
|
AutoRagAiSearchRequest,
|
|
@@ -9783,9 +10604,8 @@ export type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
9783
10604
|
stream: true;
|
|
9784
10605
|
};
|
|
9785
10606
|
/**
|
|
9786
|
-
* @deprecated
|
|
9787
|
-
*
|
|
9788
|
-
* @see AiSearchSearchResponse
|
|
10607
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10608
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9789
10609
|
*/
|
|
9790
10610
|
export type AutoRagSearchResponse = {
|
|
9791
10611
|
object: "vector_store.search_results.page";
|
|
@@ -9804,9 +10624,8 @@ export type AutoRagSearchResponse = {
|
|
|
9804
10624
|
next_page: string | null;
|
|
9805
10625
|
};
|
|
9806
10626
|
/**
|
|
9807
|
-
* @deprecated
|
|
9808
|
-
*
|
|
9809
|
-
* @see AiSearchListResponse
|
|
10627
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10628
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9810
10629
|
*/
|
|
9811
10630
|
export type AutoRagListResponse = {
|
|
9812
10631
|
id: string;
|
|
@@ -9818,49 +10637,40 @@ export type AutoRagListResponse = {
|
|
|
9818
10637
|
status: string;
|
|
9819
10638
|
}[];
|
|
9820
10639
|
/**
|
|
9821
|
-
* @deprecated
|
|
9822
|
-
*
|
|
10640
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10641
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9823
10642
|
*/
|
|
9824
10643
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9825
10644
|
response: string;
|
|
9826
10645
|
};
|
|
9827
10646
|
/**
|
|
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
|
|
10647
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10648
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9838
10649
|
*/
|
|
9839
10650
|
export declare abstract class AutoRAG {
|
|
9840
10651
|
/**
|
|
9841
|
-
* @deprecated Use
|
|
9842
|
-
*
|
|
10652
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10653
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9843
10654
|
*/
|
|
9844
10655
|
list(): Promise<AutoRagListResponse>;
|
|
9845
10656
|
/**
|
|
9846
|
-
* @deprecated Use
|
|
9847
|
-
*
|
|
9848
|
-
* @see AiSearchInstanceService.search
|
|
10657
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10658
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9849
10659
|
*/
|
|
9850
10660
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9851
10661
|
/**
|
|
9852
|
-
* @deprecated Use
|
|
9853
|
-
*
|
|
10662
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10663
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9854
10664
|
*/
|
|
9855
10665
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9856
10666
|
/**
|
|
9857
|
-
* @deprecated Use
|
|
9858
|
-
*
|
|
10667
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10668
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9859
10669
|
*/
|
|
9860
10670
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9861
10671
|
/**
|
|
9862
|
-
* @deprecated Use
|
|
9863
|
-
*
|
|
10672
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
10673
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
9864
10674
|
*/
|
|
9865
10675
|
aiSearch(
|
|
9866
10676
|
params: AutoRagAiSearchRequest,
|
|
@@ -9985,6 +10795,41 @@ export interface RequestInitCfProperties extends Record<string, unknown> {
|
|
|
9985
10795
|
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
|
|
9986
10796
|
*/
|
|
9987
10797
|
cacheTtlByStatus?: Record<string, number>;
|
|
10798
|
+
/**
|
|
10799
|
+
* Explicit Cache-Control header value to set on the response stored in cache.
|
|
10800
|
+
* This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
|
|
10801
|
+
*
|
|
10802
|
+
* Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
|
|
10803
|
+
* as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
|
|
10804
|
+
*
|
|
10805
|
+
* Can be used together with `cacheTtlByStatus`.
|
|
10806
|
+
*/
|
|
10807
|
+
cacheControl?: string;
|
|
10808
|
+
/**
|
|
10809
|
+
* Whether the response should be eligible for Cache Reserve storage.
|
|
10810
|
+
*/
|
|
10811
|
+
cacheReserveEligible?: boolean;
|
|
10812
|
+
/**
|
|
10813
|
+
* Whether to respect strong ETags (as opposed to weak ETags) from the origin.
|
|
10814
|
+
*/
|
|
10815
|
+
respectStrongEtag?: boolean;
|
|
10816
|
+
/**
|
|
10817
|
+
* Whether to strip ETag headers from the origin response before caching.
|
|
10818
|
+
*/
|
|
10819
|
+
stripEtags?: boolean;
|
|
10820
|
+
/**
|
|
10821
|
+
* Whether to strip Last-Modified headers from the origin response before caching.
|
|
10822
|
+
*/
|
|
10823
|
+
stripLastModified?: boolean;
|
|
10824
|
+
/**
|
|
10825
|
+
* Whether to enable Cache Deception Armor, which protects against web cache
|
|
10826
|
+
* deception attacks by verifying the Content-Type matches the URL extension.
|
|
10827
|
+
*/
|
|
10828
|
+
cacheDeceptionArmor?: boolean;
|
|
10829
|
+
/**
|
|
10830
|
+
* Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
|
|
10831
|
+
*/
|
|
10832
|
+
cacheReserveMinimumFileSize?: number;
|
|
9988
10833
|
scrapeShield?: boolean;
|
|
9989
10834
|
apps?: boolean;
|
|
9990
10835
|
image?: RequestInitCfPropertiesImage;
|
|
@@ -11853,6 +12698,7 @@ export declare namespace CloudflareWorkersModule {
|
|
|
11853
12698
|
constructor(ctx: ExecutionContext, env: Env);
|
|
11854
12699
|
email?(message: ForwardableEmailMessage): void | Promise<void>;
|
|
11855
12700
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12701
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11856
12702
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
11857
12703
|
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
11858
12704
|
tail?(events: TraceItem[]): void | Promise<void>;
|
|
@@ -11873,6 +12719,7 @@ export declare namespace CloudflareWorkersModule {
|
|
|
11873
12719
|
constructor(ctx: DurableObjectState, env: Env);
|
|
11874
12720
|
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
11875
12721
|
fetch?(request: Request): Response | Promise<Response>;
|
|
12722
|
+
connect?(socket: Socket): void | Promise<void>;
|
|
11876
12723
|
webSocketMessage?(
|
|
11877
12724
|
ws: WebSocket,
|
|
11878
12725
|
message: string | ArrayBuffer,
|
|
@@ -12013,17 +12860,6 @@ export interface StreamBinding {
|
|
|
12013
12860
|
* @returns A handle for per-video operations.
|
|
12014
12861
|
*/
|
|
12015
12862
|
video(id: string): StreamVideoHandle;
|
|
12016
|
-
/**
|
|
12017
|
-
* Uploads a new video from a File.
|
|
12018
|
-
* @param file The video file to upload.
|
|
12019
|
-
* @returns The uploaded video details.
|
|
12020
|
-
* @throws {BadRequestError} if the upload parameter is invalid
|
|
12021
|
-
* @throws {QuotaReachedError} if the account storage capacity is exceeded
|
|
12022
|
-
* @throws {MaxFileSizeError} if the file size is too large
|
|
12023
|
-
* @throws {RateLimitedError} if the server received too many requests
|
|
12024
|
-
* @throws {InternalError} if an unexpected error occurs
|
|
12025
|
-
*/
|
|
12026
|
-
upload(file: File): Promise<StreamVideo>;
|
|
12027
12863
|
/**
|
|
12028
12864
|
* Uploads a new video from a provided URL.
|
|
12029
12865
|
* @param url The URL to upload from.
|
|
@@ -12873,6 +13709,9 @@ export declare namespace TailStream {
|
|
|
12873
13709
|
readonly type: "fetch";
|
|
12874
13710
|
readonly statusCode: number;
|
|
12875
13711
|
}
|
|
13712
|
+
interface ConnectEventInfo {
|
|
13713
|
+
readonly type: "connect";
|
|
13714
|
+
}
|
|
12876
13715
|
type EventOutcome =
|
|
12877
13716
|
| "ok"
|
|
12878
13717
|
| "canceled"
|
|
@@ -12903,6 +13742,7 @@ export declare namespace TailStream {
|
|
|
12903
13742
|
readonly scriptVersion?: ScriptVersion;
|
|
12904
13743
|
readonly info:
|
|
12905
13744
|
| FetchEventInfo
|
|
13745
|
+
| ConnectEventInfo
|
|
12906
13746
|
| JsRpcEventInfo
|
|
12907
13747
|
| ScheduledEventInfo
|
|
12908
13748
|
| AlarmEventInfo
|