zuplo 7.1.0 → 7.1.2

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.
Files changed (36) hide show
  1. package/docs/ai-gateway/apps.mdx +28 -10
  2. package/docs/ai-gateway/cookbooks/custom-fallback.mdx +96 -0
  3. package/docs/ai-gateway/cookbooks/dynamic-model-routing.mdx +119 -0
  4. package/docs/ai-gateway/custom-policies.mdx +213 -0
  5. package/docs/ai-gateway/custom-providers.mdx +10 -2
  6. package/docs/ai-gateway/fallback.mdx +48 -75
  7. package/docs/ai-gateway/getting-started.mdx +200 -132
  8. package/docs/ai-gateway/integrations/ai-sdk.mdx +71 -28
  9. package/docs/ai-gateway/integrations/claude-code.mdx +32 -8
  10. package/docs/ai-gateway/integrations/codex.mdx +28 -10
  11. package/docs/ai-gateway/integrations/goose.mdx +26 -19
  12. package/docs/ai-gateway/integrations/langchain.mdx +31 -15
  13. package/docs/ai-gateway/integrations/openai.mdx +28 -16
  14. package/docs/ai-gateway/introduction.mdx +73 -32
  15. package/docs/ai-gateway/managing-apps.mdx +62 -17
  16. package/docs/ai-gateway/managing-providers.mdx +23 -7
  17. package/docs/ai-gateway/managing-teams.mdx +29 -12
  18. package/docs/ai-gateway/policies/akamai-ai-firewall.mdx +92 -96
  19. package/docs/ai-gateway/policies/authentication.mdx +44 -0
  20. package/docs/ai-gateway/policies/comet-opik-tracing.mdx +40 -2
  21. package/docs/ai-gateway/policies/fallback-model.mdx +40 -0
  22. package/docs/ai-gateway/policies/galileo-tracing.mdx +36 -22
  23. package/docs/ai-gateway/policies/metering.mdx +47 -0
  24. package/docs/ai-gateway/policies/model-filtering.mdx +49 -0
  25. package/docs/ai-gateway/policies/overview.mdx +28 -0
  26. package/docs/ai-gateway/policies/semantic-cache.mdx +48 -0
  27. package/docs/ai-gateway/policy-chains.mdx +178 -0
  28. package/docs/ai-gateway/policy-templates.mdx +68 -0
  29. package/docs/ai-gateway/providers.mdx +23 -9
  30. package/docs/ai-gateway/source-control.mdx +88 -0
  31. package/docs/ai-gateway/teams.mdx +16 -10
  32. package/docs/ai-gateway/universal-api.mdx +39 -12
  33. package/docs/ai-gateway/usage-limits.mdx +87 -55
  34. package/docs/policies/cdn-cache-control-outbound/doc.md +13 -13
  35. package/package.json +5 -5
  36. package/docs/ai-gateway/guardrails.mdx +0 -65
@@ -1,18 +1,24 @@
1
1
  ---
2
2
  title: AI Gateway Teams
3
3
  sidebar_label: Overview
4
+ description:
5
+ Teams manage access to AI Gateway apps, carry usage limits and policy
6
+ templates, and organize members with hierarchical sub-teams.
4
7
  ---
5
8
 
6
- Teams are used to manage access to AI Gateway applications, set usage limits,
7
- and monitor activity. Each team can have multiple members and sub-teams. Use
8
- teams to group users by department, project, or any other logical grouping.
9
+ Teams are used to manage access to AI Gateway apps, set usage limits, and
10
+ monitor activity. Each team can have multiple members and sub-teams. Use teams
11
+ to group users by department, project, or any other logical grouping.
9
12
 
10
13
  ## Teams & Apps
11
14
 
