zuplo 7.8.25 → 7.9.3
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/docs/ai-gateway/cookbooks/sdk-path-shim.mdx +10 -5
- package/docs/ai-gateway/policy-chains.mdx +9 -5
- package/docs/policies/_index.md +2 -2
- package/docs/policies/ai-gateway-akamai-firewall-inbound/doc.md +1 -1
- package/docs/policies/ai-gateway-auth-inbound/doc.md +6 -6
- package/docs/policies/ai-gateway-configuration-executor-inbound/doc.md +24 -24
- package/docs/policies/ai-gateway-configuration-executor-inbound/intro.md +2 -2
- package/docs/policies/ai-gateway-configuration-executor-inbound/schema.json +2 -2
- package/docs/policies/ai-gateway-configuration-loader-inbound/doc.md +13 -13
- package/docs/policies/ai-gateway-configuration-loader-inbound/intro.md +4 -4
- package/docs/policies/ai-gateway-configuration-loader-inbound/schema.json +2 -2
- package/docs/policies/ai-gateway-fallback-model-inbound/doc.md +1 -1
- package/docs/policies/ai-gateway-galileo-tracing-inbound/doc.md +1 -1
- package/docs/policies/ai-gateway-internal-only-inbound/doc.md +3 -3
- package/docs/policies/ai-gateway-metering-inbound/doc.md +1 -1
- package/docs/policies/ai-gateway-model-filtering-inbound/doc.md +1 -1
- package/docs/policies/ai-gateway-opik-tracing-inbound/doc.md +1 -1
- package/package.json +5 -5
|
@@ -46,7 +46,7 @@ import { ZuploRequest } from "@zuplo/runtime";
|
|
|
46
46
|
*
|
|
47
47
|
* Copy this module into your gateway, register it in `policies.json` as a
|
|
48
48
|
* `custom-code-inbound` policy, and list it FIRST in the catch-all route's
|
|
49
|
-
* inbound policies — before `ai-gateway-configuration-loader-
|
|
49
|
+
* inbound policies — before `ai-gateway-configuration-loader-inbound`. The
|
|
50
50
|
* loader answers 404 to any path whose segment after the app id is not `v1`
|
|
51
51
|
* before it loads the app, so a shim placed in an app's stored chain would
|
|
52
52
|
* never run for these paths. (This fixture mounts it on a sibling route,
|
|
@@ -74,7 +74,7 @@ import { ZuploRequest } from "@zuplo/runtime";
|
|
|
74
74
|
*
|
|
75
75
|
* Credential: an `api-key` header — what the Azure clients send — becomes
|
|
76
76
|
* `Authorization: Bearer` when no Authorization header is present, which is
|
|
77
|
-
* the header `ai-gateway-auth-
|
|
77
|
+
* the header `ai-gateway-auth-inbound` reads. Query strings such as
|
|
78
78
|
* `api-version` are left alone; the gateway ignores them.
|
|
79
79
|
*
|
|
80
80
|
* Anything the shim does not recognize passes through with the path
|
|
@@ -295,18 +295,23 @@ Three steps, all in your gateway project:
|
|
|
295
295
|
|
|
296
296
|
In `config/ai.oas.json`, list `sdk-path-shim-inbound` **first** in the
|
|
297
297
|
inbound policies of the AI Gateway catch-all route `/:app_id/(.*)`, ahead of
|
|
298
|
-
`ai-gateway-configuration-loader-
|
|
298
|
+
`ai-gateway-configuration-loader-inbound`:
|
|
299
299
|
|
|
300
300
|
```json title="config/ai.oas.json (the catch-all route's policies)"
|
|
301
301
|
"policies": {
|
|
302
302
|
"inbound": [
|
|
303
303
|
"sdk-path-shim-inbound",
|
|
304
|
-
"ai-gateway-configuration-loader-
|
|
305
|
-
"ai-gateway-configuration-executor-
|
|
304
|
+
"ai-gateway-configuration-loader-inbound",
|
|
305
|
+
"ai-gateway-configuration-executor-inbound"
|
|
306
306
|
]
|
|
307
307
|
}
|
|
308
308
|
```
|
|
309
309
|
|
|
310
|
+
Older gateways list these two policies as
|
|
311
|
+
`ai-gateway-configuration-loader-v2-inbound` and
|
|
312
|
+
`ai-gateway-configuration-executor-v2-inbound`. Keep the names your route
|
|
313
|
+
already uses and add the shim ahead of them.
|
|
314
|
+
|
|
310
315
|
</Stepper>
|
|
311
316
|
|
|
312
317
|
The order isn't optional: the shim must run before the loader, for the reason
|
|
@@ -83,6 +83,10 @@ remove that entry.
|
|
|
83
83
|
references a policy that isn't declared in the gateway's `policies.json`—the
|
|
84
84
|
request fails with an error identifying the entry to fix, and no entries run.
|
|
85
85
|
The gateway never guesses.
|
|
86
|
+
- Older gateways and chains name built-in AI Gateway policies with a
|
|
87
|
+
`-v2-inbound` suffix, such as `ai-gateway-metering-v2-inbound`. Those names
|
|
88
|
+
keep working: an entry named either way matches a policy declared either way
|
|
89
|
+
in `policies.json`.
|
|
86
90
|
|
|
87
91
|
### Options and secrets
|
|
88
92
|
|
|
@@ -149,16 +153,16 @@ the Add Policy dialog alongside the built-in ones.
|
|
|
149
153
|
|
|
150
154
|
## Configuration Executor
|
|
151
155
|
|
|
152
|
-
`ai-gateway-configuration-executor-
|
|
156
|
+
`ai-gateway-configuration-executor-inbound` is the policy that makes the
|
|
153
157
|
two-layer model work. It loads the app's configuration and then runs the app's
|
|
154
158
|
stored inbound chain, instantiating only policies already declared in
|
|
155
159
|
`config/policies.json`. Every scaffolded gateway declares it and puts it on the
|
|
156
160
|
AI Gateway route—that route entry is what gives an app's chain somewhere to run.
|
|
157
161
|
|
|
158
162
|
The scaffolded route also carries a **Configuration Loader**
|
|
159
|
-
(`ai-gateway-configuration-loader-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
(`ai-gateway-configuration-loader-inbound`) ahead of the executor. The executor
|
|
164
|
+
loads the app's configuration by default, so the loader changes nothing on its
|
|
165
|
+
own—it's there for when you want to manipulate the loaded configuration
|
|
162
166
|
programmatically before the chain runs: place your own route policy between the
|
|
163
167
|
loader and the executor.
|
|
164
168
|
|
|
@@ -171,7 +175,7 @@ also affect when a budget change takes effect.
|
|
|
171
175
|
|
|
172
176
|
## Authentication
|
|
173
177
|
|
|
174
|
-
The `ai-gateway-auth-
|
|
178
|
+
The `ai-gateway-auth-inbound` policy—**API Key Authentication** in the
|
|
175
179
|
portal—requires callers to present the app's API key, and it applies per app:
|
|
176
180
|
add it to an app's chain to require a key for that app alone. A new top-level
|
|
177
181
|
team's [policy template](./policy-templates.mdx) includes it as a locked
|
package/docs/policies/_index.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
| set-query-params-inbound | Add or Set Query Parameters | Adds or sets query parameters on the incoming request. | api-gateway |
|
|
6
6
|
| set-headers-inbound | Add or Set Request Headers | Adds or sets headers on the incoming request. | api-gateway |
|
|
7
7
|
| ai-gateway-auth-inbound | AI Gateway Authentication | Authenticates requests to an AI Gateway endpoint with application API keys. Add this policy to an application's `inboundPolicyChain` to require a key for that app only, or place it on the route before the configuration executor to require a key for every application on the route. The policies that follow can read the authenticated application from `request.user` (`sub` is the application name, `data` its metadata), and the application's AI Gateway configuration takes effect for the request. Use `authHeader` and `authScheme` when clients send their app key somewhere other than the default `Authorization: Bearer` header. Enable `credentialPassthrough`, with the application key in a separate header, to forward the caller's `Authorization` header to the primary provider as its credential. When the matched route captures an `app_id` path parameter (platform catch-all `/:app_id/(.*)`), this policy also requires the stored configuration ID to match the URL (adding `config_` for `/a`). It returns 403 on mismatch. On a User App route (`/u/{app_id}`), only a personal API key issued for that User App authenticates. `request.user.sub` is then the key owner's user ID. An application API key on a User App route, or a personal API key on any other route, returns 403. Validation results are cached for `cacheTtlSeconds`, so a revoked key stops working within that window. | ai-gateway |
|
|
8
|
-
| ai-gateway-configuration-executor-inbound | AI Gateway Configuration Executor | Loads the app configuration for the request (when auth or the configuration loader has not already), runs the inbound policy chain from that configuration, and enforces limits inherited from parent teams or the gateway root. Place this policy on AI Gateway routes after optional authentication and optional `ai-gateway-configuration-loader-
|
|
9
|
-
| ai-gateway-configuration-loader-inbound | AI Gateway Configuration Loader | Loads the AI Gateway app configuration for the request into the request-scoped channel and does nothing else. Place this policy on AI Gateway routes before `ai-gateway-configuration-executor-
|
|
8
|
+
| ai-gateway-configuration-executor-inbound | AI Gateway Configuration Executor | Loads the app configuration for the request (when auth or the configuration loader has not already), runs the inbound policy chain from that configuration, and enforces limits inherited from parent teams or the gateway root. Place this policy on AI Gateway routes after optional authentication and optional `ai-gateway-configuration-loader-inbound`. When either of those already populated the app-configuration channel, this policy reuses it. Otherwise it loads the configuration with the route's `app_id` path parameter. Applications select from policies pre-declared by the gateway. Applications without a `inboundPolicyChain`, or with an empty chain, run no application-selected policies. Entry options replace the declaration's options as a complete object; omit them to inherit the declaration, including environment-backed credentials. Each occurrence receives a private deep copy of its entry options, so a policy mutating its options cannot corrupt the cached app configuration. | ai-gateway |
|
|
9
|
+
| ai-gateway-configuration-loader-inbound | AI Gateway Configuration Loader | Loads the AI Gateway app configuration for the request into the request-scoped channel and does nothing else. Place this policy on AI Gateway routes before `ai-gateway-configuration-executor-inbound` when you want configuration loading separated from chain execution. When `ai-gateway-auth-inbound` already populated the channel, this policy reuses it. Otherwise it loads the configuration with the route's `app_id` path parameter. If this policy is omitted, the configuration executor still loads configuration itself before running the application chain. | ai-gateway |
|
|
10
10
|
| ai-gateway-fallback-model-inbound | AI Gateway Fallback Model | Adds failure and quota fallbacks to an existing AI Gateway model selection. Place this policy after AI Gateway Model Filtering. It never creates a model selection, so a misplaced policy cannot bypass filtering. | ai-gateway |
|
|
11
11
|
| ai-gateway-metering-inbound | AI Gateway Metering | Meters AI Gateway usage and enforces limits configured by the application. The authentication policy must run before this policy so the app configuration id is available for meter storage and analytics. | ai-gateway |
|
|
12
12
|
| ai-gateway-model-filtering-inbound | AI Gateway Model Filtering | Matches AI Gateway requests against curated allow lists or open block lists, then stores the winning model reference for the route handler. | ai-gateway |
|
|
@@ -17,7 +17,7 @@ by default, include it in the team's policy template.
|
|
|
17
17
|
|
|
18
18
|
```json
|
|
19
19
|
{
|
|
20
|
-
"name": "akamai-
|
|
20
|
+
"name": "ai-gateway-akamai-firewall-inbound",
|
|
21
21
|
"policyType": "ai-gateway-akamai-firewall",
|
|
22
22
|
"handler": {
|
|
23
23
|
"export": "AIGatewayAkamaiFirewallInboundPolicy",
|
|
@@ -24,7 +24,7 @@ Declare the policy in `config/policies.json`:
|
|
|
24
24
|
{
|
|
25
25
|
"policies": [
|
|
26
26
|
{
|
|
27
|
-
"name": "ai-gateway-auth-
|
|
27
|
+
"name": "ai-gateway-auth-inbound",
|
|
28
28
|
"policyType": "ai-gateway-auth",
|
|
29
29
|
"handler": {
|
|
30
30
|
"export": "AIGatewayAuthInboundPolicy",
|
|
@@ -52,7 +52,7 @@ the `app_id` path parameter before the app chain runs:
|
|
|
52
52
|
{
|
|
53
53
|
"inboundPolicyChain": [
|
|
54
54
|
{
|
|
55
|
-
"name": "ai-gateway-auth-
|
|
55
|
+
"name": "ai-gateway-auth-inbound"
|
|
56
56
|
}
|
|
57
57
|
]
|
|
58
58
|
}
|
|
@@ -75,9 +75,9 @@ application that hits the route:
|
|
|
75
75
|
},
|
|
76
76
|
"policies": {
|
|
77
77
|
"inbound": [
|
|
78
|
-
"ai-gateway-auth-
|
|
79
|
-
"ai-gateway-configuration-loader-
|
|
80
|
-
"ai-gateway-configuration-executor-
|
|
78
|
+
"ai-gateway-auth-inbound",
|
|
79
|
+
"ai-gateway-configuration-loader-inbound",
|
|
80
|
+
"ai-gateway-configuration-executor-inbound"
|
|
81
81
|
]
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -127,7 +127,7 @@ empty string when the header contains only the key:
|
|
|
127
127
|
|
|
128
128
|
```json
|
|
129
129
|
{
|
|
130
|
-
"name": "ai-gateway-auth-
|
|
130
|
+
"name": "ai-gateway-auth-inbound",
|
|
131
131
|
"policyType": "ai-gateway-auth",
|
|
132
132
|
"handler": {
|
|
133
133
|
"export": "AIGatewayAuthInboundPolicy",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
The AI Gateway Configuration Executor loads each application's configuration
|
|
2
|
-
(when auth or `ai-gateway-configuration-loader-
|
|
2
|
+
(when auth or `ai-gateway-configuration-loader-inbound` has not already) and
|
|
3
3
|
runs its ordered inbound policy chain. Configuration comes from route-level
|
|
4
|
-
`ai-gateway-auth-
|
|
5
|
-
|
|
4
|
+
`ai-gateway-auth-inbound` or the configuration loader when either already ran,
|
|
5
|
+
otherwise from the route's `app_id` path parameter via Gateway Service.
|
|
6
6
|
Applications can still require API keys later by including
|
|
7
|
-
`ai-gateway-auth-
|
|
7
|
+
`ai-gateway-auth-inbound` in their own `inboundPolicyChain`.
|
|
8
8
|
|
|
9
9
|
Prefer placing the dedicated configuration loader before this executor on the
|
|
10
10
|
route. When the loader is omitted, this executor still loads configuration
|
|
@@ -74,7 +74,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
74
74
|
{
|
|
75
75
|
"policies": [
|
|
76
76
|
{
|
|
77
|
-
"name": "ai-gateway-auth-
|
|
77
|
+
"name": "ai-gateway-auth-inbound",
|
|
78
78
|
"policyType": "ai-gateway-auth",
|
|
79
79
|
"handler": {
|
|
80
80
|
"export": "AIGatewayAuthInboundPolicy",
|
|
@@ -85,7 +85,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
|
-
"name": "ai-gateway-configuration-loader-
|
|
88
|
+
"name": "ai-gateway-configuration-loader-inbound",
|
|
89
89
|
"policyType": "ai-gateway-configuration-loader",
|
|
90
90
|
"handler": {
|
|
91
91
|
"export": "AIGatewayConfigurationLoaderInboundPolicy",
|
|
@@ -96,7 +96,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
|
-
"name": "ai-gateway-configuration-executor-
|
|
99
|
+
"name": "ai-gateway-configuration-executor-inbound",
|
|
100
100
|
"policyType": "ai-gateway-configuration-executor",
|
|
101
101
|
"handler": {
|
|
102
102
|
"export": "AIGatewayConfigurationExecutorInboundPolicy",
|
|
@@ -107,7 +107,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
|
-
"name": "ai-gateway-metering-
|
|
110
|
+
"name": "ai-gateway-metering-inbound",
|
|
111
111
|
"policyType": "ai-gateway-metering",
|
|
112
112
|
"handler": {
|
|
113
113
|
"export": "AIGatewayMeteringInboundPolicy",
|
|
@@ -116,7 +116,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
|
-
"name": "ai-gateway-model-filtering-
|
|
119
|
+
"name": "ai-gateway-model-filtering-inbound",
|
|
120
120
|
"policyType": "ai-gateway-model-filtering",
|
|
121
121
|
"handler": {
|
|
122
122
|
"export": "AIGatewayModelFilteringInboundPolicy",
|
|
@@ -131,7 +131,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
|
-
"name": "ai-gateway-fallback-model-
|
|
134
|
+
"name": "ai-gateway-fallback-model-inbound",
|
|
135
135
|
"policyType": "ai-gateway-fallback-model",
|
|
136
136
|
"handler": {
|
|
137
137
|
"export": "AIGatewayFallbackModelInboundPolicy",
|
|
@@ -147,7 +147,7 @@ chooses the policies it needs in its `inboundPolicyChain`:
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
|
-
"name": "ai-gateway-semantic-cache-
|
|
150
|
+
"name": "ai-gateway-semantic-cache-inbound",
|
|
151
151
|
"policyType": "ai-gateway-semantic-cache",
|
|
152
152
|
"handler": {
|
|
153
153
|
"export": "AIGatewaySemanticCacheInboundPolicy",
|
|
@@ -186,8 +186,8 @@ chain:
|
|
|
186
186
|
},
|
|
187
187
|
"policies": {
|
|
188
188
|
"inbound": [
|
|
189
|
-
"ai-gateway-configuration-loader-
|
|
190
|
-
"ai-gateway-configuration-executor-
|
|
189
|
+
"ai-gateway-configuration-loader-inbound",
|
|
190
|
+
"ai-gateway-configuration-executor-inbound"
|
|
191
191
|
]
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -198,9 +198,9 @@ If you omit the loader, the executor loads the application configuration.
|
|
|
198
198
|
|
|
199
199
|
Authentication is optional and placement controls its scope:
|
|
200
200
|
|
|
201
|
-
- **App-level** — add `ai-gateway-auth-
|
|
201
|
+
- **App-level** — add `ai-gateway-auth-inbound` to an application's
|
|
202
202
|
`inboundPolicyChain`. Only that application requires an API key.
|
|
203
|
-
- **Route-level** — add `ai-gateway-auth-
|
|
203
|
+
- **Route-level** — add `ai-gateway-auth-inbound` on the route **before** the
|
|
204
204
|
loader (or before the executor on executor-only routes). That requires an API
|
|
205
205
|
key for every application on the route.
|
|
206
206
|
- **Internal applications** — for an application that is only called from inside
|
|
@@ -215,22 +215,22 @@ application-selected chains.
|
|
|
215
215
|
### 3. Set an application's policy chain
|
|
216
216
|
|
|
217
217
|
An application can inherit the options from `policies.json`. Include
|
|
218
|
-
`ai-gateway-auth-
|
|
218
|
+
`ai-gateway-auth-inbound` when this application should require an API key:
|
|
219
219
|
|
|
220
220
|
```json
|
|
221
221
|
{
|
|
222
222
|
"inboundPolicyChain": [
|
|
223
223
|
{
|
|
224
|
-
"name": "ai-gateway-auth-
|
|
224
|
+
"name": "ai-gateway-auth-inbound"
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
|
-
"name": "ai-gateway-model-filtering-
|
|
227
|
+
"name": "ai-gateway-model-filtering-inbound"
|
|
228
228
|
},
|
|
229
229
|
{
|
|
230
|
-
"name": "ai-gateway-fallback-model-
|
|
230
|
+
"name": "ai-gateway-fallback-model-inbound"
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
|
-
"name": "ai-gateway-metering-
|
|
233
|
+
"name": "ai-gateway-metering-inbound",
|
|
234
234
|
"options": {
|
|
235
235
|
"budgetRules": [
|
|
236
236
|
{
|
|
@@ -248,7 +248,7 @@ An application can inherit the options from `policies.json`. Include
|
|
|
248
248
|
}
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
|
-
"name": "ai-gateway-semantic-cache-
|
|
251
|
+
"name": "ai-gateway-semantic-cache-inbound"
|
|
252
252
|
}
|
|
253
253
|
]
|
|
254
254
|
}
|
|
@@ -265,7 +265,7 @@ An application can also provide a complete options object for an entry:
|
|
|
265
265
|
{
|
|
266
266
|
"inboundPolicyChain": [
|
|
267
267
|
{
|
|
268
|
-
"name": "ai-gateway-model-filtering-
|
|
268
|
+
"name": "ai-gateway-model-filtering-inbound",
|
|
269
269
|
"options": {
|
|
270
270
|
"models": {
|
|
271
271
|
"completions": {
|
|
@@ -290,7 +290,7 @@ under `permissions` fail closed:
|
|
|
290
290
|
{
|
|
291
291
|
"inboundPolicyChain": [
|
|
292
292
|
{
|
|
293
|
-
"name": "ai-gateway-model-filtering-
|
|
293
|
+
"name": "ai-gateway-model-filtering-inbound",
|
|
294
294
|
"permissions": {
|
|
295
295
|
"canEdit": true,
|
|
296
296
|
"canRemove": false
|
|
@@ -426,7 +426,7 @@ every request. Add a `remove-headers-inbound` entry after the metering entry:
|
|
|
426
426
|
```json
|
|
427
427
|
[
|
|
428
428
|
{ "name": "set-budget-dimension" },
|
|
429
|
-
{ "name": "ai-gateway-metering-
|
|
429
|
+
{ "name": "ai-gateway-metering-inbound" },
|
|
430
430
|
{
|
|
431
431
|
"name": "remove-headers-inbound",
|
|
432
432
|
"options": { "headers": ["x-budget-customer"] }
|
|
@@ -5,8 +5,8 @@ Applications may also include authentication in their own chain. This makes it
|
|
|
5
5
|
possible to offer different routing, caching, guardrail, metering, and tracing
|
|
6
6
|
behavior from one AI Gateway deployment.
|
|
7
7
|
|
|
8
|
-
Prefer placing `ai-gateway-configuration-loader-
|
|
9
|
-
|
|
8
|
+
Prefer placing `ai-gateway-configuration-loader-inbound` before this executor on
|
|
9
|
+
the route so loading and chain execution stay separate. When the loader is
|
|
10
10
|
omitted, this executor still loads configuration itself.
|
|
11
11
|
|
|
12
12
|
The gateway owner decides which policy declarations are available, while
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"requiresAI": true,
|
|
13
13
|
"policyType": "ai-gateway-configuration-executor",
|
|
14
14
|
"products": ["ai-gateway"],
|
|
15
|
-
"description": "Loads the app configuration for the request (when auth or the configuration loader has not already), runs the inbound policy chain from that configuration, and enforces limits inherited from parent teams or the gateway root.\n\nPlace this policy on AI Gateway routes after optional authentication and optional `ai-gateway-configuration-loader-
|
|
15
|
+
"description": "Loads the app configuration for the request (when auth or the configuration loader has not already), runs the inbound policy chain from that configuration, and enforces limits inherited from parent teams or the gateway root.\n\nPlace this policy on AI Gateway routes after optional authentication and optional `ai-gateway-configuration-loader-inbound`. When either of those already populated the app-configuration channel, this policy reuses it. Otherwise it loads the configuration with the route's `app_id` path parameter. Applications select from policies pre-declared by the gateway. Applications without a `inboundPolicyChain`, or with an empty chain, run no application-selected policies. Entry options replace the declaration's options as a complete object; omit them to inherit the declaration, including environment-backed credentials. Each occurrence receives a private deep copy of its entry options, so a policy mutating its options cannot corrupt the cached app configuration.",
|
|
16
16
|
"deprecatedMessage": "",
|
|
17
17
|
"required": ["handler"],
|
|
18
18
|
"properties": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"type": "number",
|
|
41
41
|
"default": 10,
|
|
42
42
|
"minimum": 2,
|
|
43
|
-
"description": "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-
|
|
43
|
+
"description": "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."
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
The AI Gateway Configuration Loader loads each application's configuration into
|
|
2
2
|
the request-scoped app-configuration channel. Configuration comes from
|
|
3
|
-
route-level `ai-gateway-auth-
|
|
3
|
+
route-level `ai-gateway-auth-inbound` when that policy already ran, otherwise
|
|
4
4
|
from the route's `app_id` path parameter via Gateway Service.
|
|
5
5
|
|
|
6
6
|
This policy does **not** run `inboundPolicyChain`. Pair it with
|
|
7
|
-
`ai-gateway-configuration-executor-
|
|
7
|
+
`ai-gateway-configuration-executor-inbound` when applications select policies
|
|
8
8
|
dynamically. If you omit this loader, the executor still loads configuration
|
|
9
9
|
before running the chain.
|
|
10
10
|
|
|
11
11
|
Applications can still require API keys later by including
|
|
12
|
-
`ai-gateway-auth-
|
|
12
|
+
`ai-gateway-auth-inbound` in their own `inboundPolicyChain`.
|
|
13
13
|
|
|
14
14
|
## Build an AI Gateway from scratch
|
|
15
15
|
|
|
@@ -22,7 +22,7 @@ Add the loader, the executor, and every policy an application may select to
|
|
|
22
22
|
{
|
|
23
23
|
"policies": [
|
|
24
24
|
{
|
|
25
|
-
"name": "ai-gateway-configuration-loader-
|
|
25
|
+
"name": "ai-gateway-configuration-loader-inbound",
|
|
26
26
|
"policyType": "ai-gateway-configuration-loader",
|
|
27
27
|
"handler": {
|
|
28
28
|
"export": "AIGatewayConfigurationLoaderInboundPolicy",
|
|
@@ -33,7 +33,7 @@ Add the loader, the executor, and every policy an application may select to
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
"name": "ai-gateway-configuration-executor-
|
|
36
|
+
"name": "ai-gateway-configuration-executor-inbound",
|
|
37
37
|
"policyType": "ai-gateway-configuration-executor",
|
|
38
38
|
"handler": {
|
|
39
39
|
"export": "AIGatewayConfigurationExecutorInboundPolicy",
|
|
@@ -70,8 +70,8 @@ Place the loader before the executor on each AI Gateway route:
|
|
|
70
70
|
},
|
|
71
71
|
"policies": {
|
|
72
72
|
"inbound": [
|
|
73
|
-
"ai-gateway-configuration-loader-
|
|
74
|
-
"ai-gateway-configuration-executor-
|
|
73
|
+
"ai-gateway-configuration-loader-inbound",
|
|
74
|
+
"ai-gateway-configuration-executor-inbound"
|
|
75
75
|
]
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -80,17 +80,17 @@ Place the loader before the executor on each AI Gateway route:
|
|
|
80
80
|
|
|
81
81
|
Authentication is optional and placement controls its scope:
|
|
82
82
|
|
|
83
|
-
- **App-level** — add `ai-gateway-auth-
|
|
83
|
+
- **App-level** — add `ai-gateway-auth-inbound` to an application's
|
|
84
84
|
`inboundPolicyChain`. Only that application requires an API key.
|
|
85
|
-
- **Route-level** — add `ai-gateway-auth-
|
|
85
|
+
- **Route-level** — add `ai-gateway-auth-inbound` on the route **before** the
|
|
86
86
|
loader. That requires an API key for every application on the route.
|
|
87
87
|
|
|
88
88
|
### Executor-only routes
|
|
89
89
|
|
|
90
|
-
Routes that list only `ai-gateway-configuration-executor-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
Routes that list only `ai-gateway-configuration-executor-inbound` keep working.
|
|
91
|
+
The executor loads configuration when the channel is empty, then runs the chain.
|
|
92
|
+
Use the dedicated loader when you want other route policies between load and
|
|
93
|
+
chain execution, or a clearer separation of concerns.
|
|
94
94
|
|
|
95
95
|
## Configuration checklist
|
|
96
96
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The AI Gateway Configuration Loader loads each application's configuration into
|
|
2
2
|
the request-scoped channel — reusing the channel from route-level
|
|
3
|
-
`ai-gateway-auth-
|
|
4
|
-
|
|
5
|
-
`ai-gateway-configuration-executor-
|
|
6
|
-
|
|
3
|
+
`ai-gateway-auth-inbound` when present, otherwise fetching by path `app_id`. It
|
|
4
|
+
does not run the application's policy chain; place
|
|
5
|
+
`ai-gateway-configuration-executor-inbound` after it for that. When this loader
|
|
6
|
+
is omitted, the executor still loads configuration itself.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"requiresAI": true,
|
|
13
13
|
"policyType": "ai-gateway-configuration-loader",
|
|
14
14
|
"products": ["ai-gateway"],
|
|
15
|
-
"description": "Loads the AI Gateway app configuration for the request into the request-scoped channel and does nothing else.\n\nPlace this policy on AI Gateway routes before `ai-gateway-configuration-executor-
|
|
15
|
+
"description": "Loads the AI Gateway app configuration for the request into the request-scoped channel and does nothing else.\n\nPlace this policy on AI Gateway routes before `ai-gateway-configuration-executor-inbound` when you want configuration loading separated from chain execution. When `ai-gateway-auth-inbound` already populated the channel, this policy reuses it. Otherwise it loads the configuration with the route's `app_id` path parameter.\n\nIf this policy is omitted, the configuration executor still loads configuration itself before running the application chain.",
|
|
16
16
|
"deprecatedMessage": "",
|
|
17
17
|
"required": ["handler"],
|
|
18
18
|
"properties": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"type": "number",
|
|
41
41
|
"default": 10,
|
|
42
42
|
"minimum": 2,
|
|
43
|
-
"description": "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-
|
|
43
|
+
"description": "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."
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -34,7 +34,7 @@ A fallback that names the same model as the primary selection is skipped.
|
|
|
34
34
|
|
|
35
35
|
```json
|
|
36
36
|
{
|
|
37
|
-
"name": "ai-gateway-fallback-model-
|
|
37
|
+
"name": "ai-gateway-fallback-model-inbound",
|
|
38
38
|
"policyType": "ai-gateway-fallback-model",
|
|
39
39
|
"handler": {
|
|
40
40
|
"export": "AIGatewayFallbackModelInboundPolicy",
|
|
@@ -44,15 +44,15 @@ Declare the policy in `config/policies.json`:
|
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Then select it in the application's `inboundPolicyChain` in place of
|
|
47
|
-
`ai-gateway-auth-
|
|
47
|
+
`ai-gateway-auth-inbound`. Put it first so nothing else runs for a rejected
|
|
48
48
|
request:
|
|
49
49
|
|
|
50
50
|
```json
|
|
51
51
|
{
|
|
52
52
|
"inboundPolicyChain": [
|
|
53
53
|
{ "name": "ai-gateway-internal-only-inbound" },
|
|
54
|
-
{ "name": "ai-gateway-model-filtering-
|
|
55
|
-
{ "name": "ai-gateway-metering-
|
|
54
|
+
{ "name": "ai-gateway-model-filtering-inbound" },
|
|
55
|
+
{ "name": "ai-gateway-metering-inbound" }
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
58
|
```
|
|
@@ -107,7 +107,7 @@ capability to add.
|
|
|
107
107
|
|
|
108
108
|
```json
|
|
109
109
|
{
|
|
110
|
-
"name": "ai-gateway-model-filtering-
|
|
110
|
+
"name": "ai-gateway-model-filtering-inbound",
|
|
111
111
|
"policyType": "ai-gateway-model-filtering",
|
|
112
112
|
"handler": {
|
|
113
113
|
"export": "AIGatewayModelFilteringInboundPolicy",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zuplo",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The official Zuplo CLI for local development and platform management",
|
|
6
6
|
"homepage": "https://zuplo.com/docs/cli/overview",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"zuplo": "zuplo.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@zuplo/cli": "7.
|
|
36
|
-
"@zuplo/core": "7.
|
|
37
|
-
"@zuplo/runtime": "7.
|
|
38
|
-
"@zuplo/test": "7.
|
|
35
|
+
"@zuplo/cli": "7.9.3",
|
|
36
|
+
"@zuplo/core": "7.9.3",
|
|
37
|
+
"@zuplo/runtime": "7.9.3",
|
|
38
|
+
"@zuplo/test": "7.9.3"
|
|
39
39
|
}
|
|
40
40
|
}
|