Skip to content

feat(core): add Cloudflare AI Gateway to the model router#19284

Open
brennanmceachran wants to merge 2 commits into
mastra-ai:mainfrom
brennanmceachran:feat/cloudflare-ai-gateway-model-router
Open

feat(core): add Cloudflare AI Gateway to the model router#19284
brennanmceachran wants to merge 2 commits into
mastra-ai:mainfrom
brennanmceachran:feat/cloudflare-ai-gateway-model-router

Conversation

@brennanmceachran

@brennanmceachran brennanmceachran commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Cloudflare AI Gateway to the model router with the same string DX as the other built-in gateways:

const agent = new Agent({
  model: "cloudflare-ai-gateway/anthropic/claude-3-5-haiku",
});

configured via CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_GATEWAY_ID, and CLOUDFLARE_API_TOKEN.

cloudflare-ai-gateway is already listed on models.dev (78 models, already named {provider}/{model}, env vars declared) but its entry has no api URL because Cloudflare's endpoint is account-scoped — so the registry generator's hasApiAndEnv filter dropped it. This PR supplies the URL through the existing PROVIDER_OVERRIDES mechanism (same as mistral/groq/moonshotai), routing through Cloudflare's OpenAI-compatible endpoint with env-var URL templating — the same mechanism cloudflare-workers-ai uses today:

https://gateway.ai.cloudflare.com/v1/${CLOUDFLARE_ACCOUNT_ID}/${CLOUDFLARE_GATEWAY_ID}/compat

Mastra v0 shipped this provider natively; it fell out in the v1 registry pipeline because of the missing api field. This restores it and promotes it to the Gateways docs section.