12
- Apps in the AI Gateway represent any app or integration that will call the AI
13
- Gateway. Apps in the AI Gateway are owned by a specific team. Members of the
14
- team will have permissions to perform various actions on the App depending on
15
- their permissions.
15
+ Every [app](./apps.mdx)—each service or integration that calls the AI
16
+ Gateway—belongs to exactly one team. What a team member may do to an app depends
17
+ on that member's role.
18
+
19
+ Teams also carry a [policy template](./policy-templates.mdx)—the policy chain
20
+ that apps created in the team start with—and [usage limits](./usage-limits.mdx)
21
+ that apply to all of the team's apps combined.
16
22
 
17
23
  ## Members
18
24
 
@@ -21,9 +27,9 @@ depend on their role in the Zuplo account, project, and team.
21
27
 
22
28
  There are two roles at the team level:
23
29
 
24
- - **Member**: Can access AI Providers and Apps assigned to the team.
25
- - **Admin**: Can manage team settings, members, and access AI Providers and Apps
26
- assigned to the team.
30
+ - **Member**: Can access the AI providers and apps assigned to the team.
31
+ - **Admin**: Can manage team settings and members, and access the AI providers
32
+ and apps assigned to the team.
27
33
 
28
34
  For more information on roles and permissions, see the
29
35
  [document on roles and permissions](../articles/accounts/roles-and-permissions.mdx).
@@ -1,36 +1,46 @@
1
1
  ---
2
2
  title: AI Gateway Universal API
3
3
  sidebar_label: Universal API
4
+ description:
5
+ Every AI Gateway app exposes an OpenAI-compatible API. Point your SDK's base
6
+ URL at the app's gateway URL and reference models as providerName/model.
4
7
  ---
5
8
 
6
9
  Zuplo AI Gateway provides a universal API that standardizes interactions with
7
10
  various AI providers. This API follows the
