zuplo 6.73.30 → 6.73.31
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.
|
@@ -76,17 +76,24 @@ const { text } = await generateText({
|
|
|
76
76
|
|
|
77
77
|
### Google
|
|
78
78
|
|
|
79
|
+
The `@ai-sdk/google` provider speaks Gemini's native protocol: it sends requests
|
|
80
|
+
to `/models/{model}:generateContent` and authenticates with the `x-goog-api-key`
|
|
81
|
+
header, neither of which the AI Gateway serves. Use the
|
|
82
|
+
[OpenAI-compatible provider](https://ai-sdk.dev/providers/openai-compatible-providers)
|
|
83
|
+
instead — the AI Gateway translates OpenAI-format requests to Google upstream.
|
|
84
|
+
|
|
79
85
|
```typescript
|
|
80
|
-
import {
|
|
86
|
+
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
81
87
|
import { generateText } from "ai";
|
|
82
88
|
|
|
83
|
-
const
|
|
89
|
+
const gateway = createOpenAICompatible({
|
|
90
|
+
name: "zuplo-ai-gateway",
|
|
84
91
|
apiKey: process.env.ZUPLO_AI_GATEWAY_API_KEY,
|
|
85
92
|
baseURL: "https://my-ai-gateway.zuplo.app/v1",
|
|
86
93
|
});
|
|
87
94
|
|
|
88
95
|
const { text } = await generateText({
|
|
89
|
-
model:
|
|
96
|
+
model: gateway("gemini-2.5-flash"),
|
|
90
97
|
prompt: "Write a one-sentence bedtime story about a unicorn.",
|
|
91
98
|
});
|
|
92
99
|
```
|
|
@@ -1,9 +1,73 @@
|
|
|
1
1
|
# AI Gateway Model Filtering (v2) Policy
|
|
2
2
|
|
|
3
|
-
Use this policy
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Use this policy when an AI Gateway route must restrict which models clients may
|
|
4
|
+
select. The policy is optional.
|
|
5
|
+
|
|
6
|
+
Choose the setup that matches the route:
|
|
7
|
+
|
|
8
|
+
- Omit Model Filtering to let each request select any available model. Every
|
|
9
|
+
request must provide `model` as `providerName/model`.
|
|
10
|
+
- Use an `allowList` to expose a curated set of models and provide a default
|
|
11
|
+
model.
|
|
12
|
+
- Use a `blockList` to permit available models except for specific exclusions.
|
|
13
|
+
- Use a custom routing policy when model selection depends on request data or
|
|
14
|
+
application logic that an allow list or block list cannot express.
|
|
15
|
+
|
|
16
|
+
`providerName` is the Provider Name configured in the Zuplo Portal. The text
|
|
17
|
+
after the first slash is the provider-specific model ID, so model IDs may
|
|
18
|
+
contain additional slashes.
|
|
19
|
+
|
|
20
|
+
## Routing without Model Filtering
|
|
21
|
+
|
|
22
|
+
When neither Model Filtering nor a custom routing policy selects a model, the AI
|
|
23
|
+
Gateway handler reads the request body's `model` and uses it as the primary
|
|
24
|
+
routing target:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"model": "openai/gpt-4o-mini",
|
|
29
|
+
"messages": [{ "role": "user", "content": "Hello" }]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The handler validates that:
|
|
34
|
+
|
|
35
|
+
- `model` is a string in `providerName/model` form;
|
|
36
|
+
- the Provider Name is configured;
|
|
37
|
+
- the model is available for the route's capability;
|
|
38
|
+
- the Provider Assignment has usable credentials.
|
|
39
|
+
|
|
40
|
+
Missing, bare, non-string, or malformed model values receive an
|
|
41
|
+
OpenAI-compatible 400 `invalid_request_error`. A validly formatted target that
|
|
42
|
+
cannot be fulfilled is reported as a routing configuration error with a
|
|
43
|
+
suggested fix.
|
|
44
|
+
|
|
45
|
+
When Semantic Cache is attached, a cache hit also validates request-derived
|
|
46
|
+
routing before returning the cached response. A removed, deprecated, or
|
|
47
|
+
otherwise unavailable target therefore follows the same routing configuration
|
|
48
|
+
error path instead of bypassing validation with a cached response. Native route
|
|
49
|
+
requirements are checked too, so an Anthropic Messages cache hit cannot be
|
|
50
|
+
served by an OpenAI-backed Provider Name.
|
|
51
|
+
|
|
52
|
+
Attach Model Filtering only when the gateway must enforce model-selection rules.
|
|
53
|
+
An attached policy must always have a valid, non-empty `models` configuration.
|
|
54
|
+
|
|
55
|
+
### Responses management operations
|
|
56
|
+
|
|
57
|
+
These Responses API operations do not have a request body:
|
|
58
|
+
|
|
59
|
+
- `GET /v1/responses/:responseId`
|
|
60
|
+
- `GET /v1/responses/:responseId/input_items`
|
|
61
|
+
- `DELETE /v1/responses/:responseId`
|
|
62
|
+
|
|
63
|
+
Because they cannot supply `model`, they require routing to be selected before
|
|
64
|
+
the handler runs. Configure a `completions.allowList` in Model Filtering so its
|
|
65
|
+
first entry supplies the default, or use a custom inbound policy that calls
|
|
66
|
+
`AIGatewayModelRouting.set(context, { completions: "providerName/model" })`.
|
|
67
|
+
Without preselected routing, the handler returns an OpenAI-compatible 400
|
|
68
|
+
`invalid_request_error` with this configuration guidance.
|
|
69
|
+
|
|
70
|
+
## Policy order
|
|
7
71
|
|
|
8
72
|
Place Model Filtering before Fallback Model in the inbound policy chain:
|
|
9
73
|
|
|
@@ -13,7 +77,8 @@ Model Filtering -> Fallback Model -> AI Gateway handler
|
|
|
13
77
|
|
|
14
78
|
Model Filtering accepts or rejects the request and creates the primary model
|
|
15
79
|
selection. Fallback Model can then enrich that allowed selection without
|
|
16
|
-
bypassing the filter.
|
|
80
|
+
bypassing the filter. Fallback Model does not create a primary selection by
|
|
81
|
+
itself.
|
|
17
82
|
|
|
18
83
|
## Options
|
|
19
84
|
|
|
@@ -25,9 +90,17 @@ chooses exactly one mode:
|
|
|
25
90
|
- `blockList` leaves the catalog open except for named models. Every request
|
|
26
91
|
must include `model`.
|
|
27
92
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
93
|
+
Each configured list must contain at least one entry. A capability cannot define
|
|
94
|
+
both `allowList` and `blockList`, and unsupported fields are rejected. Every
|
|
95
|
+
list entry is a plain `providerName/model` string. Matching is case-insensitive,
|
|
96
|
+
while configured casing is preserved for the upstream request. Route-target
|
|
97
|
+
objects and fallback fields belong in the Fallback Model policy.
|
|
98
|
+
|
|
99
|
+
Configure every capability served by a route using this policy. A route using
|
|
100
|
+
`/v1/embeddings` needs `embeddings`; Chat Completions, Responses, and Anthropic
|
|
101
|
+
Messages routes need `completions`. If the policy is attached but the active
|
|
102
|
+
capability has no rules, the request receives a 403 response explaining which
|
|
103
|
+
capability to add.
|
|
31
104
|
|
|
32
105
|
## Allow-list example
|
|
33
106
|
|
|
@@ -70,14 +143,30 @@ reported as warnings because they cannot match a request.
|
|
|
70
143
|
|
|
71
144
|
## Request behavior
|
|
72
145
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
146
|
+
| Situation | Result |
|
|
147
|
+
| --------------------------------------------------- | ------------------------------------------------------ |
|
|
148
|
+
| Allow list, request omits `model` | The first allow-list entry is selected. |
|
|
149
|
+
| Allow list, request names a listed model | The matching configured entry is selected. |
|
|
150
|
+
| Allow list, request names an unlisted model | 403 response listing the allowed models. |
|
|
151
|
+
| Block list, request omits `model` | 400 response asking for `providerName/model`. |
|
|
152
|
+
| Block list, request names a blocked model | 403 response. |
|
|
153
|
+
| Either mode, request uses a bare or malformed model | 400 response explaining the required format. |
|
|
154
|
+
| Policy has no rules for the route capability | 403 response explaining which capability to configure. |
|
|
155
|
+
| Another inbound policy already selected routing | Model Filtering leaves that selection unchanged. |
|
|
77
156
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
157
|
+
Native routes also enforce provider type. `/v1/responses` requires a Provider
|
|
158
|
+
Name backed by OpenAI, and `/v1/messages` requires a Provider Name backed by
|
|
159
|
+
Anthropic. Provider Names may be custom labels; validation uses the provider
|
|
160
|
+
type configured for that Provider Assignment.
|
|
161
|
+
|
|
162
|
+
For example, this embedding request is evaluated against `models.embeddings`:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"model": "openai/text-embedding-3-small",
|
|
167
|
+
"input": "Search text"
|
|
168
|
+
}
|
|
169
|
+
```
|
|
81
170
|
|
|
82
171
|
## Adding fallbacks
|
|
83
172
|
|
|
@@ -143,6 +232,18 @@ Attach the module as an ordinary inbound policy instead of Model Filtering:
|
|
|
143
232
|
|
|
144
233
|
`AIGatewayModelRouting.get(context)` returns the sanitized, normalized routing
|
|
145
234
|
for the current request and never returns credentials. The AI Gateway handler
|
|
146
|
-
consumes a custom selection even when Model Filtering is not attached.
|
|
147
|
-
|
|
148
|
-
|
|
235
|
+
consumes a custom selection even when Model Filtering is not attached. If
|
|
236
|
+
neither kind of policy creates a selection, the handler derives one from the
|
|
237
|
+
request's required `providerName/model`.
|
|
238
|
+
|
|
239
|
+
Policy order determines precedence:
|
|
240
|
+
|
|
241
|
+
1. Routing selected before Model Filtering remains authoritative because Model
|
|
242
|
+
Filtering leaves an existing selection unchanged.
|
|
243
|
+
2. Model Filtering creates routing when no earlier policy selected it.
|
|
244
|
+
3. A custom policy placed after Model Filtering may deliberately replace that
|
|
245
|
+
selection.
|
|
246
|
+
4. If no policy selects routing, the handler derives it from the request.
|
|
247
|
+
|
|
248
|
+
Prefer one policy as the primary selector so the route's intent is easy to
|
|
249
|
+
understand.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zuplo",
|
|
3
|
-
"version": "6.73.
|
|
3
|
+
"version": "6.73.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The programmable API Gateway",
|
|
6
6
|
"author": "Zuplo, Inc.",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"zuplo": "zuplo.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@zuplo/cli": "6.73.
|
|
23
|
-
"@zuplo/core": "6.73.
|
|
24
|
-
"@zuplo/runtime": "6.73.
|
|
22
|
+
"@zuplo/cli": "6.73.31",
|
|
23
|
+
"@zuplo/core": "6.73.31",
|
|
24
|
+
"@zuplo/runtime": "6.73.31",
|
|
25
25
|
"@zuplo/test": "1.4.4"
|
|
26
26
|
}
|
|
27
27
|
}
|