Changes

  • packages/core/src/llm/model/gateways/models-dev.tsPROVIDER_OVERRIDES entry (URL template + CLOUDFLARE_API_TOKEN as auth; the other two env vars are consumed by the URL template, mirroring the guard from [BUG] Cloudflare API Key #14510).
  • packages/core/scripts/generate-model-docs.ts — list cloudflare-ai-gateway in GATEWAY_PROVIDERS, display-name special case, gateway description, and a Configuration block that now lists URL-template env vars (so account/gateway IDs show up) with a Cloudflare-specific note that provider keys live in the Cloudflare dashboard (BYOK) rather than in env.
  • Regenerated provider-registry.json, provider-types.generated.d.ts, capabilities/, and model docs via the canonical generate:providers + generate-model-docs.ts scripts (this also picked up a few hours of routine models.dev drift, same as the 6-hourly automated refresh).
  • Removed the now-superseded AI-SDK stub page docs/src/content/en/models/providers/cloudflare-ai-gateway.mdx (the generator no longer emits it once the provider is in the registry; it's replaced by docs/src/content/en/models/gateways/cloudflare-ai-gateway.mdx).
  • Tests:
    • cloudflare-ai-gateway-url.test.ts — mirrors cloudflare-workers-ai-url.test.ts: a real agent.stream() asserts the interpolated baseURL, the CLOUDFLARE_API_TOKEN api key, and that the model id keeps its {provider}/{model} shape (the compat endpoint contract).
    • models-dev.test.ts — registry-inclusion case proving the override admits the provider despite the missing api URL and selects the token (not the account id) for auth.

Design notes

  • Why /compat and not the newer REST API (api.cloudflare.com/.../ai/v1): the REST API selects the gateway via header (falling back to the account default) and is documented only with Unified Billing — no BYOK provider keys. /compat keeps explicit per-env gateway selection and BYOK stored keys, matches how Cloudflare's own maintained AI SDK integration (ai-gateway-provider in cloudflare/ai) targets the gateway, and switching later is a one-line URL change in the override. Users who prefer the REST API today can point CLOUDFLARE_AI_GATEWAY_BASE_URL at it.
  • Provider API keys are managed in the Cloudflare dashboard (BYOK stored keys) or via Unified Billing; nothing provider-specific is configured in Mastra. The generated docs page says so explicitly.

Verification

  • pnpm --filter @mastra/core generate:providers and generate-model-docs.ts run clean (CI-workflow sequence, prettier applied).
  • Targeted vitest run green (161 tests across the gateway/model-router suites, including the two new tests).
  • pnpm --filter @mastra/core typecheck green with the regenerated types.
  • Live URL-shape probe: POST https://gateway.ai.cloudflare.com/v1/{account}/{gateway}/compat/chat/completions with a synthetic account returns a structured AiGatewayError 401 (route recognized by AI Gateway, auth enforced) — confirming the endpoint shape the override targets.

Related issue(s)

Fixes #19283

Type of change

  • New feature (non-breaking change that adds functionality)
  • Documentation update

Checklist

  • I have linked the related issue(s) in the description above
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • I have addressed all Coderabbit comments on this PR

🤖 Generated with Claude Code

ELI5

This update lets Mastra use Cloudflare AI Gateway just by writing a model name like cloudflare-ai-gateway/anthropic/claude-3-5-haiku. Mastra automatically talks to Cloudflare’s OpenAI-compatible gateway endpoint, and Cloudflare handles the key management, routing, and usage behind the scenes.

What changed

  • Added Cloudflare AI Gateway support to the model router using cloudflare-ai-gateway/... model strings.
  • Implemented a provider override that routes to Cloudflare’s account- and gateway-scoped OpenAI-compatible /compat endpoint:
    • https://gateway.ai.cloudflare.com/v1/${CLOUDFLARE_ACCOUNT_ID}/${CLOUDFLARE_GATEWAY_ID}/compat
    • Auth via CLOUDFLARE_API_TOKEN
  • Updated provider resolution so Cloudflare appears in generated models.dev/router output even though it has no static provider API URL (endpoint is account-scoped).
  • Added Cloudflare (and other new providers) to the provider registry, reverse model index, and generated TypeScript model/provider types.
  • Added Cloudflare AI Gateway capabilities configuration so supported features are reflected in routing/docs.
  • Removed the now-superseded Cloudflare AI Gateway provider docs page and replaced it with generated gateways/provider documentation (including env-var guidance and gateway routing examples).
  • Added/updated tests:
    • URL interpolation/regression coverage for Cloudflare Gateway baseURL construction and apiKey wiring.
    • models.dev mock + assertions ensuring the override-driven provider works without per-model model overrides.
  • Refreshed generated docs metadata and counts where needed (including minor placeholder/example updates for other gateways/providers).
  • Added a changeset for a patch release of @mastra/core documenting the new router support.

Cloudflare AI Gateway is listed on models.dev but its entry has no api URL
(the endpoint is account-scoped), so the registry generator skipped it. Add a
PROVIDER_OVERRIDES entry that routes it through Cloudflare's OpenAI-compatible
endpoint with URL-template env vars, list it as a gateway in the docs
generator, and regenerate the provider registry and model docs.

Model strings like cloudflare-ai-gateway/anthropic/claude-3-5-haiku now work
with CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_GATEWAY_ID, and CLOUDFLARE_API_TOKEN.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ebd7d27

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@mastra/core Patch
@mastra/code-sdk Patch
mastracode Patch
@mastra/mcp-docs-server Patch
@internal/playground Patch
@mastra/client-js Patch
@mastra/opencode Patch
@mastra/longmemeval Patch
mastra Patch
@mastra/deployer-cloud Patch
@mastra/react Patch
@mastra/playground-ui Patch
@mastra/server Patch
@mastra/deployer Patch
create-mastra Patch
@mastra/express Patch
@mastra/fastify Patch
@mastra/hono Patch
@mastra/koa Patch
@mastra/nestjs Patch
@mastra/next Patch
@mastra/tanstack-start Patch
@mastra/temporal Patch

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

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

@brennanmceachran is attempting to deploy a commit to the Mastra Team on Vercel.

A member of the Team first needs to authorize it.

@dane-ai-mastra dane-ai-mastra Bot added the complexity: critical Critical-complexity PR label Jul 10, 2026
@dane-ai-mastra

dane-ai-mastra Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

PR triage

Linked issue check passed (#19283).

Mastra uses CodeRabbit for automated code reviews. Please address all feedback from CodeRabbit by either making changes to your PR or leaving a comment explaining why you disagree with the feedback. Since CodeRabbit is an AI, it may occasionally provide incorrect feedback.


PR complexity score

Factor Value Score impact
Files changed 26 +52
Lines changed 3273 +60
Author merged PRs 3 -3
Test files changed Yes -10
Final score 99

Applied label: complexity: critical


Changed test gate

Changed Test Gate is pending. The Changed Test Gate / changed-tests check will update the test label when it completes.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55cc09ab-f50f-48bd-ab97-8d80fedff8ab

📥 Commits

Reviewing files that changed from the base of the PR and between 0abef62 and ebd7d27.

📒 Files selected for processing (6)
  • .changeset/cloudflare-ai-gateway-provider.md
  • docs/src/content/en/models/gateways/cloudflare-ai-gateway.mdx
  • packages/core/scripts/generate-model-docs.ts
  • packages/core/src/llm/model/gateways/models-dev.test.ts
  • packages/core/src/llm/model/gateways/models-dev.ts
  • packages/core/src/llm/model/provider-registry.json
✅ Files skipped from review due to trivial changes (1)
  • .changeset/cloudflare-ai-gateway-provider.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/core/src/llm/model/gateways/models-dev.test.ts
  • packages/core/scripts/generate-model-docs.ts
  • packages/core/src/llm/model/provider-registry.json

Walkthrough

Adds Cloudflare AI Gateway routing with account-scoped configuration, registers Pioneer, UnoRouter, and EmpirioLabs models, updates capability/type metadata, adds routing tests, and refreshes generated provider and gateway documentation.

Changes

Model router and provider registry

Layer / File(s) Summary
Provider registry and router integration
packages/core/src/llm/model/provider-registry.json, packages/core/src/llm/model/gateways/models-dev.ts, packages/core/src/llm/model/provider-types.generated.d.ts, .changeset/*
Registers four providers and their model IDs, adds Cloudflare’s account/gateway URL override, updates generated provider types, and records a core patch changeset.
Capability metadata and routing tests
packages/core/src/llm/model/capabilities/*, packages/core/src/llm/model/cloudflare-ai-gateway-url.test.ts, packages/core/src/llm/model/gateways/models-dev.test.ts
Adds capability allowlists for the new providers, updates OpenAI/OpenRouter capabilities, and verifies Cloudflare URL interpolation and provider override handling.
Documentation generation and model pages
packages/core/scripts/generate-model-docs.ts, docs/src/content/en/models/**
Updates gateway generation, adds Cloudflare gateway documentation, adds EmpirioLabs, Pioneer, and UnoRouter pages, updates navigation and environment variables, and refreshes model counts and catalog entries.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: tests: green ✅

Suggested reviewers: wardpeet, TylerBarnes, CalebBarnes, rase-, abhiaiyer91, mikhael28

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also adds or edits EmpirioLabs, Pioneer, UnoRouter, OpenAI, OpenRouter, and Vercel docs/models, which are unrelated to #19283. Split the Cloudflare AI Gateway work from unrelated provider/model doc and registry updates, or justify those changes within the linked issue scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the Cloudflare AI Gateway model-router addition and matches the main change.
Linked Issues check ✅ Passed The PR adds the Cloudflare override, docs, and regression tests requested in #19283, including the account-scoped /compat endpoint and env vars.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/src/content/en/models/gateways/openrouter.mdx (1)

89-89: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a token for arcee-ai/trinity-large-thinking and use it here instead of the literal ID.
docs/src/plugins/remark-model-tokens/models.ts doesn’t define this model yet, so this row should follow the same placeholder-token pattern as the rest of the docs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/src/content/en/models/gateways/openrouter.mdx` at line 89, Add an
appropriate token constant for arcee-ai/trinity-large-thinking in the model
token definitions, then update the OpenRouter documentation row to reference
that token instead of the literal model ID, following the existing
placeholder-token pattern and naming conventions.

Sources: Coding guidelines, Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/cloudflare-ai-gateway-provider.md:
- Line 5: Add a concise Agent configuration example to the changeset,
demonstrating use of the Cloudflare model string
cloudflare-ai-gateway/anthropic/claude-3-5-haiku and the relevant
environment-based configuration, while preserving the existing feature
description.

In `@docs/src/content/en/models/gateways/cloudflare-ai-gateway.mdx`:
- Line 25: The generated Cloudflare AI Gateway example hard-codes a model
identifier instead of using the registered model token. Update the generator
configuration in the models registry to reference the corresponding token for
`cloudflare-ai-gateway/anthropic/claude-3-5-haiku`, then regenerate the MDX
documentation so the example uses the placeholder.

In `@docs/src/content/en/models/index.mdx`:
- Line 152: The provider count is inconsistent between the card and the page
headline. Update the “+ 139 more” text in the provider card to “+ 145 more” if
the intended total is 148; otherwise adjust the headline count so both totals
match.

In `@docs/src/content/en/models/providers/pioneer.mdx`:
- Line 25: The generated Pioneer MDX examples hard-code model IDs instead of
registered placeholders. Update the generator responsible for these examples to
use the model tokens defined in `models.ts`, including the occurrences
corresponding to the referenced lines, then regenerate the page rather than
editing the generated file manually.

In `@docs/src/content/en/models/providers/unorouter.mdx`:
- Line 25: The generated UnoRouter examples hard-code provider model IDs instead
of registered placeholders. Update the documentation generator responsible for
the UnoRouter examples to use the model tokens defined in models.ts, including
all referenced occurrences, then regenerate the MDX page rather than editing the
generated file manually.

In `@packages/core/scripts/generate-model-docs.ts`:
- Around line 589-591: Sanitize the gateway name in the empty-provider fallback
within the environment-variable generation logic: replace all non-alphanumeric
characters in gatewayName with underscores before uppercasing and appending
_API_KEY, so names such as CLOUDFLARE-AI-GATEWAY produce valid shell variable
names.

In `@packages/core/src/llm/model/capabilities/cloudflare-ai-gateway.json`:
- Around line 59-101: Remove non-generative model identifiers from the
temperature capability list in the Cloudflare AI Gateway capabilities
configuration, including embeddings, TTS, transcription, classification,
reranker, and translation models. Retain only models that support temperature
sampling so modelSupportsTemperature reports accurate capabilities.

In `@packages/core/src/llm/model/capabilities/openai.json`:
- Line 45: The model capabilities entry for gpt-realtime-2.1 incorrectly uses
the generic attachment capability to represent image support. Update the OpenAI
capability configuration so this model is listed under the appropriate
image-input capability and removed from the generic attachment list, preserving
separate Files API support semantics.

In `@packages/core/src/llm/model/capabilities/pioneer.json`:
- Around line 66-75: Remove the non-generative guardrail, NER, and diffusion
model identifiers from the temperature capability array in pioneer.json,
including the fastino/gliguard-LLMGuardrails-300M, fastino/gliner2-* entries,
and google/diffusiongemma-26B-A4B-it, so modelSupportsTemperature only
recognizes models that accept temperature.

In `@packages/core/src/llm/model/provider-registry.json`:
- Around line 3155-3170: Update the modelOverrides entry for
anthropic/claude-opus-4-7 to use the OpenAI-compatible ai-gateway-provider, or
remove the override so the configured Cloudflare /compat gateway handles it
instead of `@ai-sdk/anthropic`.

---

Outside diff comments:
In `@docs/src/content/en/models/gateways/openrouter.mdx`:
- Line 89: Add an appropriate token constant for arcee-ai/trinity-large-thinking
in the model token definitions, then update the OpenRouter documentation row to
reference that token instead of the literal model ID, following the existing
placeholder-token pattern and naming conventions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 095b1a5a-34c0-4d29-9353-1f378e417d83

📥 Commits

Reviewing files that changed from the base of the PR and between ea440da and 0abef62.

📒 Files selected for processing (26)
  • .changeset/cloudflare-ai-gateway-provider.md
  • docs/src/content/en/models/environment-variables.mdx
  • docs/src/content/en/models/gateways/cloudflare-ai-gateway.mdx
  • docs/src/content/en/models/gateways/index.mdx
  • docs/src/content/en/models/gateways/openrouter.mdx
  • docs/src/content/en/models/gateways/vercel.mdx
  • docs/src/content/en/models/index.mdx
  • docs/src/content/en/models/providers/cloudflare-ai-gateway.mdx
  • docs/src/content/en/models/providers/empiriolabs.mdx
  • docs/src/content/en/models/providers/index.mdx
  • docs/src/content/en/models/providers/openai.mdx
  • docs/src/content/en/models/providers/pioneer.mdx
  • docs/src/content/en/models/providers/unorouter.mdx
  • docs/src/content/en/models/sidebars.js
  • packages/core/scripts/generate-model-docs.ts
  • packages/core/src/llm/model/capabilities/cloudflare-ai-gateway.json
  • packages/core/src/llm/model/capabilities/empiriolabs.json
  • packages/core/src/llm/model/capabilities/openai.json
  • packages/core/src/llm/model/capabilities/openrouter.json
  • packages/core/src/llm/model/capabilities/pioneer.json
  • packages/core/src/llm/model/capabilities/unorouter.json
  • packages/core/src/llm/model/cloudflare-ai-gateway-url.test.ts
  • packages/core/src/llm/model/gateways/models-dev.test.ts
  • packages/core/src/llm/model/gateways/models-dev.ts
  • packages/core/src/llm/model/provider-registry.json
  • packages/core/src/llm/model/provider-types.generated.d.ts
💤 Files with no reviewable changes (2)
  • docs/src/content/en/models/providers/cloudflare-ai-gateway.mdx
  • packages/core/src/llm/model/capabilities/openrouter.json

Comment thread .changeset/cloudflare-ai-gateway-provider.md Outdated
Comment thread docs/src/content/en/models/gateways/cloudflare-ai-gateway.mdx Outdated
Comment thread docs/src/content/en/models/index.mdx
Comment thread docs/src/content/en/models/providers/pioneer.mdx
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "unorouter/claude-haiku-4-5-20251001"

@coderabbitai coderabbitai Bot Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use registered model placeholders in illustrative examples.

These generated MDX examples hard-code UnoRouter model IDs. Update the generator to use tokens from docs/src/plugins/remark-model-tokens/models.ts, then regenerate the page; do not manually edit this auto-generated file.

[potential_issue]

Also applies to: 337-338, 355-356

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/src/content/en/models/providers/unorouter.mdx` at line 25, The generated
UnoRouter examples hard-code provider model IDs instead of registered
placeholders. Update the documentation generator responsible for the UnoRouter
examples to use the model tokens defined in models.ts, including all referenced
occurrences, then regenerate the MDX page rather than editing the generated file
manually.

Sources: Coding guidelines, Learnings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping for the same reason as pioneer.mdx: auto-generated models.dev drift from the canonical regeneration, not part of this PR's change surface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brennanmceachran, understood — thanks for clarifying. I'll treat this as out of scope for this PR, consistent with the pioneer.mdx case.


✏️ Learnings added
Learnt from: brennanmceachran
Repo: mastra-ai/mastra PR: 19284
File: docs/src/content/en/models/providers/unorouter.mdx:25-25
Timestamp: 2026-07-10T22:22:57.754Z
Learning: In the mastra-ai/mastra repo, generated model documentation pages under `docs/src/content/en/models/providers/*.mdx` and `docs/src/content/en/models/gateways/*.mdx` are auto-generated by `packages/core/scripts/generate-model-docs.ts` from models.dev data. Hard-coded model IDs in illustrative examples (rather than placeholder tokens from `docs/src/plugins/remark-model-tokens/models.ts`) reflect drift in the canonical regeneration process itself, not something to fix within an individual PR that merely adds/updates provider docs. Per brennanmceachran, such findings should be skipped as out of scope for the PR's change surface.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: mikhael28
Repo: mastra-ai/mastra PR: 17896
File: examples/voice-agent/src/mastra/agents/call-center-agent.ts:36-36
Timestamp: 2026-06-23T16:45:35.194Z
Learning: In this repo, the "placeholder-token" rule (replacing model name/provider/model strings with the tokens defined in `docs/src/plugins/remark-model-tokens/models.ts`) applies only to documentation markdown/MDX content and changeset entries. For any documentation file matched by `**/*.{md,mdx}`, ensure literal model name strings are replaced with the corresponding placeholder tokens.

Do not treat literal provider/model ID strings in executable code as a placeholder-token violation: in `.ts`/`.tsx` files (including `examples/**`, tests, and integration code), it’s expected to use real provider/model IDs such as `"openai/gpt-5-mini"`, because the Remark plugin runs only during docs build and not at runtime.

Learnt from: mikhael28
Repo: mastra-ai/mastra PR: 17896
File: integrations/livekit/src/worker.ts:45-48
Timestamp: 2026-06-23T16:45:35.250Z
Learning: In the mastra-ai/mastra repo, the remark plugin model-token placeholder policy should be enforced only for MDX documentation files under docs/src that are processed by the remark-model-tokens plugin. In those MDX files, use the placeholder tokens defined in docs/src/plugins/remark-model-tokens/models.ts instead of writing literal model IDs. Do not apply this restriction to TypeScript/TSX source files, JSDoc comments, or executable example code; in those files, literal model IDs are acceptable.

Comment thread packages/core/scripts/generate-model-docs.ts
Comment thread packages/core/src/llm/model/capabilities/cloudflare-ai-gateway.json
Comment thread packages/core/src/llm/model/capabilities/openai.json
Comment thread packages/core/src/llm/model/capabilities/pioneer.json
Comment thread packages/core/src/llm/model/provider-registry.json Outdated
- Drop models.dev per-model npm hints for cloudflare-ai-gateway via
  PROVIDER_OVERRIDES so every model stays on the OpenAI-compatible /compat
  endpoint (claude-opus-4-7 carried an @ai-sdk/anthropic hint that would
  have routed it through the wrong SDK protocol); regression test added
- Use the evergreen __GATEWAY_ANTHROPIC_MODEL_HAIKU__ token in the generated
  gateway usage example
- Sanitize the empty-provider env-var fallback in the docs generator
- Add a usage example to the changeset

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: critical Critical-complexity PR Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Cloudflare AI Gateway to the model router (string DX like Vercel/Netlify)

1 participant