Repository navigation
feat(agents): zdr and vendorKey options for createAI - #2571
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 324f536 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Comment on lines
+218
to
+235
| When the gateway stores several keys for one provider, `byokAlias` picks one | ||
| by alias. `zdr: true` sends a unified-billing request only to upstreams with | ||
| Zero Data Retention, and `zdr: false` turns it off for a gateway that has it | ||
| on. Both travel as `cf-aig-byok-alias` / `cf-aig-zdr` on the universal request | ||
| and do nothing for a Workers AI model. | ||
|
|
||
| To use a key you hold yourself rather than one stored on the gateway, give it | ||
| to the vendor's provider and set `vendorKey: "request"`, which forwards the | ||
| credential header instead of stripping it: | ||
|
|
||
| ```ts | ||
| const anthropic = createAnthropic({ apiKey: env.ANTHROPIC_API_KEY }); | ||
| const model = ai(anthropic("claude-opus-4-8"), { vendorKey: "request" }); | ||
| ``` | ||
|
|
||
| `vendorKey` belongs to the model it is set on (`ai(model, …)` or | ||
| `ai.routed(model, …)`). A fallback leg does not inherit it, so a chain can mix | ||
| a model on your key with one on unified billing. |
Contributor
Comment on lines
+184
to
+187
| const dropped = new Set([ | ||
| ...(vendorKey === "request" ? [] : route.authHeaders), | ||
| "content-length" | ||
| ]); |
Contributor
There was a problem hiding this comment.
Contributor
🟡 agents import sizes: 6 entry points grew
Changed exports (54)
…and 4 more exports in the workflow artifact. How this worksEach runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement. Compared |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
7 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a gateway option and a model option to
createAI, for vendor models routed through AI Gateway:zdrturns Zero Data Retention on or off for one request on unified billing, whatever the gateway's own setting.vendorKey: "request"(AI SDK only, per model) forwards the key the vendor's provider put on the request, instead of stripping it.ai-gateway-providerandworkers-ai-provider/gatewayhave both of these andcreateAIdidn't (#2569, cloudflare/ai#675).zdris an ordinary gateway option: flat or nested, on any layer, inherited by fallback legs. The gateway readscf-aig-zdroff the universal request itself (Universal.prepare), not off a provider entry, so the core transport sends it in the binding'sextraHeaders. pi-ai gets it too. The Workers AI run path doesn't send it.vendorKeybelongs to the model it was set on. A fallback leg doesn't inherit it, so a chain can mix a model on your own key with one on unified billing. A re-wrapped model keeps it. With a key on the entry, the gateway uses it and turns unified billing off for that request.pnpm run checkand the model tests (src/tests/models) pass.