8
11
  [OpenAI API specification](https://platform.openai.com/docs/api-reference/introduction),
9
- making it easy to integrate with existing applications that already use OpenAI's
10
- API.
12
+ making it easy to integrate with existing apps that already use OpenAI's API.
11
13
 
12
14
  ## Using the Universal API
13
15
 
14
- The Universal API is automatically enabled for all AI Gateway applications.
15
- Using this endpoint is as simple as changing your API base URL to point to
16
- Zuplo. For example, if your Zuplo application is hosted at
17
- `https://my-ai-gateway.zuplo.app`, you can simply change the base URL in your
18
- API client to `https://my-ai-gateway.zuplo.app/v1`.
16
+ Every AI Gateway app serves the Universal API. The app page in the portal shows
17
+ each app's **API URL**, which ends in the app's ID—for example
18
+ `https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e`.
19
+ Client libraries expect a base URL ending in `/v1`, so append that suffix. When
20
+ the gateway runs the
21
+ [authentication policy](./policy-chains.mdx#authentication), send the app's API
22
+ key as a bearer token.
23
+
24
+ Models are referenced as `providerName/model`, where `providerName` is the
25
+ provider name configured in your gateway. This is how the gateway knows which
26
+ provider to route each request to—and it means one app can use models from
27
+ several providers through the same endpoint.
19
28
 
20
29
  If you are using an SDK or library that supports custom base URLs, you can
21
- configure it to use your Zuplo application's URL. For example, with the OpenAI
22
- Node.js SDK, you can set the `baseURL` option:
30
+ configure it to use your app's URL. For example, with the OpenAI Node.js SDK,
31
+ you can set the `baseURL` option:
23
32
 
24
33
  ```ts
25
34
  import OpenAI from "openai";
26
35
 
27
36
  const client = new OpenAI({
28
- apiKey: process.env.ZUPLO_API_KEY,
29
- baseURL: "https://my-ai-gateway.zuplo.app/v1",
37
+ apiKey: process.env.ZUPLO_APP_API_KEY,
38
+ baseURL:
39
+ "https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e/v1",
30
40
  });
31
41
 
32
42
  const response = await client.chat.completions.create({
33
- model: "gpt-4",
43
+ model: "openai/gpt-5-mini",
34
44
  messages: [
35
45
  {
36
46
  role: "user",
@@ -41,3 +51,20 @@ const response = await client.chat.completions.create({
41
51
 
42
52
  console.log(response.choices[0].message.content);
43
53
  ```
54
+
55
+ :::tip
56
+
57
+ If the app's [Model Filtering](./policies/model-filtering.mdx) policy has an
58
+ allow list, a request that omits `model` uses the first model in the list—so
59
+ clients that can't set a model still work.
60
+
61
+ :::
62
+
63
+ ## Supported endpoints
64
+
65
+ | Endpoint | Notes |
66
+ | ---------------------- | ------------------------------------------------------ |
67
+ | `/v1/chat/completions` | Chat completions for every provider |
68
+ | `/v1/embeddings` | Embeddings for every provider except Anthropic |
69
+ | `/v1/responses` | OpenAI Responses API, for OpenAI-backed providers |
70
+ | `/v1/messages` | Anthropic Messages API, for Anthropic-backed providers |
@@ -1,88 +1,118 @@
1
1
  ---
2
2
  title: "Usage Limits & Thresholds"
3
3
  sidebar_label: "Usage Limits"
4
+ description:
5
+ Set hierarchical spending, token, and request limits at the gateway, team, and
6
+ app levels, with warning thresholds and quota fallbacks.
4
7
  ---
5
8
 
6
9
  The Zuplo AI Gateway provides hierarchical usage limits and budget controls to
7
- manage LLM spending across your organization. Limits can be set at the
8
- organization, team, and application levels.
10
+ manage LLM spending across your organization. Limits can be set at the gateway,
11
+ team, and app levels.
9
12
 
10
13
  ## Budget Hierarchy
11
14
 
12
- Budget limits cascade down through your organizational structure:
15
+ Limits at every level apply together—a request is blocked when _any_ level's
16
+ limit is exceeded, and the error names the level that blocked it:
13
17
 
14
- - **Root Team** - Organization-wide limits (for example, $1,000/day)
15
- - **Sub-Teams** - Team-specific limits that cannot exceed the parent team's
16
- budget (for example, $500/day for the Engineering team)
17
- - **Applications** - Per-app limits for granular control (for example, $10/day
18
- for a hackathon project)
18
+ - **Gateway** - Organization-wide limits (for example, $1,000/day), covering all
19
+ teams and apps combined
20
+ - **Teams** - Team-specific limits covering all of the team's apps combined (for
21
+ example, $500/day for the Engineering team)
22
+ - **Apps** - Per-app limits for granular control (for example, $10/day for a
23
+ hackathon project)
19
24
 
20
- A sub-team's budget can never exceed the available budget from its parent team.
21
- Similarly, an application's budget cannot exceed its owning team's budget.
25
+ ## Where limits are configured
22
26
 
23
- ## Configuring Limits
27
+ | Level | Where |
28
+ | ------- | --------------------------------------------------------------------------------- |
29
+ | Gateway | **Settings → Usage Limits** |
30
+ | Team | The team's **Usage & Limits** tab |
31
+ | App | The **Budgets and Costs** policy in the app's [policy chain](./policy-chains.mdx) |
24
32
 
25
- ### Daily Budgets
33
+ Each level supports the same three meters, each with independent daily and
34
+ monthly settings:
26
35
 
27
- Set a maximum daily spend for a team or application. When the daily budget is
28
- reached, requests are either blocked or flagged with a warning depending on your
29
- enforcement configuration.
36
+ - **Budget** - spend in dollars
37
+ - **Tokens** - input plus output tokens
38
+ - **Requests** - request count
30
39
 
31
- To configure daily budgets:
40
+ For each meter and period you can set a **Limit** (usage at or above it gets
41
+ blocked) and a **Warning** threshold (a percentage of the limit that triggers a
42
+ warning notification without blocking). Leave a field empty to not enforce it.
32
43
 
33
- 1. Open your AI Gateway project in the Zuplo Portal
34
- 2. Select the [Teams](https://portal.zuplo.com/+/account/project/ai/teams) or
35
- [Apps](https://portal.zuplo.com/+/account/project/ai/apps) tab
36
- 3. Click on the team or app to edit
37
- 4. Select the **Usage & Limits** tab and configure the **Daily Budget** field
38
- 5. Click **Save Changes**
44
+ :::note
39
45
 
40
- ### Monthly Budgets
46
+ Daily and monthly periods are anchored to your gateway, not the calendar: a
47
+ daily period rolls over at the time of day (UTC) the gateway was created, and a
48
+ monthly period runs anchor-day to anchor-day. Changing a limit mid-period
49
+ doesn't reset the period's usage.
41
50
 
42
- Set a maximum monthly spend for applications. Monthly budgets reset on the first
43
- day of each calendar month.
51
+ :::
44
52
 
45
- ### Rate Limits
53
+ ## Setting an app's limits
46
54
 
47
- In addition to budget-based limits, you can configure request rate limits to
48
- control the volume of requests flowing through the gateway.
55
+ <Stepper>
49
56
 
50
- ## Enforcement Modes
57
+ 1. Open the [Apps](https://portal.zuplo.com/+/account/project/ai/apps) tab and
58
+ select the app.
51
59
 
52
- When a limit is reached, the AI Gateway can operate in two modes:
60
+ 1. On the **Policies** tab, configure the **Budgets and Costs** policy (add it
61
+ from **Add Policy** if the chain doesn't have it).
53
62
 
54
- - **Enforce** - Requests are blocked and an error response is returned to the
55
- caller
56
- - **Warn** - Requests are allowed through but a warning notification is
57
- generated
63
+ 1. Set daily or monthly limits for budget, tokens, or requests, and optional
64
+ warning thresholds.
58
65
 
59
- ## Monitoring Usage
66
+ 1. Save. The change applies within about a minute.
60
67
 
61
- Track current usage and spending through the AI Gateway dashboard:
68
+ </Stepper>
62
69
 
63
- 1. Open the
64
- [**Analytics**](https://portal.zuplo.com/+/account/project/ai/analytics) tab
65
- of your AI Gateway project
66
- 2. Click on an app and select **Dashboard**
67
- 3. View real-time metrics including:
68
- - Request count
69
- - Token usage (input and output)
70
- - Current spending against budget
71
- - Time to first byte
70
+ :::note
72
71
 
73
- ## Semantic Caching
72
+ Each period in the Budgets and Costs policy's options carries an `enabled` flag
73
+ next to its number, and so does each warning threshold. A period enforces
74
+ nothing until `enabled` is `true` _and_ `limit` is set—options that set only
75
+ `limit` are silently inert. Watch for this when editing the policy's options
76
+ directly, such as in `config/policies.json` or a
77
+ [policy template](./policy-templates.mdx).
74
78
 
75
- Enable semantic caching on applications to reduce costs by identifying and
76
- returning cached responses for similar prompts. This can significantly reduce
77
- token usage and spending, especially for applications with repeated or similar
78
- queries.
79
+ :::
79
80
 
80
- To enable semantic caching:
81
+ If the app has a **quota fallback** model configured, an exceeded limit routes
82
+ requests to that model instead of blocking with a `429`—see
83
+ [Fallback Models](./fallback.mdx). The fallback's usage still counts toward the
84
+ limits.
81
85
 
82
- 1. Open the [Apps](https://portal.zuplo.com/+/account/project/ai/apps) tab and
83
- click on the app to edit
84
- 2. Enable the **Semantic Caching** toggle under **Advanced Features**
85
- 3. Save your changes
86
+ :::warning
87
+
88
+ An app without the Budgets and Costs policy in its chain doesn't enforce
89
+ app-level limits. Team and gateway limits still protect overall spend, but
90
+ per-app budgets need Budgets and Costs in the chain—use a
91
+ [policy template](./policy-templates.mdx) to make sure every app starts with it.
92
+
93
+ :::
94
+
95
+ :::caution{title="Budgets fail open by default"}
96
+
97
+ The Budgets and Costs policy's `throwOnFailure` option defaults to `false`, so
98
+ if the metering service is unavailable the request proceeds unmetered: no limit
99
+ is checked and the request reaches the provider even if the app is already over
100
+ budget. Set `throwOnFailure` to `true` to fail closed instead, so a metering
101
+ outage rejects the request rather than letting it escape the budget.
102
+
103
+ :::
104
+
105
+ ## Monitoring Usage
106
+
107
+ Each app, team, and the gateway show current usage against their limits:
108
+
109
+ 1. Open the [Apps](https://portal.zuplo.com/+/account/project/ai/apps) or
110
+ [Teams](https://portal.zuplo.com/+/account/project/ai/teams) tab and select
111
+ an app or team
112
+ 2. The **Overview** tab shows daily and monthly usage—spend, tokens, and
113
+ requests—with progress against any configured limits
114
+ 3. For request-level metrics (request count, token usage, time to first byte),
115
+ open the app's **Dashboard**
86
116
 
87
117
  ## Related Resources
88
118
 
@@ -90,3 +120,5 @@ To enable semantic caching:
90
120
  project with budget controls
91
121
  - [Managing Teams](./managing-teams.mdx) - Configure team-level budgets
92
122
  - [Managing Apps](./managing-apps.mdx) - Configure app-level limits
123
+ - [Fallback Models](./fallback.mdx) - Serve a cheaper model instead of blocking
124
+ when a limit is exceeded
@@ -173,8 +173,8 @@ policy to that route.** There is no configuration that lets a backend-set
173
173
  targeted header through: `edge` is required unless `cacheConfig` supplies it at
174
174
  runtime, and the vendor's headers are stripped on every path — including when a
175
175
  response is opted out with `cache: false`, which removes them and writes nothing
176
- in their place. `client.mode: "preserve"` preserves the _client_
177
- `Cache-Control` only; it has no bearing on the edge headers.
176
+ in their place. `client.mode: "preserve"` preserves the _client_ `Cache-Control`
177
+ only; it has no bearing on the edge headers.
178
178
 
179
179
  ## tags
180
180
 
@@ -226,13 +226,13 @@ The names you configure are **unioned** with any `Vary` the upstream already
226
226
  sent, deduplicated case-insensitively; `Vary: *` from either side absorbs the
227
227
  rest. Unlike the edge headers, `Vary` is still emitted when an upstream veto or
228
228
  `cache: false` suppresses edge caching — a `private, max-age=300` response is
229
- uncacheable at the edge but still cached by the browser, and it needs the variant
230
- key just as much. The policy never narrows an upstream `Vary`, because doing so silently is
231
- unsafe: if the origin sent `Vary: Authorization` and you configure
232
- `vary: ["accept-language"]`, replacing it would stop a shared cache keying on
233
- `Authorization` and let it serve one user's authorized response to another. To
234
- deliberately drop a wasteful upstream `Vary` — `Vary: User-Agent` shreds hit
235
- rates — remove it in a separate outbound policy before this one runs.
229
+ uncacheable at the edge but still cached by the browser, and it needs the
230
+ variant key just as much. The policy never narrows an upstream `Vary`, because
231
+ doing so silently is unsafe: if the origin sent `Vary: Authorization` and you
232
+ configure `vary: ["accept-language"]`, replacing it would stop a shared cache
233
+ keying on `Authorization` and let it serve one user's authorized response to
234
+ another. To deliberately drop a wasteful upstream `Vary` — `Vary: User-Agent`
235
+ shreds hit rates — remove it in a separate outbound policy before this one runs.
236
236
 
237
237
  If your response genuinely varies by a request header, configure the cache key
238
238
  at the CDN — Cache ID Modification on Akamai, Cache Keys on Cloudflare — rather
@@ -283,10 +283,10 @@ message naming the cause, rather than letting the response go out truncated.
283
283
 
284
284
  The three return values:
285
285
 
286
- | Return | Effect |
287
- | ------------------ | ----------------------------------------------------------------------------------- |
288
- | `undefined`/`null` | Use the static options unchanged. |
289
- | a config object | Use it in place of the static options. |
286
+ | Return | Effect |
287
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
288
+ | `undefined`/`null` | Use the static options unchanged. |
289
+ | a config object | Use it in place of the static options. |
290
290
  | `{ cache: false }` | Emit no edge headers or tags, **and** send `Cache-Control: no-store` to the client — except under `client.mode: "preserve"`, which is a trap; see below. |
291
291
 
292
292
  `{ cache: false }` is a positive statement that the response must not be cached
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zuplo",
3
- "version": "7.1.0",
3
+ "version": "7.1.2",
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": "7.1.0",
23
- "@zuplo/core": "7.1.0",
24
- "@zuplo/runtime": "7.1.0",
25
- "@zuplo/test": "7.1.0"
22
+ "@zuplo/cli": "7.1.2",
23
+ "@zuplo/core": "7.1.2",
24
+ "@zuplo/runtime": "7.1.2",
25
+ "@zuplo/test": "7.1.2"
26
26
  }
27
27
  }
@@ -1,65 +0,0 @@
1
- ---
2
- title: Zuplo AI Guardrails
3
- sidebar_label: Overview
4
- ---
5
-
6
- The Zuplo AI Gateway supports guardrails to protect your AI-powered applications
7
- from security threats, ensure compliance, and maintain quality in both requests
8
- and responses flowing through the gateway.
9
-
10
- ## Available Guardrail Policies
11
-
12
- ### Akamai AI Firewall
13
-
14
- The [Akamai AI Firewall](./policies/akamai-ai-firewall.mdx) provides
15
- enterprise-grade security for AI applications, including:
16
-
17
- - **Prompt injection defense** - Protects against attackers manipulating AI
18
- models through deceptive inputs
19
- - **Data loss prevention (DLP)** - Detects and blocks sensitive data leaks in
20
- AI-generated responses and incoming requests
21
- - **Toxic content filtering** - Flags hate speech, misinformation, and offensive
22
- content
23
- - **Adversarial AI security** - Protects against remote code execution, model
24
- back doors, and data poisoning attacks
25
-
26
- ## Observability & Tracing
27
-
28
- Guardrails work alongside observability policies to provide visibility into AI
29
- interactions:
30
-
31
- - [Comet Opik Tracing](./policies/comet-opik-tracing.mdx) - Trace and monitor AI
32
- interactions with Comet's Opik platform
33
- - [Galileo Tracing](./policies/galileo-tracing.mdx) - Monitor AI quality and
34
- performance with Galileo
35
-
36
- ## How Guardrails Work
37
-
38
- Guardrails are applied as policies on your AI Gateway routes. They inspect both
39
- inbound requests (prompts sent to LLM providers) and outbound responses (content
40
- returned from LLM providers) in real-time.
41
-
42
- When a guardrail detects a policy violation:
43
-
44
- 1. The request or response is blocked before reaching its destination
45
- 2. An appropriate error response is returned to the caller
46
- 3. The violation is logged for audit and monitoring purposes
47
-
48
- ## Getting Started
49
-
50
- To add guardrails to your AI Gateway:
51
-
52
- 1. Open your [project](https://portal.zuplo.com/+/account/project/) associated
53
- with your AI Gateway in the Zuplo Portal
54
- 2. Open the **Code** tab and select your `routes.oas.json` file
55
- 3. Select the route for your AI Gateway endpoint
56
- 4. Click **Add Policy** and search for the guardrail you want to add
57
- 5. Configure the policy settings and click **OK**
58
- 6. Save your changes to deploy
59
-
60
- ## Custom Guardrails
61
-
62
- You can build custom guardrails using Zuplo's programmable gateway. Create a
63
- custom inbound or outbound policy that inspects request/response content and
64
- applies your own rules. This allows you to implement organization-specific
65
- content policies, regulatory compliance checks, or domain-specific validation.