Repository navigation
feat(agents): AI Gateway dynamic routes in createAI - #2572
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: fe09d29 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 |
7 tasks
Comment on lines
+89
to
+90
| // 2b. An AI Gateway dynamic route — the route on the gateway picks the model. | ||
| ai("dynamic/support"); |
Contributor
There was a problem hiding this comment.
Comment on lines
+96
to
+99
| const ai = createAI({ binding: asAi(binding), id: "prod" }); | ||
| const { message } = await collectEvents( | ||
| ai.stream(ai("dynamic/support"), userContext("hi")) | ||
| ); |
Contributor
Contributor
🟡 agents import sizes: 2 entry points grew
Changed exports (17)
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: |
mattzcarey
force-pushed
the
feat/createai-dynamic-routes
branch
from
October 12, 2026 15:54
913d367 to
6949445
Compare
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.
createAInow takes AI Gateway dynamic routes asai("dynamic/<route>"), in bothagents/models/ai-sdkandagents/models/pi-ai. The route runs onenv.AI.rununder the configured gateway, and it can also be a fallback leg, per model or per call.workers-ai-providersupports dynamic routes, andcreateAIrejected anything that wasn't@cf/(#2569, cloudflare/ai#675).dynamic/ids from/run(DynamicRoutesModel). It accepts OpenAI chat-completions input with nomodel, passes streams through, and answers a non-streaming call in chat-completions shape. That's what the existing Workers AI language model sends and reads, so a route reuses it. The id isn't@cf/, so it gets the strict-OpenAI request profile:chatTemplateKwargsis dropped with a warning, because the route may not land on Workers AI.ai.embeddingand the other modality methods still accept only@cf/legs, including per-call legs fromproviderOptions.cloudflare, and adynamic/leg there gets an error that says so.DynamicRouteId,isDynamicRouteIdandisRunPathLanguageModelIdlive incore/catalog.ts, so both frameworks share one gate.pnpm run checkand the model tests (src/tests/models) pass.