@zuplo/runtime 7.8.23 → 7.8.25
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/out/esm/chunk-KMX3RLHQ.js +411 -0
- package/out/esm/chunk-KMX3RLHQ.js.map +1 -0
- package/out/esm/index.js +1 -1
- package/out/esm/index.js.map +1 -1
- package/out/esm/mcp-gateway/index.js +1 -1
- package/out/esm/mocks/index.js +1 -1
- package/out/types/index.d.ts +252 -764
- package/package.json +1 -1
- package/out/esm/chunk-OABXMALF.js +0 -425
- package/out/esm/chunk-OABXMALF.js.map +0 -1
- /package/out/esm/{chunk-OABXMALF.js.LEGAL.txt → chunk-KMX3RLHQ.js.LEGAL.txt} +0 -0
package/out/types/index.d.ts
CHANGED
|
@@ -21,123 +21,61 @@ export declare type AiFormat =
|
|
|
21
21
|
| "anthropic-messages";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @deprecated Platform AI Gateway routes use native Anthropic passthrough. This
|
|
28
|
-
* policy is retained for legacy custom routes that explicitly require translation.
|
|
29
|
-
*
|
|
30
|
-
* @hidden
|
|
31
|
-
* @title Anthropic to OpenAI Format Translator
|
|
32
|
-
* @product ai-gateway
|
|
33
|
-
* @param request - The incoming ZuploRequest
|
|
34
|
-
* @param context - The ZuploContext
|
|
35
|
-
* @param options - The policy configuration options
|
|
36
|
-
* @param policyName - The name of the policy instance
|
|
37
|
-
* @returns A modified ZuploRequest with translated body format
|
|
38
|
-
*/
|
|
39
|
-
export declare const AIGatewayAnthropicToOpenAIInboundPolicy: InboundPolicyHandler<AIGatewayAnthropicToOpenAIInboundPolicyOptions>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Options for the AI Gateway Anthropic to OpenAI format translator policy.
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export declare interface AIGatewayAnthropicToOpenAIInboundPolicyOptions {}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Authenticates an AI Gateway Application requests based on Application API Keys
|
|
49
|
-
* using Zuplo's Gateway service.
|
|
50
|
-
* This policy validates API keys against the Api keys bucket, fetches configuration data,
|
|
51
|
-
* caches results for performance, and automatically adds user information to
|
|
52
|
-
* authenticated requests.
|
|
53
|
-
* @hidden
|
|
54
|
-
* @title AI Gateway Authentication
|
|
24
|
+
* Akamai AI Firewall Inbound Policy
|
|
25
|
+
* @title Akamai AI Firewall
|
|
55
26
|
* @product ai-gateway
|
|
56
|
-
* @
|
|
57
|
-
*
|
|
58
|
-
* @param request - The incoming ZuploRequest
|
|
59
|
-
* @param context - The ZuploContext
|
|
60
|
-
* @param unparsedOptions - The policy configuration options
|
|
61
|
-
* @param policyName - The name of the policy instance
|
|
62
|
-
* @returns The authenticated request with user info, or a 401 response if unauthorized
|
|
27
|
+
* @requiresAI
|
|
63
28
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* "name": "ai-gateway-auth",
|
|
69
|
-
* "policyType": "ai-gateway-auth-inbound",
|
|
70
|
-
* "handler": {
|
|
71
|
-
* "export": "AIGatewayAuthInboundPolicy",
|
|
72
|
-
* "module": "$import(@zuplo/runtime)",
|
|
73
|
-
* "options": {
|
|
74
|
-
* "cacheTtlSeconds": 300
|
|
75
|
-
* }
|
|
76
|
-
* }
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
29
|
+
* Detects and blocks malicious AI inputs and outputs via Akamai's AI Firewall
|
|
30
|
+
* service. Settings come from the policy options (configurationId, api-key,
|
|
31
|
+
* applicationId, streamingAccumulation), and presence in the route's
|
|
32
|
+
* `inbound[]` chain is what enables it.
|
|
79
33
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* "export": "AIGatewayAuthInboundPolicy",
|
|
86
|
-
* "module": "$import(@zuplo/runtime)",
|
|
87
|
-
* "options": {
|
|
88
|
-
* "authHeader": "x-api-key",
|
|
89
|
-
* "authScheme": ""
|
|
90
|
-
* }
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* ```
|
|
34
|
+
* Options are validated at request time and invalid options fail closed with a
|
|
35
|
+
* ConfigurationError. Detect-call failures (invalid credentials, rate limits,
|
|
36
|
+
* outages) also fail closed by default, returning a 502 in the route's native
|
|
37
|
+
* error format; set `onError: "allow"` to fail open and prioritize
|
|
38
|
+
* availability over inspection.
|
|
94
39
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* // Access authenticated user data in handler
|
|
98
|
-
* export function myHandler(request: ZuploRequest, context: ZuploContext) {
|
|
99
|
-
* // User is automatically added by AI Gateway policy
|
|
100
|
-
* const user = request.user;
|
|
101
|
-
* context.log.info(`Request from API key: ${user.sub}`);
|
|
40
|
+
* For streaming responses it uses a transform stream that can block content
|
|
41
|
+
* mid-stream if harmful content is detected.
|
|
102
42
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
43
|
+
* Do not add this policy to the inbound chain of an app used as a Smart
|
|
44
|
+
* Router classifier (`classifierAppID`). The firewall would inspect Smart
|
|
45
|
+
* Router's internal classification call as if it were a completion request,
|
|
46
|
+
* and Smart Router fails open on the resulting denial — so this is rejected
|
|
47
|
+
* with a `ConfigurationError` rather than silently degrading classification.
|
|
108
48
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* ```
|
|
49
|
+
* @param request - The ZuploRequest
|
|
50
|
+
* @param context - The ZuploContext
|
|
51
|
+
* @param options - The policy options set in policies.json
|
|
52
|
+
* @param policyName - The name of the policy as set in policies.json
|
|
53
|
+
* @returns A Request or a Response
|
|
115
54
|
*/
|
|
116
|
-
|
|
55
|
+
declare function AIGatewayAkamaiFirewallInboundPolicy(
|
|
117
56
|
request: ZuploRequest,
|
|
118
57
|
context: ZuploContext,
|
|
119
|
-
unparsedOptions:
|
|
58
|
+
unparsedOptions: unknown,
|
|
120
59
|
policyName: string
|
|
121
|
-
): Promise<
|
|
60
|
+
): Promise<ZuploRequest | Response>;
|
|
61
|
+
export { AIGatewayAkamaiFirewallInboundPolicy };
|
|
62
|
+
export { AIGatewayAkamaiFirewallInboundPolicy as AkamaiAIFirewallV2InboundPolicy };
|
|
122
63
|
|
|
123
64
|
/**
|
|
124
|
-
* The options for
|
|
65
|
+
* The options for the Akamai AI Firewall policy.
|
|
125
66
|
* @public
|
|
126
67
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
authHeader?: string;
|
|
136
|
-
/**
|
|
137
|
-
* The scheme used on the header.
|
|
138
|
-
*/
|
|
139
|
-
authScheme?: string;
|
|
68
|
+
declare interface AIGatewayAkamaiFirewallInboundPolicyOptions {
|
|
69
|
+
configurationId: ConfigurationID;
|
|
70
|
+
"api-key": APIKey;
|
|
71
|
+
applicationId?: ApplicationID;
|
|
72
|
+
streamingAccumulation?: StreamingAccumulationSettings;
|
|
73
|
+
endpoints?: ApplicableEndpoints;
|
|
74
|
+
onUnknownShape?: OnUnknownShape;
|
|
75
|
+
onError?: OnFirewallError;
|
|
140
76
|
}
|
|
77
|
+
export { AIGatewayAkamaiFirewallInboundPolicyOptions };
|
|
78
|
+
export { AIGatewayAkamaiFirewallInboundPolicyOptions as AkamaiAIFirewallV2PolicyOptions };
|
|
141
79
|
|
|
142
80
|
/**
|
|
143
81
|
* Authenticates requests to an AI Gateway endpoint with application API keys.
|
|
@@ -180,9 +118,9 @@ export declare interface AIGatewayAuthInboundPolicyOptions {
|
|
|
180
118
|
* // policies.json - Authenticate an AI Gateway route
|
|
181
119
|
* {
|
|
182
120
|
* "name": "ai-gateway-auth",
|
|
183
|
-
* "policyType": "ai-gateway-auth
|
|
121
|
+
* "policyType": "ai-gateway-auth",
|
|
184
122
|
* "handler": {
|
|
185
|
-
* "export": "
|
|
123
|
+
* "export": "AIGatewayAuthInboundPolicy",
|
|
186
124
|
* "module": "$import(@zuplo/runtime)",
|
|
187
125
|
* "options": {
|
|
188
126
|
* "cacheTtlSeconds": 300
|
|
@@ -196,7 +134,7 @@ export declare interface AIGatewayAuthInboundPolicyOptions {
|
|
|
196
134
|
* // Accept an app key from a custom header
|
|
197
135
|
* {
|
|
198
136
|
* "handler": {
|
|
199
|
-
* "export": "
|
|
137
|
+
* "export": "AIGatewayAuthInboundPolicy",
|
|
200
138
|
* "module": "$import(@zuplo/runtime)",
|
|
201
139
|
* "options": {
|
|
202
140
|
* "authHeader": "x-api-key",
|
|
@@ -207,18 +145,20 @@ export declare interface AIGatewayAuthInboundPolicyOptions {
|
|
|
207
145
|
* ```
|
|
208
146
|
*
|
|
209
147
|
*/
|
|
210
|
-
|
|
148
|
+
declare function AIGatewayAuthInboundPolicy(
|
|
211
149
|
request: ZuploRequest,
|
|
212
150
|
context: ZuploContext,
|
|
213
|
-
unparsedOptions:
|
|
151
|
+
unparsedOptions: AIGatewayAuthInboundPolicyOptions,
|
|
214
152
|
policyName: string
|
|
215
153
|
): Promise<Response | ZuploRequest<RequestGeneric>>;
|
|
154
|
+
export { AIGatewayAuthInboundPolicy };
|
|
155
|
+
export { AIGatewayAuthInboundPolicy as AIGatewayAuthV2InboundPolicy };
|
|
216
156
|
|
|
217
157
|
/**
|
|
218
158
|
* The options for this policy.
|
|
219
159
|
* @public
|
|
220
160
|
*/
|
|
221
|
-
|
|
161
|
+
declare interface AIGatewayAuthInboundPolicyOptions {
|
|
222
162
|
/**
|
|
223
163
|
* The time to cache authentication results for a particular key. Higher values will decrease latency. Cached results will be valid until the cache expires even in the event the key is deleted, etc.
|
|
224
164
|
*/
|
|
@@ -236,6 +176,8 @@ export declare interface AIGatewayAuthV2InboundPolicyOptions {
|
|
|
236
176
|
*/
|
|
237
177
|
credentialPassthrough?: boolean;
|
|
238
178
|
}
|
|
179
|
+
export { AIGatewayAuthInboundPolicyOptions };
|
|
180
|
+
export { AIGatewayAuthInboundPolicyOptions as AIGatewayAuthV2InboundPolicyOptions };
|
|
239
181
|
|
|
240
182
|
/**
|
|
241
183
|
* An AI Gateway capability that can have a resolved model selection.
|
|
@@ -262,7 +204,7 @@ export declare type AIGatewayCapability =
|
|
|
262
204
|
* gateway root.
|
|
263
205
|
*
|
|
264
206
|
* Place this policy on AI Gateway routes after optional authentication and
|
|
265
|
-
* optional `ai-gateway-configuration-loader-
|
|
207
|
+
* optional `ai-gateway-configuration-loader-inbound`. When either of those
|
|
266
208
|
* already populated the app-configuration channel, this policy reuses it.
|
|
267
209
|
* Otherwise it loads the configuration with the route's `app_id` path
|
|
268
210
|
* parameter. Applications select from policies pre-declared by the gateway.
|
|
@@ -277,11 +219,11 @@ export declare type AIGatewayCapability =
|
|
|
277
219
|
* @product ai-gateway
|
|
278
220
|
* @requiresAI
|
|
279
221
|
*/
|
|
280
|
-
|
|
222
|
+
declare class AIGatewayConfigurationExecutorInboundPolicy extends InboundPolicy<AIGatewayConfigurationExecutorInboundPolicyOptions> {
|
|
281
223
|
#private;
|
|
282
|
-
static readonly policyType = "ai-gateway-configuration-executor
|
|
224
|
+
static readonly policyType = "ai-gateway-configuration-executor";
|
|
283
225
|
constructor(
|
|
284
|
-
options:
|
|
226
|
+
options: AIGatewayConfigurationExecutorInboundPolicyOptions,
|
|
285
227
|
policyName: string
|
|
286
228
|
);
|
|
287
229
|
handler(
|
|
@@ -295,25 +237,29 @@ export declare class AIGatewayConfigurationExecutorV2InboundPolicy extends Inbou
|
|
|
295
237
|
private getConsumerSub;
|
|
296
238
|
private createQuotaExceededResponse;
|
|
297
239
|
}
|
|
240
|
+
export { AIGatewayConfigurationExecutorInboundPolicy };
|
|
241
|
+
export { AIGatewayConfigurationExecutorInboundPolicy as AIGatewayConfigurationExecutorV2InboundPolicy };
|
|
298
242
|
|
|
299
243
|
/**
|
|
300
244
|
* Options for loading each application's AI Gateway configuration and running its inbound policy chain.
|
|
301
245
|
* @public
|
|
302
246
|
*/
|
|
303
|
-
|
|
247
|
+
declare interface AIGatewayConfigurationExecutorInboundPolicyOptions {
|
|
304
248
|
/**
|
|
305
|
-
* The time in seconds to cache app configurations loaded by app_id. Defaults to 10 seconds when omitted. Higher values decrease latency; lower values pick up portal changes sooner. Cached results remain valid until the cache expires even if the configuration changes in the portal. This cache is only used when neither ai-gateway-auth-
|
|
249
|
+
* The time in seconds to cache app configurations loaded by app_id. Defaults to 10 seconds when omitted. Higher values decrease latency; lower values pick up portal changes sooner. Cached results remain valid until the cache expires even if the configuration changes in the portal. This cache is only used when neither ai-gateway-auth-inbound nor ai-gateway-configuration-loader-inbound already loaded the configuration for the request.
|
|
306
250
|
*/
|
|
307
251
|
cacheTtlSeconds?: number;
|
|
308
252
|
}
|
|
253
|
+
export { AIGatewayConfigurationExecutorInboundPolicyOptions };
|
|
254
|
+
export { AIGatewayConfigurationExecutorInboundPolicyOptions as AIGatewayConfigurationExecutorV2InboundPolicyOptions };
|
|
309
255
|
|
|
310
256
|
/**
|
|
311
257
|
* Loads the AI Gateway app configuration for the request into the
|
|
312
258
|
* request-scoped channel and does nothing else.
|
|
313
259
|
*
|
|
314
260
|
* Place this policy on AI Gateway routes before
|
|
315
|
-
* `ai-gateway-configuration-executor-
|
|
316
|
-
* loading separated from chain execution. When `ai-gateway-auth-
|
|
261
|
+
* `ai-gateway-configuration-executor-inbound` when you want configuration
|
|
262
|
+
* loading separated from chain execution. When `ai-gateway-auth-inbound`
|
|
317
263
|
* already populated the channel, this policy reuses it. Otherwise it loads
|
|
318
264
|
* the configuration with the route's `app_id` path parameter.
|
|
319
265
|
*
|
|
@@ -324,11 +270,11 @@ export declare interface AIGatewayConfigurationExecutorV2InboundPolicyOptions {
|
|
|
324
270
|
* @product ai-gateway
|
|
325
271
|
* @requiresAI
|
|
326
272
|
*/
|
|
327
|
-
|
|
273
|
+
declare class AIGatewayConfigurationLoaderInboundPolicy extends InboundPolicy<AIGatewayConfigurationLoaderInboundPolicyOptions> {
|
|
328
274
|
#private;
|
|
329
|
-
static readonly policyType = "ai-gateway-configuration-loader
|
|
275
|
+
static readonly policyType = "ai-gateway-configuration-loader";
|
|
330
276
|
constructor(
|
|
331
|
-
options:
|
|
277
|
+
options: AIGatewayConfigurationLoaderInboundPolicyOptions,
|
|
332
278
|
policyName: string
|
|
333
279
|
);
|
|
334
280
|
handler(
|
|
@@ -336,17 +282,21 @@ export declare class AIGatewayConfigurationLoaderV2InboundPolicy extends Inbound
|
|
|
336
282
|
context: ZuploContext
|
|
337
283
|
): Promise<ZuploRequest | Response>;
|
|
338
284
|
}
|
|
285
|
+
export { AIGatewayConfigurationLoaderInboundPolicy };
|
|
286
|
+
export { AIGatewayConfigurationLoaderInboundPolicy as AIGatewayConfigurationLoaderV2InboundPolicy };
|
|
339
287
|
|
|
340
288
|
/**
|
|
341
289
|
* Options for loading each application's AI Gateway configuration into the request-scoped channel.
|
|
342
290
|
* @public
|
|
343
291
|
*/
|
|
344
|
-
|
|
292
|
+
declare interface AIGatewayConfigurationLoaderInboundPolicyOptions {
|
|
345
293
|
/**
|
|
346
|
-
* The time in seconds to cache app configurations loaded by app_id. Defaults to 10 seconds when omitted. Higher values decrease latency; lower values pick up portal changes sooner. Cached results remain valid until the cache expires even if the configuration changes in the portal. When ai-gateway-auth-
|
|
294
|
+
* The time in seconds to cache app configurations loaded by app_id. Defaults to 10 seconds when omitted. Higher values decrease latency; lower values pick up portal changes sooner. Cached results remain valid until the cache expires even if the configuration changes in the portal. When ai-gateway-auth-inbound already loaded the configuration for the request, this cache is not used.
|
|
347
295
|
*/
|
|
348
296
|
cacheTtlSeconds?: number;
|
|
349
297
|
}
|
|
298
|
+
export { AIGatewayConfigurationLoaderInboundPolicyOptions };
|
|
299
|
+
export { AIGatewayConfigurationLoaderInboundPolicyOptions as AIGatewayConfigurationLoaderV2InboundPolicyOptions };
|
|
350
300
|
|
|
351
301
|
/**
|
|
352
302
|
* Data Loss Prevention (DLP) Inbound Policy for the AI Gateway
|
|
@@ -404,8 +354,8 @@ export declare interface AIGatewayDlpInboundPolicyOptions {
|
|
|
404
354
|
*/
|
|
405
355
|
scanToolArguments?: boolean;
|
|
406
356
|
streaming?: DlpStreamingSettings;
|
|
407
|
-
endpoints?:
|
|
408
|
-
onUnknownShape?:
|
|
357
|
+
endpoints?: ApplicableEndpoints_2;
|
|
358
|
+
onUnknownShape?: OnUnknownShape_2;
|
|
409
359
|
onError?: OnEngineError;
|
|
410
360
|
/**
|
|
411
361
|
* The detection engine. Only `builtin` (in-gateway regex + checksum detection with context-word scoring; no data egress) is available today. Declaring the discriminator now keeps future engines an additive, non-breaking change.
|
|
@@ -440,24 +390,87 @@ export declare interface AIGatewayDlpInboundPolicyOptions {
|
|
|
440
390
|
* }
|
|
441
391
|
* ```
|
|
442
392
|
*/
|
|
443
|
-
|
|
393
|
+
declare class AIGatewayFallbackModelInboundPolicy extends InboundPolicy<AIGatewayFallbackModelInboundPolicyOptions> {
|
|
444
394
|
#private;
|
|
445
|
-
static readonly policyType = "ai-gateway-fallback-model
|
|
395
|
+
static readonly policyType = "ai-gateway-fallback-model";
|
|
446
396
|
constructor(
|
|
447
|
-
options:
|
|
397
|
+
options: AIGatewayFallbackModelInboundPolicyOptions,
|
|
448
398
|
policyName: string
|
|
449
399
|
);
|
|
450
400
|
handler(request: ZuploRequest, context: ZuploContext): Promise<ZuploRequest>;
|
|
451
401
|
}
|
|
402
|
+
export { AIGatewayFallbackModelInboundPolicy };
|
|
403
|
+
export { AIGatewayFallbackModelInboundPolicy as AIGatewayFallbackModelV2InboundPolicy };
|
|
452
404
|
|
|
453
405
|
/**
|
|
454
406
|
* Options for adding failure and quota fallbacks to an existing AI Gateway model selection.
|
|
455
407
|
* @public
|
|
456
408
|
*/
|
|
457
|
-
|
|
409
|
+
declare interface AIGatewayFallbackModelInboundPolicyOptions {
|
|
458
410
|
models: FallbackModels;
|
|
459
411
|
fallbackTimeoutSeconds?: FallbackTimeoutSeconds;
|
|
460
412
|
}
|
|
413
|
+
export { AIGatewayFallbackModelInboundPolicyOptions };
|
|
414
|
+
export { AIGatewayFallbackModelInboundPolicyOptions as AIGatewayFallbackModelV2InboundPolicyOptions };
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Galileo Tracing Inbound Policy
|
|
418
|
+
* @title Galileo Tracing
|
|
419
|
+
* @product ai-gateway
|
|
420
|
+
* @requiresAI
|
|
421
|
+
*
|
|
422
|
+
* Traces both streaming and non-streaming AI Gateway responses to Galileo's LLM
|
|
423
|
+
* observability platform, creating complete traces with workflow and LLM spans
|
|
424
|
+
* when responses complete. Credentials (apiKey, projectId, logStreamId, baseUrl)
|
|
425
|
+
* come from the policy options. The authenticated app configuration is used
|
|
426
|
+
* only to label the model; presence in the route's chain is what enables the
|
|
427
|
+
* policy.
|
|
428
|
+
*
|
|
429
|
+
* For streaming responses, it clones the response stream and processes it in
|
|
430
|
+
* the background using `waitUntil`, allowing the original stream to pass through
|
|
431
|
+
* unmodified while still capturing the complete content for tracing.
|
|
432
|
+
*
|
|
433
|
+
* @param request - The ZuploRequest
|
|
434
|
+
* @param context - The ZuploContext
|
|
435
|
+
* @param options - The policy options set in policies.json
|
|
436
|
+
* @param policyName - The name of the policy as set in policies.json
|
|
437
|
+
* @returns A Request or a Response
|
|
438
|
+
*/
|
|
439
|
+
declare function AIGatewayGalileoTracingInboundPolicy(
|
|
440
|
+
request: ZuploRequest,
|
|
441
|
+
context: ZuploContext,
|
|
442
|
+
options: AIGatewayGalileoTracingInboundPolicyOptions,
|
|
443
|
+
_policyName: string
|
|
444
|
+
): Promise<ZuploRequest | Response>;
|
|
445
|
+
export { AIGatewayGalileoTracingInboundPolicy };
|
|
446
|
+
export { AIGatewayGalileoTracingInboundPolicy as GalileoTracingV2InboundPolicy };
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Track AI Gateway requests and responses using Galileo's LLM observability platform.
|
|
450
|
+
* @public
|
|
451
|
+
*/
|
|
452
|
+
declare interface AIGatewayGalileoTracingInboundPolicyOptions {
|
|
453
|
+
/**
|
|
454
|
+
* The Galileo API key for authentication.
|
|
455
|
+
*/
|
|
456
|
+
apiKey: string;
|
|
457
|
+
/**
|
|
458
|
+
* The Galileo project ID (UUID) for organizing traces.
|
|
459
|
+
*/
|
|
460
|
+
projectId: string;
|
|
461
|
+
/**
|
|
462
|
+
* The Galileo log stream ID (UUID) for organizing traces.
|
|
463
|
+
*/
|
|
464
|
+
logStreamId: string;
|
|
465
|
+
/**
|
|
466
|
+
* The base URL for the Galileo API (optional, defaults to https://api.galileo.ai).
|
|
467
|
+
*/
|
|
468
|
+
baseUrl?: string;
|
|
469
|
+
endpoints?: ApplicableEndpoints_3;
|
|
470
|
+
onUnknownShape?: OnUnknownShape_3;
|
|
471
|
+
}
|
|
472
|
+
export { AIGatewayGalileoTracingInboundPolicyOptions };
|
|
473
|
+
export { AIGatewayGalileoTracingInboundPolicyOptions as GalileoTracingV2PolicyOptions };
|
|
461
474
|
|
|
462
475
|
/**
|
|
463
476
|
* Handler that routes AI/LLM requests through Zuplo's LLM Translation Layer.
|
|
@@ -569,109 +582,6 @@ export declare interface AIGatewayInternalOnlyInboundPolicyOptions {}
|
|
|
569
582
|
|
|
570
583
|
/* Excluded from this release type: AIGatewayMeterIncrements */
|
|
571
584
|
|
|
572
|
-
/**
|
|
573
|
-
* AI Gateway Metering policy for quota enforcement.
|
|
574
|
-
* This policy is meant to be used as singleton.
|
|
575
|
-
* You should only have one for your entire Gateway.
|
|
576
|
-
*
|
|
577
|
-
* The AI Gateway authentication policy provides the application's
|
|
578
|
-
* configuration and must run earlier on the route.
|
|
579
|
-
*
|
|
580
|
-
* Metering runs at most once per request: when the policy appears more than
|
|
581
|
-
* once in the effective chain (for example repeated
|
|
582
|
-
* `configuration.inboundPolicyChain` entries, or a static route entry plus a
|
|
583
|
-
* chain entry), only the first occurrence checks quotas and registers the
|
|
584
|
-
* meter-increment hook, so usage is never billed twice.
|
|
585
|
-
*
|
|
586
|
-
* @title AI Gateway Metering
|
|
587
|
-
* @product ai-gateway
|
|
588
|
-
* @hidden
|
|
589
|
-
* @param request - The ZuploRequest
|
|
590
|
-
* @param context - The ZuploContext
|
|
591
|
-
* @param options - The policy options set in policies.json
|
|
592
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
593
|
-
* @returns A Request or a Response
|
|
594
|
-
*/
|
|
595
|
-
export declare class AIGatewayMeteringInboundPolicy extends InboundPolicy<AIGatewayMeteringInboundPolicyOptions> {
|
|
596
|
-
static readonly policyType = "ai-gateway-metering";
|
|
597
|
-
/**
|
|
598
|
-
* Set the meter increments for the current request.
|
|
599
|
-
*
|
|
600
|
-
* @param context - The ZuploContext
|
|
601
|
-
* @param increments - The increments to set.
|
|
602
|
-
*/
|
|
603
|
-
static setIncrements(
|
|
604
|
-
context: ZuploContext,
|
|
605
|
-
increments: AIGatewayMeterIncrements
|
|
606
|
-
): void;
|
|
607
|
-
static getIncrements(context: ZuploContext): AIGatewayMeterIncrements;
|
|
608
|
-
/**
|
|
609
|
-
* Record the global quota fallback models for the current request. Set by the
|
|
610
|
-
* metering policy when a quota is exceeded and a fallback is configured; read
|
|
611
|
-
* by the LLM translation handler, which routes to the capability-appropriate
|
|
612
|
-
* model instead of the (over-budget) primary.
|
|
613
|
-
*
|
|
614
|
-
* @param context - The ZuploContext
|
|
615
|
-
* @param quotaFallback - The validated quota fallback models.
|
|
616
|
-
*/
|
|
617
|
-
static setQuotaFallback(
|
|
618
|
-
context: ZuploContext,
|
|
619
|
-
quotaFallback: QuotaFallbackModels
|
|
620
|
-
): void;
|
|
621
|
-
static getQuotaFallback(
|
|
622
|
-
context: ZuploContext
|
|
623
|
-
): QuotaFallbackModels | undefined;
|
|
624
|
-
handler(
|
|
625
|
-
request: ZuploRequest,
|
|
626
|
-
context: ZuploContext
|
|
627
|
-
): Promise<Response | ZuploRequest<RequestGeneric>>;
|
|
628
|
-
private fetchCurrentMeters;
|
|
629
|
-
/**
|
|
630
|
-
* The capability a request targets, derived from its path, or `undefined` for
|
|
631
|
-
* paths that do not support quota fallback (e.g. `/v1/responses`, which the LLM
|
|
632
|
-
* handler serves without the fallback chain). Used to decide whether a quota
|
|
633
|
-
* fallback actually applies to *this* request.
|
|
634
|
-
*/
|
|
635
|
-
private requestCapability;
|
|
636
|
-
/**
|
|
637
|
-
* Validate and return the configured quota fallback when it applies to *this*
|
|
638
|
-
* request's capability, or `undefined` otherwise. A resolved selection is
|
|
639
|
-
* already validated and returns a presence-only marker; legacy configuration
|
|
640
|
-
* is customer-authored and validated through Zod before use. Returning
|
|
641
|
-
* `undefined` blocks the request with a 429, so a fallback is counted only
|
|
642
|
-
* when the handler can serve the request with it.
|
|
643
|
-
*/
|
|
644
|
-
private resolveQuotaFallback;
|
|
645
|
-
private checkHierarchicalQuotaLimits;
|
|
646
|
-
/**
|
|
647
|
-
* Increment meters via API. Can be used by providers for streaming responses.
|
|
648
|
-
*
|
|
649
|
-
* @param configurationId - The AI Gateway configuration ID
|
|
650
|
-
* @param increments - The meter increments to send
|
|
651
|
-
* @param context - The ZuploContext for logging
|
|
652
|
-
* @returns Promise that resolves when meters are incremented
|
|
653
|
-
*/
|
|
654
|
-
static incrementMeters(
|
|
655
|
-
configurationId: string,
|
|
656
|
-
increments: AIGatewayMeterIncrements,
|
|
657
|
-
context: ZuploContext
|
|
658
|
-
): Promise<void>;
|
|
659
|
-
private checkWarnings;
|
|
660
|
-
private checkQuotaWarning;
|
|
661
|
-
private createHierarchicalQuotaExceededResponse;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* The options for this policy.
|
|
666
|
-
* @public
|
|
667
|
-
*/
|
|
668
|
-
export declare interface AIGatewayMeteringInboundPolicyOptions {
|
|
669
|
-
/**
|
|
670
|
-
* If true, the policy will throw an error in the event there is a problem connecting to the metering service.
|
|
671
|
-
*/
|
|
672
|
-
throwOnFailure?: boolean;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
585
|
/**
|
|
676
586
|
* Meters AI Gateway usage and enforces limits configured by the application.
|
|
677
587
|
*
|
|
@@ -687,11 +597,11 @@ export declare interface AIGatewayMeteringInboundPolicyOptions {
|
|
|
687
597
|
* @param policyName - The name of the policy as set in policies.json
|
|
688
598
|
* @returns The request, or a 429 response when a limit is exceeded
|
|
689
599
|
*/
|
|
690
|
-
|
|
600
|
+
declare class AIGatewayMeteringInboundPolicy extends InboundPolicy<AIGatewayMeteringInboundPolicyOptions> {
|
|
691
601
|
#private;
|
|
692
|
-
static readonly policyType = "ai-gateway-metering
|
|
602
|
+
static readonly policyType = "ai-gateway-metering";
|
|
693
603
|
constructor(
|
|
694
|
-
options:
|
|
604
|
+
options: AIGatewayMeteringInboundPolicyOptions,
|
|
695
605
|
policyName: string
|
|
696
606
|
);
|
|
697
607
|
/** Set the meter increments accumulated for this request. */
|
|
@@ -727,12 +637,14 @@ export declare class AIGatewayMeteringV2InboundPolicy extends InboundPolicy<AIGa
|
|
|
727
637
|
private findViolation;
|
|
728
638
|
private createQuotaExceededResponse;
|
|
729
639
|
}
|
|
640
|
+
export { AIGatewayMeteringInboundPolicy };
|
|
641
|
+
export { AIGatewayMeteringInboundPolicy as AIGatewayMeteringV2InboundPolicy };
|
|
730
642
|
|
|
731
643
|
/**
|
|
732
644
|
* Options for metering AI Gateway usage and enforcing request-time limits.
|
|
733
645
|
* @public
|
|
734
646
|
*/
|
|
735
|
-
|
|
647
|
+
declare interface AIGatewayMeteringInboundPolicyOptions {
|
|
736
648
|
/**
|
|
737
649
|
* Throw when the metering service is unavailable instead of failing open.
|
|
738
650
|
*/
|
|
@@ -770,31 +682,35 @@ export declare interface AIGatewayMeteringV2InboundPolicyOptions {
|
|
|
770
682
|
requests?: QuotaLimit;
|
|
771
683
|
};
|
|
772
684
|
}
|
|
685
|
+
export { AIGatewayMeteringInboundPolicyOptions };
|
|
686
|
+
export { AIGatewayMeteringInboundPolicyOptions as AIGatewayMeteringV2InboundPolicyOptions };
|
|
773
687
|
|
|
774
688
|
/**
|
|
775
689
|
* Usage-limit settings accepted by the `options.limits` policy option.
|
|
776
690
|
*/
|
|
777
|
-
|
|
778
|
-
costs?:
|
|
779
|
-
tokens?:
|
|
780
|
-
requests?:
|
|
691
|
+
declare interface AIGatewayMeteringLimitOverrides {
|
|
692
|
+
costs?: AIGatewayMeteringMeterLimitOverrides;
|
|
693
|
+
tokens?: AIGatewayMeteringMeterLimitOverrides;
|
|
694
|
+
requests?: AIGatewayMeteringMeterLimitOverrides;
|
|
781
695
|
}
|
|
696
|
+
export { AIGatewayMeteringLimitOverrides };
|
|
697
|
+
export { AIGatewayMeteringLimitOverrides as AIGatewayMeteringV2LimitOverrides };
|
|
782
698
|
|
|
783
699
|
/** Daily and monthly settings for one usage meter. */
|
|
784
|
-
declare interface
|
|
785
|
-
daily?:
|
|
786
|
-
monthly?:
|
|
700
|
+
declare interface AIGatewayMeteringMeterLimitOverrides {
|
|
701
|
+
daily?: AIGatewayMeteringPeriodLimitOverride;
|
|
702
|
+
monthly?: AIGatewayMeteringPeriodLimitOverride;
|
|
787
703
|
}
|
|
788
704
|
|
|
789
705
|
/** Settings for one usage-limit period. */
|
|
790
|
-
declare interface
|
|
706
|
+
declare interface AIGatewayMeteringPeriodLimitOverride {
|
|
791
707
|
enabled?: boolean;
|
|
792
708
|
limit?: number;
|
|
793
|
-
warning?:
|
|
709
|
+
warning?: AIGatewayMeteringWarningLimitOverride;
|
|
794
710
|
}
|
|
795
711
|
|
|
796
712
|
/** Warning settings for one usage-limit period. */
|
|
797
|
-
declare interface
|
|
713
|
+
declare interface AIGatewayMeteringWarningLimitOverride {
|
|
798
714
|
enabled?: boolean;
|
|
799
715
|
threshold?: number;
|
|
800
716
|
}
|
|
@@ -825,11 +741,11 @@ declare interface AIGatewayMeteringV2WarningLimitOverride {
|
|
|
825
741
|
* }
|
|
826
742
|
* ```
|
|
827
743
|
*/
|
|
828
|
-
|
|
744
|
+
declare class AIGatewayModelFilteringInboundPolicy extends InboundPolicy<AIGatewayModelFilteringInboundPolicyOptions> {
|
|
829
745
|
#private;
|
|
830
|
-
static readonly policyType = "ai-gateway-model-filtering
|
|
746
|
+
static readonly policyType = "ai-gateway-model-filtering";
|
|
831
747
|
constructor(
|
|
832
|
-
options:
|
|
748
|
+
options: AIGatewayModelFilteringInboundPolicyOptions,
|
|
833
749
|
policyName: string
|
|
834
750
|
);
|
|
835
751
|
handler(
|
|
@@ -837,14 +753,18 @@ export declare class AIGatewayModelFilteringV2InboundPolicy extends InboundPolic
|
|
|
837
753
|
context: ZuploContext
|
|
838
754
|
): Promise<ZuploRequest | Response>;
|
|
839
755
|
}
|
|
756
|
+
export { AIGatewayModelFilteringInboundPolicy };
|
|
757
|
+
export { AIGatewayModelFilteringInboundPolicy as AIGatewayModelFilteringV2InboundPolicy };
|
|
840
758
|
|
|
841
759
|
/**
|
|
842
760
|
* Options for allowing or blocking providerName/model references for each AI Gateway capability.
|
|
843
761
|
* @public
|
|
844
762
|
*/
|
|
845
|
-
|
|
763
|
+
declare interface AIGatewayModelFilteringInboundPolicyOptions {
|
|
846
764
|
models: Models;
|
|
847
765
|
}
|
|
766
|
+
export { AIGatewayModelFilteringInboundPolicyOptions };
|
|
767
|
+
export { AIGatewayModelFilteringInboundPolicyOptions as AIGatewayModelFilteringV2InboundPolicyOptions };
|
|
848
768
|
|
|
849
769
|
/**
|
|
850
770
|
* Catalog information about an AI Gateway model.
|
|
@@ -970,29 +890,62 @@ export declare const AIGatewayModels: {
|
|
|
970
890
|
};
|
|
971
891
|
|
|
972
892
|
/**
|
|
973
|
-
*
|
|
974
|
-
*
|
|
893
|
+
* Comet Opik Tracing Inbound Policy
|
|
894
|
+
* @title Comet Opik Tracing
|
|
895
|
+
* @product ai-gateway
|
|
896
|
+
* @requiresAI
|
|
975
897
|
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
898
|
+
* Traces both streaming and non-streaming AI Gateway responses to Comet Opik,
|
|
899
|
+
* creating traces when requests start and spans when responses complete.
|
|
900
|
+
* Credentials (apiKey, projectName, workspace, baseUrl) come from the policy
|
|
901
|
+
* options. The authenticated app configuration is used only to label the
|
|
902
|
+
* model; presence in the route's chain is what enables the policy.
|
|
978
903
|
*
|
|
979
|
-
*
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
* @param request - The
|
|
904
|
+
* For streaming responses, it clones the response stream and processes it in
|
|
905
|
+
* the background using `waitUntil`, allowing the original stream to pass through
|
|
906
|
+
* unmodified while still capturing the complete content for tracing.
|
|
907
|
+
*
|
|
908
|
+
* @param request - The ZuploRequest
|
|
984
909
|
* @param context - The ZuploContext
|
|
985
|
-
* @param options - The policy
|
|
986
|
-
* @param policyName - The name of the policy
|
|
987
|
-
* @returns A
|
|
910
|
+
* @param options - The policy options set in policies.json
|
|
911
|
+
* @param policyName - The name of the policy as set in policies.json
|
|
912
|
+
* @returns A Request or a Response
|
|
988
913
|
*/
|
|
989
|
-
|
|
914
|
+
declare function AIGatewayOpikTracingInboundPolicy(
|
|
915
|
+
request: ZuploRequest,
|
|
916
|
+
context: ZuploContext,
|
|
917
|
+
options: AIGatewayOpikTracingInboundPolicyOptions,
|
|
918
|
+
_policyName: string
|
|
919
|
+
): Promise<ZuploRequest | Response>;
|
|
920
|
+
export { AIGatewayOpikTracingInboundPolicy };
|
|
921
|
+
export { AIGatewayOpikTracingInboundPolicy as CometOpikTracingV2InboundPolicy };
|
|
990
922
|
|
|
991
923
|
/**
|
|
992
|
-
*
|
|
924
|
+
* Track AI Gateway requests and responses using Comet Opik's LLM observability platform.
|
|
993
925
|
* @public
|
|
994
926
|
*/
|
|
995
|
-
|
|
927
|
+
declare interface AIGatewayOpikTracingInboundPolicyOptions {
|
|
928
|
+
/**
|
|
929
|
+
* The Comet Opik API key for authentication.
|
|
930
|
+
*/
|
|
931
|
+
apiKey: string;
|
|
932
|
+
/**
|
|
933
|
+
* The Comet Opik project name for organizing traces.
|
|
934
|
+
*/
|
|
935
|
+
projectName: string;
|
|
936
|
+
/**
|
|
937
|
+
* The Comet Opik workspace name.
|
|
938
|
+
*/
|
|
939
|
+
workspace: string;
|
|
940
|
+
/**
|
|
941
|
+
* The base URL for the Comet Opik API (optional, defaults to https://www.comet.com/opik/api).
|
|
942
|
+
*/
|
|
943
|
+
baseUrl?: string;
|
|
944
|
+
endpoints?: ApplicableEndpoints_4;
|
|
945
|
+
onUnknownShape?: OnUnknownShape_4;
|
|
946
|
+
}
|
|
947
|
+
export { AIGatewayOpikTracingInboundPolicyOptions };
|
|
948
|
+
export { AIGatewayOpikTracingInboundPolicyOptions as CometOpikTracingV2PolicyOptions };
|
|
996
949
|
|
|
997
950
|
/**
|
|
998
951
|
* Prompt Injection Protection Policy
|
|
@@ -1068,7 +1021,7 @@ export declare function AIGatewayPromptInjectionPolicy(
|
|
|
1068
1021
|
* @public
|
|
1069
1022
|
*/
|
|
1070
1023
|
export declare interface AIGatewayPromptInjectionPolicyOptions {
|
|
1071
|
-
apiKey?:
|
|
1024
|
+
apiKey?: APIKey_2;
|
|
1072
1025
|
appId?: ClassifierAppID;
|
|
1073
1026
|
execution?: Execution;
|
|
1074
1027
|
recentMessageCount?: RecentMessageCount;
|
|
@@ -1076,8 +1029,8 @@ export declare interface AIGatewayPromptInjectionPolicyOptions {
|
|
|
1076
1029
|
classifierPrompt?: ClassifierPrompt;
|
|
1077
1030
|
baseUrl?: BaseURL;
|
|
1078
1031
|
timeoutMs?: ClassifierTimeoutMs;
|
|
1079
|
-
endpoints?:
|
|
1080
|
-
onUnknownShape?:
|
|
1032
|
+
endpoints?: ApplicableEndpoints_5;
|
|
1033
|
+
onUnknownShape?: OnUnknownShape_5;
|
|
1081
1034
|
onError?: OnClassifierError;
|
|
1082
1035
|
}
|
|
1083
1036
|
|
|
@@ -1159,68 +1112,6 @@ export declare interface AIGatewayRouting {
|
|
|
1159
1112
|
embeddings?: AIGatewayRouteTarget;
|
|
1160
1113
|
}
|
|
1161
1114
|
|
|
1162
|
-
/**
|
|
1163
|
-
* AI Gateway Semantic Cache policy for caching chat completion responses
|
|
1164
|
-
* based on semantic similarity of user messages.
|
|
1165
|
-
*
|
|
1166
|
-
* This policy wraps the SemanticCacheInboundPolicy and applies it specifically
|
|
1167
|
-
* for AI Gateway chat completion endpoints. It uses configuration from the
|
|
1168
|
-
* user's metadata to determine whether caching should be applied and with
|
|
1169
|
-
* what tolerance.
|
|
1170
|
-
*
|
|
1171
|
-
* @title AI Gateway Semantic Cache
|
|
1172
|
-
* @product ai-gateway
|
|
1173
|
-
* @hidden
|
|
1174
|
-
* @requiresAI
|
|
1175
|
-
* @param request - The ZuploRequest
|
|
1176
|
-
* @param context - The ZuploContext
|
|
1177
|
-
* @param options - The policy options set in policies.json
|
|
1178
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
1179
|
-
* @returns A Request or a Response
|
|
1180
|
-
*/
|
|
1181
|
-
export declare function AIGatewaySemanticCacheInboundPolicy(
|
|
1182
|
-
request: ZuploRequest,
|
|
1183
|
-
context: ZuploContext,
|
|
1184
|
-
options: AIGatewaySemanticCacheInboundPolicyOptions,
|
|
1185
|
-
policyName: string
|
|
1186
|
-
): Promise<Response | ZuploRequest<RequestGeneric>>;
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* Options for the AI Gateway Semantic Cache policy.
|
|
1190
|
-
* @public
|
|
1191
|
-
*/
|
|
1192
|
-
export declare interface AIGatewaySemanticCacheInboundPolicyOptions {}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* Outbound policy to handle response caching for AI Gateway.
|
|
1196
|
-
* This policy intercepts responses and handles caching for both
|
|
1197
|
-
* streaming and non-streaming responses.
|
|
1198
|
-
*
|
|
1199
|
-
* @title AI Gateway Semantic Cache
|
|
1200
|
-
* @product ai-gateway
|
|
1201
|
-
* @hidden
|
|
1202
|
-
* @requiresAI
|
|
1203
|
-
* @param response - The response from the upstream service
|
|
1204
|
-
* @param request - The original request
|
|
1205
|
-
* @param context - The ZuploContext
|
|
1206
|
-
* @param options - The policy options
|
|
1207
|
-
* @param policyName - The name of the policy
|
|
1208
|
-
* @returns The response (potentially modified for caching)
|
|
1209
|
-
*/
|
|
1210
|
-
export declare function AIGatewaySemanticCacheOutboundPolicy(
|
|
1211
|
-
response: Response,
|
|
1212
|
-
request: ZuploRequest,
|
|
1213
|
-
context: ZuploContext,
|
|
1214
|
-
options: AIGatewaySemanticCacheOutboundPolicyOptions,
|
|
1215
|
-
policyName: string
|
|
1216
|
-
): Promise<Response>;
|
|
1217
|
-
|
|
1218
|
-
/**
|
|
1219
|
-
* Options for the AI Gateway Semantic Cache Outbound policy.
|
|
1220
|
-
* @public
|
|
1221
|
-
*/
|
|
1222
|
-
export declare interface AIGatewaySemanticCacheOutboundPolicyOptions {}
|
|
1223
|
-
|
|
1224
1115
|
/**
|
|
1225
1116
|
* AI Gateway Semantic Cache policy. This inbound policy looks up the semantic
|
|
1226
1117
|
* cache on entry and, on a miss, registers a response-sending hook to write the
|
|
@@ -1251,26 +1142,30 @@ export declare interface AIGatewaySemanticCacheOutboundPolicyOptions {}
|
|
|
1251
1142
|
* @param policyName - The name of the policy as set in policies.json
|
|
1252
1143
|
* @returns A Request or a Response
|
|
1253
1144
|
*/
|
|
1254
|
-
|
|
1145
|
+
declare function AIGatewaySemanticCacheInboundPolicy(
|
|
1255
1146
|
request: ZuploRequest,
|
|
1256
1147
|
context: ZuploContext,
|
|
1257
|
-
options:
|
|
1148
|
+
options: AIGatewaySemanticCacheInboundPolicyOptions,
|
|
1258
1149
|
policyName: string
|
|
1259
1150
|
): Promise<Response | ZuploRequest<RequestGeneric>>;
|
|
1151
|
+
export { AIGatewaySemanticCacheInboundPolicy };
|
|
1152
|
+
export { AIGatewaySemanticCacheInboundPolicy as AIGatewaySemanticCacheV2InboundPolicy };
|
|
1260
1153
|
|
|
1261
1154
|
/**
|
|
1262
1155
|
* Options for the AI Gateway Semantic Cache policy. Configured inline in policies.json; the policy reads nothing from the AI Gateway configuration to decide whether to cache.
|
|
1263
1156
|
* @public
|
|
1264
1157
|
*/
|
|
1265
|
-
|
|
1158
|
+
declare interface AIGatewaySemanticCacheInboundPolicyOptions {
|
|
1266
1159
|
semanticTolerance?: SemanticTolerance;
|
|
1267
1160
|
expirationSecondsTtl?: CacheTTLSeconds;
|
|
1268
1161
|
namespace?: CacheNamespace;
|
|
1269
1162
|
recentMessageCount?: RecentMessageCount_2;
|
|
1270
1163
|
maxConversationLength?: MaxConversationLength;
|
|
1271
|
-
endpoints?:
|
|
1272
|
-
onUnknownShape?:
|
|
1164
|
+
endpoints?: ApplicableEndpoints_6;
|
|
1165
|
+
onUnknownShape?: OnUnknownShape_6;
|
|
1273
1166
|
}
|
|
1167
|
+
export { AIGatewaySemanticCacheInboundPolicyOptions };
|
|
1168
|
+
export { AIGatewaySemanticCacheInboundPolicyOptions as AIGatewaySemanticCacheV2InboundPolicyOptions };
|
|
1274
1169
|
|
|
1275
1170
|
/**
|
|
1276
1171
|
* Reads and writes the Smart Router result for an AI Gateway request.
|
|
@@ -1426,54 +1321,6 @@ export declare interface AIGatewaySmartRouterTokenUsage {
|
|
|
1426
1321
|
totalTokens: number;
|
|
1427
1322
|
}
|
|
1428
1323
|
|
|
1429
|
-
/**
|
|
1430
|
-
* The options for this policy.
|
|
1431
|
-
* @public
|
|
1432
|
-
*/
|
|
1433
|
-
export declare interface AIGatewayUsageTrackerOptions {}
|
|
1434
|
-
|
|
1435
|
-
/**
|
|
1436
|
-
* Tracks AI Gateway usage including token consumption and costs based on
|
|
1437
|
-
* real-time model pricing from the Gateway service.
|
|
1438
|
-
*
|
|
1439
|
-
* This policy monitors AI model usage by:
|
|
1440
|
-
* - Extracting token usage from AI provider responses
|
|
1441
|
-
* - Fetching current model pricing from the Gateway service
|
|
1442
|
-
* - Calculating costs based on prompt and completion tokens
|
|
1443
|
-
* - Recording metrics for billing and monitoring
|
|
1444
|
-
* - Adding usage headers to responses for debugging
|
|
1445
|
-
* @hidden
|
|
1446
|
-
* @title AI Gateway Usage Tracker
|
|
1447
|
-
* @product ai-gateway
|
|
1448
|
-
* @param response - The response from the AI provider
|
|
1449
|
-
* @param request - The incoming ZuploRequest
|
|
1450
|
-
* @param context - The ZuploContext
|
|
1451
|
-
* @param options - The policy configuration options
|
|
1452
|
-
* @param policyName - The name of the policy instance
|
|
1453
|
-
* @returns The response with added usage headers
|
|
1454
|
-
*
|
|
1455
|
-
* @example
|
|
1456
|
-
* ```json
|
|
1457
|
-
* // policies.json - Basic usage tracking
|
|
1458
|
-
* {
|
|
1459
|
-
* "name": "ai-usage-tracker",
|
|
1460
|
-
* "policyType": "ai-gateway-usage-tracker",
|
|
1461
|
-
* "handler": {
|
|
1462
|
-
* "export": "AIGatewayUsageTrackerPolicy",
|
|
1463
|
-
* "module": "$import(@zuplo/runtime)",
|
|
1464
|
-
* "options": {}
|
|
1465
|
-
* }
|
|
1466
|
-
* }
|
|
1467
|
-
* ```
|
|
1468
|
-
*/
|
|
1469
|
-
export declare function AIGatewayUsageTrackerPolicy(
|
|
1470
|
-
response: Response,
|
|
1471
|
-
request: ZuploRequest,
|
|
1472
|
-
context: ZuploContext,
|
|
1473
|
-
_options: AIGatewayUsageTrackerOptions,
|
|
1474
|
-
_policyName: string
|
|
1475
|
-
): Promise<Response>;
|
|
1476
|
-
|
|
1477
1324
|
/**
|
|
1478
1325
|
* Common options every AI Gateway policy understands for scoping itself across
|
|
1479
1326
|
* the multi-endpoint surface. A policy reads these from its own `options`.
|
|
@@ -1571,104 +1418,6 @@ export declare interface AiUsage {
|
|
|
1571
1418
|
totalTokens: number;
|
|
1572
1419
|
}
|
|
1573
1420
|
|
|
1574
|
-
/**
|
|
1575
|
-
* Akamai AI Firewall Inbound Policy
|
|
1576
|
-
* @title Akamai AI Firewall
|
|
1577
|
-
* @product ai-gateway
|
|
1578
|
-
* @hidden
|
|
1579
|
-
* @requiresAI
|
|
1580
|
-
*
|
|
1581
|
-
* This policy integrates with Akamai's AI Firewall service to detect and block
|
|
1582
|
-
* malicious AI inputs and outputs. It uses the shared AI Gateway shape and
|
|
1583
|
-
* streaming helpers for both streaming and non-streaming responses.
|
|
1584
|
-
*
|
|
1585
|
-
* For streaming responses, it uses a transform stream that can block
|
|
1586
|
-
* content mid-stream if harmful content is detected.
|
|
1587
|
-
*
|
|
1588
|
-
* Detect-call failures (invalid credentials, rate limits, outages) fail closed
|
|
1589
|
-
* by default, returning a 502 in the route's native error format; set
|
|
1590
|
-
* `onError: "allow"` in the app configuration (or in the policy options, which
|
|
1591
|
-
* the app configuration overrides) to fail open and prioritize availability
|
|
1592
|
-
* over inspection.
|
|
1593
|
-
*
|
|
1594
|
-
* @param request - The ZuploRequest
|
|
1595
|
-
* @param context - The ZuploContext
|
|
1596
|
-
* @param options - The policy options set in policies.json
|
|
1597
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
1598
|
-
* @returns A Request or a Response
|
|
1599
|
-
*/
|
|
1600
|
-
export declare function AkamaiAIFirewallInboundPolicy(
|
|
1601
|
-
request: ZuploRequest,
|
|
1602
|
-
context: ZuploContext,
|
|
1603
|
-
options: AkamaiAIFirewallPolicyOptions,
|
|
1604
|
-
_policyName: string
|
|
1605
|
-
): Promise<ZuploRequest | Response>;
|
|
1606
|
-
|
|
1607
|
-
/**
|
|
1608
|
-
* The options for the Akamai AI Firewall policy.
|
|
1609
|
-
* @public
|
|
1610
|
-
*/
|
|
1611
|
-
export declare interface AkamaiAIFirewallPolicyOptions {
|
|
1612
|
-
configurationId: ConfigurationID;
|
|
1613
|
-
"api-key": APIKey_2;
|
|
1614
|
-
applicationId?: ApplicationID;
|
|
1615
|
-
streamingAccumulation?: StreamingAccumulationSettings;
|
|
1616
|
-
onError?: OnFirewallError;
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
/**
|
|
1620
|
-
* Akamai AI Firewall Inbound Policy
|
|
1621
|
-
* @title Akamai AI Firewall
|
|
1622
|
-
* @product ai-gateway
|
|
1623
|
-
* @requiresAI
|
|
1624
|
-
*
|
|
1625
|
-
* Detects and blocks malicious AI inputs and outputs via Akamai's AI Firewall
|
|
1626
|
-
* service. Settings come from the policy options (configurationId, api-key,
|
|
1627
|
-
* applicationId, streamingAccumulation), and presence in the route's
|
|
1628
|
-
* `inbound[]` chain is what enables it.
|
|
1629
|
-
*
|
|
1630
|
-
* Options are validated at request time and invalid options fail closed with a
|
|
1631
|
-
* ConfigurationError. Detect-call failures (invalid credentials, rate limits,
|
|
1632
|
-
* outages) also fail closed by default, returning a 502 in the route's native
|
|
1633
|
-
* error format; set `onError: "allow"` to fail open and prioritize
|
|
1634
|
-
* availability over inspection.
|
|
1635
|
-
*
|
|
1636
|
-
* For streaming responses it uses a transform stream that can block content
|
|
1637
|
-
* mid-stream if harmful content is detected.
|
|
1638
|
-
*
|
|
1639
|
-
* Do not add this policy to the inbound chain of an app used as a Smart
|
|
1640
|
-
* Router classifier (`classifierAppID`). The firewall would inspect Smart
|
|
1641
|
-
* Router's internal classification call as if it were a completion request,
|
|
1642
|
-
* and Smart Router fails open on the resulting denial — so this is rejected
|
|
1643
|
-
* with a `ConfigurationError` rather than silently degrading classification.
|
|
1644
|
-
*
|
|
1645
|
-
* @param request - The ZuploRequest
|
|
1646
|
-
* @param context - The ZuploContext
|
|
1647
|
-
* @param options - The policy options set in policies.json
|
|
1648
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
1649
|
-
* @returns A Request or a Response
|
|
1650
|
-
*/
|
|
1651
|
-
export declare function AkamaiAIFirewallV2InboundPolicy(
|
|
1652
|
-
request: ZuploRequest,
|
|
1653
|
-
context: ZuploContext,
|
|
1654
|
-
unparsedOptions: unknown,
|
|
1655
|
-
policyName: string
|
|
1656
|
-
): Promise<ZuploRequest | Response>;
|
|
1657
|
-
|
|
1658
|
-
/**
|
|
1659
|
-
* The options for the Akamai AI Firewall policy.
|
|
1660
|
-
* @public
|
|
1661
|
-
*/
|
|
1662
|
-
export declare interface AkamaiAIFirewallV2PolicyOptions {
|
|
1663
|
-
configurationId: ConfigurationID_2;
|
|
1664
|
-
"api-key": APIKey_3;
|
|
1665
|
-
applicationId?: ApplicationID_2;
|
|
1666
|
-
streamingAccumulation?: StreamingAccumulationSettings_2;
|
|
1667
|
-
endpoints?: ApplicableEndpoints_4;
|
|
1668
|
-
onUnknownShape?: OnUnknownShape_4;
|
|
1669
|
-
onError?: OnFirewallError_2;
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
1421
|
/**
|
|
1673
1422
|
* Entry format for Akamai API Security logger
|
|
1674
1423
|
* @public
|
|
@@ -2048,23 +1797,17 @@ export declare interface ApiAuthKeyInboundPolicyOptions {
|
|
|
2048
1797
|
}
|
|
2049
1798
|
|
|
2050
1799
|
/**
|
|
2051
|
-
*
|
|
1800
|
+
* The API key for the AI Firewall.
|
|
2052
1801
|
* @public
|
|
2053
1802
|
*/
|
|
2054
1803
|
declare type APIKey = string;
|
|
2055
1804
|
|
|
2056
1805
|
/**
|
|
2057
|
-
*
|
|
1806
|
+
* Credential used to run the classifier. Without `appId` this is the API key for the OpenAI-compatible service at `baseUrl`, and it is required. With `appId` it is optional: omit it when the classifier app runs the Ensure Gateway Internal Invocation Only policy, which authorizes the in-process invocation itself, and set it only when that app authenticates callers with API keys, in which case it is sent as `Authorization: Bearer`.
|
|
2058
1807
|
* @public
|
|
2059
1808
|
*/
|
|
2060
1809
|
declare type APIKey_2 = string;
|
|
2061
1810
|
|
|
2062
|
-
/**
|
|
2063
|
-
* The API key for the AI Firewall.
|
|
2064
|
-
* @public
|
|
2065
|
-
*/
|
|
2066
|
-
declare type APIKey_3 = string;
|
|
2067
|
-
|
|
2068
1811
|
/**
|
|
2069
1812
|
* Represents a consumer in the API Key service.
|
|
2070
1813
|
* @public
|
|
@@ -2303,21 +2046,10 @@ declare type ApplicableEndpoints = (
|
|
|
2303
2046
|
)[];
|
|
2304
2047
|
|
|
2305
2048
|
/**
|
|
2306
|
-
* The endpoint shapes this policy applies to. Omit to apply to all (openai-chat, openai-responses, anthropic-messages).
|
|
2307
|
-
*
|
|
2308
|
-
* @minItems 1
|
|
2309
|
-
* @public
|
|
2310
|
-
*/
|
|
2311
|
-
declare type ApplicableEndpoints_2 = [
|
|
2312
|
-
"openai-chat" | "openai-responses" | "anthropic-messages",
|
|
2313
|
-
...("openai-chat" | "openai-responses" | "anthropic-messages")[],
|
|
2314
|
-
];
|
|
2315
|
-
|
|
2316
|
-
/**
|
|
2317
|
-
* The endpoint shapes to cache. Defaults to all shapes: ['openai-chat', 'anthropic-messages', 'openai-responses'].
|
|
2049
|
+
* The endpoint shapes this policy applies to. Omit to apply to all (openai-chat, openai-responses, anthropic-messages).
|
|
2318
2050
|
* @public
|
|
2319
2051
|
*/
|
|
2320
|
-
declare type
|
|
2052
|
+
declare type ApplicableEndpoints_2 = (
|
|
2321
2053
|
| "openai-chat"
|
|
2322
2054
|
| "openai-responses"
|
|
2323
2055
|
| "anthropic-messages"
|
|
@@ -2327,7 +2059,7 @@ declare type ApplicableEndpoints_3 = (
|
|
|
2327
2059
|
* The endpoint shapes this policy applies to. Omit to apply to all (openai-chat, openai-responses, anthropic-messages).
|
|
2328
2060
|
* @public
|
|
2329
2061
|
*/
|
|
2330
|
-
declare type
|
|
2062
|
+
declare type ApplicableEndpoints_3 = (
|
|
2331
2063
|
| "openai-chat"
|
|
2332
2064
|
| "openai-responses"
|
|
2333
2065
|
| "anthropic-messages"
|
|
@@ -2337,7 +2069,7 @@ declare type ApplicableEndpoints_4 = (
|
|
|
2337
2069
|
* The endpoint shapes this policy applies to. Omit to apply to all (openai-chat, openai-responses, anthropic-messages).
|
|
2338
2070
|
* @public
|
|
2339
2071
|
*/
|
|
2340
|
-
declare type
|
|
2072
|
+
declare type ApplicableEndpoints_4 = (
|
|
2341
2073
|
| "openai-chat"
|
|
2342
2074
|
| "openai-responses"
|
|
2343
2075
|
| "anthropic-messages"
|
|
@@ -2345,6 +2077,17 @@ declare type ApplicableEndpoints_5 = (
|
|
|
2345
2077
|
|
|
2346
2078
|
/**
|
|
2347
2079
|
* The endpoint shapes this policy applies to. Omit to apply to all (openai-chat, openai-responses, anthropic-messages).
|
|
2080
|
+
*
|
|
2081
|
+
* @minItems 1
|
|
2082
|
+
* @public
|
|
2083
|
+
*/
|
|
2084
|
+
declare type ApplicableEndpoints_5 = [
|
|
2085
|
+
"openai-chat" | "openai-responses" | "anthropic-messages",
|
|
2086
|
+
...("openai-chat" | "openai-responses" | "anthropic-messages")[],
|
|
2087
|
+
];
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* The endpoint shapes to cache. Defaults to all shapes: ['openai-chat', 'anthropic-messages', 'openai-responses'].
|
|
2348
2091
|
* @public
|
|
2349
2092
|
*/
|
|
2350
2093
|
declare type ApplicableEndpoints_6 = (
|
|
@@ -2359,12 +2102,6 @@ declare type ApplicableEndpoints_6 = (
|
|
|
2359
2102
|
*/
|
|
2360
2103
|
declare type ApplicationID = string;
|
|
2361
2104
|
|
|
2362
|
-
/**
|
|
2363
|
-
* The application ID to identify this usage of the AI Firewall (optional).
|
|
2364
|
-
* @public
|
|
2365
|
-
*/
|
|
2366
|
-
declare type ApplicationID_2 = string;
|
|
2367
|
-
|
|
2368
2105
|
/**
|
|
2369
2106
|
* A list of attributes that will be included in the authorization request.
|
|
2370
2107
|
* @public
|
|
@@ -4008,12 +3745,6 @@ declare interface ChatCompletionResponse {
|
|
|
4008
3745
|
*/
|
|
4009
3746
|
declare type CheckIntervalMs = number;
|
|
4010
3747
|
|
|
4011
|
-
/**
|
|
4012
|
-
* Time interval in milliseconds for periodic checks (alternative to chunk count).
|
|
4013
|
-
* @public
|
|
4014
|
-
*/
|
|
4015
|
-
declare type CheckIntervalMs_2 = number;
|
|
4016
|
-
|
|
4017
3748
|
/**
|
|
4018
3749
|
* A light JSON-path selector into the authenticated user's claims (request.user.data). Use dot notation for nested claims, e.g. 'address.country'. Use bracket notation with quotes for claim names that contain dots or slashes — namespaced claims — e.g. ["https://sts.amazonaws.com/"]["lambda_source_function_arn"]; the two notations may be mixed. A missing claim always fails the check.
|
|
4019
3750
|
* @public
|
|
@@ -4248,110 +3979,6 @@ export declare interface CognitoJwtInboundPolicyOptions {
|
|
|
4248
3979
|
oAuthResourceMetadataEnabled?: boolean;
|
|
4249
3980
|
}
|
|
4250
3981
|
|
|
4251
|
-
/**
|
|
4252
|
-
* Comet Opik Tracing Inbound Policy
|
|
4253
|
-
* @title Comet Opik Tracing
|
|
4254
|
-
* @product ai-gateway
|
|
4255
|
-
* @hidden
|
|
4256
|
-
*
|
|
4257
|
-
* This policy automatically handles tracing for both streaming and non-streaming
|
|
4258
|
-
* responses from AI Gateway. It creates traces when requests start and spans
|
|
4259
|
-
* when responses complete.
|
|
4260
|
-
*
|
|
4261
|
-
* For streaming responses, it clones the response stream and processes it in
|
|
4262
|
-
* the background using `waitUntil`, allowing the original stream to pass through
|
|
4263
|
-
* unmodified while still capturing the complete content for tracing.
|
|
4264
|
-
*
|
|
4265
|
-
* @param request - The ZuploRequest
|
|
4266
|
-
* @param context - The ZuploContext
|
|
4267
|
-
* @param options - The policy options set in policies.json
|
|
4268
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
4269
|
-
* @returns A Request or a Response
|
|
4270
|
-
*/
|
|
4271
|
-
export declare function CometOpikTracingInboundPolicy(
|
|
4272
|
-
request: ZuploRequest,
|
|
4273
|
-
context: ZuploContext,
|
|
4274
|
-
options: CometOpikTracingPolicyOptions,
|
|
4275
|
-
policyName: string
|
|
4276
|
-
): Promise<ZuploRequest | Response>;
|
|
4277
|
-
|
|
4278
|
-
/**
|
|
4279
|
-
* Track AI Gateway requests and responses using Comet Opik's LLM observability platform.
|
|
4280
|
-
* @public
|
|
4281
|
-
*/
|
|
4282
|
-
export declare interface CometOpikTracingPolicyOptions {
|
|
4283
|
-
/**
|
|
4284
|
-
* The Comet Opik API key for authentication.
|
|
4285
|
-
*/
|
|
4286
|
-
apiKey: string;
|
|
4287
|
-
/**
|
|
4288
|
-
* The Comet Opik project name for organizing traces.
|
|
4289
|
-
*/
|
|
4290
|
-
projectName: string;
|
|
4291
|
-
/**
|
|
4292
|
-
* The Comet Opik workspace name.
|
|
4293
|
-
*/
|
|
4294
|
-
workspace: string;
|
|
4295
|
-
/**
|
|
4296
|
-
* The base URL for the Comet Opik API (optional, defaults to https://www.comet.com/opik/api).
|
|
4297
|
-
*/
|
|
4298
|
-
baseUrl?: string;
|
|
4299
|
-
}
|
|
4300
|
-
|
|
4301
|
-
/**
|
|
4302
|
-
* Comet Opik Tracing Inbound Policy
|
|
4303
|
-
* @title Comet Opik Tracing
|
|
4304
|
-
* @product ai-gateway
|
|
4305
|
-
* @requiresAI
|
|
4306
|
-
*
|
|
4307
|
-
* Traces both streaming and non-streaming AI Gateway responses to Comet Opik,
|
|
4308
|
-
* creating traces when requests start and spans when responses complete.
|
|
4309
|
-
* Credentials (apiKey, projectName, workspace, baseUrl) come from the policy
|
|
4310
|
-
* options. The authenticated app configuration is used only to label the
|
|
4311
|
-
* model; presence in the route's chain is what enables the policy.
|
|
4312
|
-
*
|
|
4313
|
-
* For streaming responses, it clones the response stream and processes it in
|
|
4314
|
-
* the background using `waitUntil`, allowing the original stream to pass through
|
|
4315
|
-
* unmodified while still capturing the complete content for tracing.
|
|
4316
|
-
*
|
|
4317
|
-
* @param request - The ZuploRequest
|
|
4318
|
-
* @param context - The ZuploContext
|
|
4319
|
-
* @param options - The policy options set in policies.json
|
|
4320
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
4321
|
-
* @returns A Request or a Response
|
|
4322
|
-
*/
|
|
4323
|
-
export declare function CometOpikTracingV2InboundPolicy(
|
|
4324
|
-
request: ZuploRequest,
|
|
4325
|
-
context: ZuploContext,
|
|
4326
|
-
options: CometOpikTracingV2PolicyOptions,
|
|
4327
|
-
_policyName: string
|
|
4328
|
-
): Promise<ZuploRequest | Response>;
|
|
4329
|
-
|
|
4330
|
-
/**
|
|
4331
|
-
* Track AI Gateway requests and responses using Comet Opik's LLM observability platform.
|
|
4332
|
-
* @public
|
|
4333
|
-
*/
|
|
4334
|
-
export declare interface CometOpikTracingV2PolicyOptions {
|
|
4335
|
-
/**
|
|
4336
|
-
* The Comet Opik API key for authentication.
|
|
4337
|
-
*/
|
|
4338
|
-
apiKey: string;
|
|
4339
|
-
/**
|
|
4340
|
-
* The Comet Opik project name for organizing traces.
|
|
4341
|
-
*/
|
|
4342
|
-
projectName: string;
|
|
4343
|
-
/**
|
|
4344
|
-
* The Comet Opik workspace name.
|
|
4345
|
-
*/
|
|
4346
|
-
workspace: string;
|
|
4347
|
-
/**
|
|
4348
|
-
* The base URL for the Comet Opik API (optional, defaults to https://www.comet.com/opik/api).
|
|
4349
|
-
*/
|
|
4350
|
-
baseUrl?: string;
|
|
4351
|
-
endpoints?: ApplicableEndpoints_5;
|
|
4352
|
-
onUnknownShape?: OnUnknownShape_5;
|
|
4353
|
-
}
|
|
4354
|
-
|
|
4355
3982
|
/**
|
|
4356
3983
|
* The compatibility date on which to run the gateway
|
|
4357
3984
|
*/
|
|
@@ -4647,12 +4274,6 @@ export declare class ConfigurationError extends RuntimeError {
|
|
|
4647
4274
|
*/
|
|
4648
4275
|
declare type ConfigurationID = string;
|
|
4649
4276
|
|
|
4650
|
-
/**
|
|
4651
|
-
* The configuration ID of the AI Firewall.
|
|
4652
|
-
* @public
|
|
4653
|
-
*/
|
|
4654
|
-
declare type ConfigurationID_2 = string;
|
|
4655
|
-
|
|
4656
4277
|
/* Excluded from this release type: ContentTypes */
|
|
4657
4278
|
|
|
4658
4279
|
/**
|
|
@@ -5617,12 +5238,6 @@ declare type EmbeddingsOverride =
|
|
|
5617
5238
|
*/
|
|
5618
5239
|
declare type EnableStreamingAccumulation = boolean;
|
|
5619
5240
|
|
|
5620
|
-
/**
|
|
5621
|
-
* Enable accumulation and validation of streaming responses.
|
|
5622
|
-
* @public
|
|
5623
|
-
*/
|
|
5624
|
-
declare type EnableStreamingAccumulation_2 = boolean;
|
|
5625
|
-
|
|
5626
5241
|
/**
|
|
5627
5242
|
* @beta
|
|
5628
5243
|
* Object exposing environment variables
|
|
@@ -5654,12 +5269,6 @@ export declare interface ErrorHandler {
|
|
|
5654
5269
|
*/
|
|
5655
5270
|
declare type EventsInterval = number;
|
|
5656
5271
|
|
|
5657
|
-
/**
|
|
5658
|
-
* Number of SSE events to accumulate before checking with Akamai (default: 5).
|
|
5659
|
-
* @public
|
|
5660
|
-
*/
|
|
5661
|
-
declare type EventsInterval_2 = number;
|
|
5662
|
-
|
|
5663
5272
|
declare const EventType: {
|
|
5664
5273
|
readonly AI_GATEWAY_COST_SUM: "ai_gateway_cost_sum";
|
|
5665
5274
|
readonly AI_GATEWAY_REQUEST_COUNT: "ai_gateway_request_count";
|
|
@@ -5892,111 +5501,6 @@ declare interface FunctionTool {
|
|
|
5892
5501
|
description?: string | null;
|
|
5893
5502
|
}
|
|
5894
5503
|
|
|
5895
|
-
/**
|
|
5896
|
-
* Galileo Tracing Inbound Policy
|
|
5897
|
-
* @title Galileo Tracing
|
|
5898
|
-
* @product ai-gateway
|
|
5899
|
-
* @hidden
|
|
5900
|
-
*
|
|
5901
|
-
* This policy automatically handles tracing for both streaming and non-streaming
|
|
5902
|
-
* responses from AI Gateway. It creates complete traces with workflow and LLM spans
|
|
5903
|
-
* when responses complete.
|
|
5904
|
-
*
|
|
5905
|
-
* For streaming responses, it clones the response stream and processes it in
|
|
5906
|
-
* the background using `waitUntil`, allowing the original stream to pass through
|
|
5907
|
-
* unmodified while still capturing the complete content for tracing.
|
|
5908
|
-
*
|
|
5909
|
-
* @param request - The ZuploRequest
|
|
5910
|
-
* @param context - The ZuploContext
|
|
5911
|
-
* @param options - The policy options set in policies.json
|
|
5912
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
5913
|
-
* @returns A Request or a Response
|
|
5914
|
-
*/
|
|
5915
|
-
export declare function GalileoTracingInboundPolicy(
|
|
5916
|
-
request: ZuploRequest,
|
|
5917
|
-
context: ZuploContext,
|
|
5918
|
-
options: GalileoTracingPolicyOptions,
|
|
5919
|
-
policyName: string
|
|
5920
|
-
): Promise<ZuploRequest | Response>;
|
|
5921
|
-
|
|
5922
|
-
/**
|
|
5923
|
-
* Track AI Gateway requests and responses using Galileo's LLM observability platform.
|
|
5924
|
-
* @public
|
|
5925
|
-
*/
|
|
5926
|
-
export declare interface GalileoTracingPolicyOptions {
|
|
5927
|
-
/**
|
|
5928
|
-
* The Galileo API key for authentication.
|
|
5929
|
-
*/
|
|
5930
|
-
apiKey: string;
|
|
5931
|
-
/**
|
|
5932
|
-
* The Galileo project ID (UUID) for organizing traces.
|
|
5933
|
-
*/
|
|
5934
|
-
projectId: string;
|
|
5935
|
-
/**
|
|
5936
|
-
* The Galileo log stream ID (UUID) for organizing traces.
|
|
5937
|
-
*/
|
|
5938
|
-
logStreamId: string;
|
|
5939
|
-
/**
|
|
5940
|
-
* The base URL for the Galileo API (optional, defaults to https://api.galileo.ai).
|
|
5941
|
-
*/
|
|
5942
|
-
baseUrl?: string;
|
|
5943
|
-
}
|
|
5944
|
-
|
|
5945
|
-
/**
|
|
5946
|
-
* Galileo Tracing Inbound Policy
|
|
5947
|
-
* @title Galileo Tracing
|
|
5948
|
-
* @product ai-gateway
|
|
5949
|
-
* @requiresAI
|
|
5950
|
-
*
|
|
5951
|
-
* Traces both streaming and non-streaming AI Gateway responses to Galileo's LLM
|
|
5952
|
-
* observability platform, creating complete traces with workflow and LLM spans
|
|
5953
|
-
* when responses complete. Credentials (apiKey, projectId, logStreamId, baseUrl)
|
|
5954
|
-
* come from the policy options. The authenticated app configuration is used
|
|
5955
|
-
* only to label the model; presence in the route's chain is what enables the
|
|
5956
|
-
* policy.
|
|
5957
|
-
*
|
|
5958
|
-
* For streaming responses, it clones the response stream and processes it in
|
|
5959
|
-
* the background using `waitUntil`, allowing the original stream to pass through
|
|
5960
|
-
* unmodified while still capturing the complete content for tracing.
|
|
5961
|
-
*
|
|
5962
|
-
* @param request - The ZuploRequest
|
|
5963
|
-
* @param context - The ZuploContext
|
|
5964
|
-
* @param options - The policy options set in policies.json
|
|
5965
|
-
* @param policyName - The name of the policy as set in policies.json
|
|
5966
|
-
* @returns A Request or a Response
|
|
5967
|
-
*/
|
|
5968
|
-
export declare function GalileoTracingV2InboundPolicy(
|
|
5969
|
-
request: ZuploRequest,
|
|
5970
|
-
context: ZuploContext,
|
|
5971
|
-
options: GalileoTracingV2PolicyOptions,
|
|
5972
|
-
_policyName: string
|
|
5973
|
-
): Promise<ZuploRequest | Response>;
|
|
5974
|
-
|
|
5975
|
-
/**
|
|
5976
|
-
* Track AI Gateway requests and responses using Galileo's LLM observability platform.
|
|
5977
|
-
* @public
|
|
5978
|
-
*/
|
|
5979
|
-
export declare interface GalileoTracingV2PolicyOptions {
|
|
5980
|
-
/**
|
|
5981
|
-
* The Galileo API key for authentication.
|
|
5982
|
-
*/
|
|
5983
|
-
apiKey: string;
|
|
5984
|
-
/**
|
|
5985
|
-
* The Galileo project ID (UUID) for organizing traces.
|
|
5986
|
-
*/
|
|
5987
|
-
projectId: string;
|
|
5988
|
-
/**
|
|
5989
|
-
* The Galileo log stream ID (UUID) for organizing traces.
|
|
5990
|
-
*/
|
|
5991
|
-
logStreamId: string;
|
|
5992
|
-
/**
|
|
5993
|
-
* The base URL for the Galileo API (optional, defaults to https://api.galileo.ai).
|
|
5994
|
-
*/
|
|
5995
|
-
baseUrl?: string;
|
|
5996
|
-
endpoints?: ApplicableEndpoints_6;
|
|
5997
|
-
onUnknownShape?: OnUnknownShape_6;
|
|
5998
|
-
}
|
|
5999
|
-
|
|
6000
5504
|
/**
|
|
6001
5505
|
* Function to generate request logger entries
|
|
6002
5506
|
* @public
|
|
@@ -11532,17 +11036,11 @@ declare type OnClassifierError = "block" | "allow";
|
|
|
11532
11036
|
*/
|
|
11533
11037
|
declare type OnEngineError = "block" | "allow";
|
|
11534
11038
|
|
|
11535
|
-
/**
|
|
11536
|
-
* What to do when the Akamai detect call itself fails (invalid API key, rate limit, outage). 'block' (the default) fails closed and returns a 502 so unverified content is never served; 'allow' fails open and lets the request through without inspection. An onError value in the AI Gateway app configuration takes precedence over this option.
|
|
11537
|
-
* @public
|
|
11538
|
-
*/
|
|
11539
|
-
declare type OnFirewallError = "block" | "allow";
|
|
11540
|
-
|
|
11541
11039
|
/**
|
|
11542
11040
|
* What to do when the Akamai detect call itself fails (invalid API key, rate limit, outage). 'block' (the default) fails closed and returns a 502 so unverified content is never served; 'allow' fails open and lets the request through without inspection.
|
|
11543
11041
|
* @public
|
|
11544
11042
|
*/
|
|
11545
|
-
declare type
|
|
11043
|
+
declare type OnFirewallError = "block" | "allow";
|
|
11546
11044
|
|
|
11547
11045
|
/**
|
|
11548
11046
|
* @public
|
|
@@ -11590,37 +11088,37 @@ declare interface OnSendingAwsLambdaEventHook {
|
|
|
11590
11088
|
}
|
|
11591
11089
|
|
|
11592
11090
|
/**
|
|
11593
|
-
* What to do when the request shape cannot be inspected. As a guardrail this policy defaults to
|
|
11091
|
+
* What to do when the request shape cannot be inspected. As a guardrail, this policy defaults to 'deny' (fail closed) so uninspectable content is never served.
|
|
11594
11092
|
* @public
|
|
11595
11093
|
*/
|
|
11596
11094
|
declare type OnUnknownShape = "deny" | "skip";
|
|
11597
11095
|
|
|
11598
11096
|
/**
|
|
11599
|
-
* What to do when the request shape cannot be inspected. As a guardrail
|
|
11097
|
+
* What to do when the request shape cannot be inspected. As a guardrail this policy defaults to `deny` (fail closed) so uninspectable content is never served.
|
|
11600
11098
|
* @public
|
|
11601
11099
|
*/
|
|
11602
11100
|
declare type OnUnknownShape_2 = "deny" | "skip";
|
|
11603
11101
|
|
|
11604
11102
|
/**
|
|
11605
|
-
*
|
|
11103
|
+
* What to do on a shape the policy cannot read. As an observer this defaults to 'skip' (fail open — pass through untraced).
|
|
11606
11104
|
* @public
|
|
11607
11105
|
*/
|
|
11608
11106
|
declare type OnUnknownShape_3 = "deny" | "skip";
|
|
11609
11107
|
|
|
11610
11108
|
/**
|
|
11611
|
-
* What to do
|
|
11109
|
+
* What to do on a shape the policy cannot read. As an observer this defaults to 'skip' (fail open — pass through untraced).
|
|
11612
11110
|
* @public
|
|
11613
11111
|
*/
|
|
11614
11112
|
declare type OnUnknownShape_4 = "deny" | "skip";
|
|
11615
11113
|
|
|
11616
11114
|
/**
|
|
11617
|
-
* What to do
|
|
11115
|
+
* What to do when the request shape cannot be inspected. As a guardrail, this policy defaults to 'deny' (fail closed) so uninspectable content is never forwarded.
|
|
11618
11116
|
* @public
|
|
11619
11117
|
*/
|
|
11620
11118
|
declare type OnUnknownShape_5 = "deny" | "skip";
|
|
11621
11119
|
|
|
11622
11120
|
/**
|
|
11623
|
-
*
|
|
11121
|
+
* Unused by the cache (a cache miss is never unsafe, so it always fails open). Present for interface consistency.
|
|
11624
11122
|
* @public
|
|
11625
11123
|
*/
|
|
11626
11124
|
declare type OnUnknownShape_6 = "deny" | "skip";
|
|
@@ -14740,16 +14238,6 @@ declare interface StreamingAccumulationSettings {
|
|
|
14740
14238
|
checkIntervalMs?: CheckIntervalMs;
|
|
14741
14239
|
}
|
|
14742
14240
|
|
|
14743
|
-
/**
|
|
14744
|
-
* Configuration for accumulating and validating streaming responses.
|
|
14745
|
-
* @public
|
|
14746
|
-
*/
|
|
14747
|
-
declare interface StreamingAccumulationSettings_2 {
|
|
14748
|
-
enabled?: EnableStreamingAccumulation_2;
|
|
14749
|
-
eventsInterval?: EventsInterval_2;
|
|
14750
|
-
checkIntervalMs?: CheckIntervalMs_2;
|
|
14751
|
-
}
|
|
14752
|
-
|
|
14753
14241
|
/**
|
|
14754
14242
|
* A specialized zone cache for storing and retrieving ReadableStreams.
|
|
14755
14243
|
* Unlike regular ZoneCache which serializes to JSON, this cache stores raw stream data,
|