createAI: the ai peer range allows ai@6, which the provider cannot work with
Maintainers usually reply within 1 day
@akhil9tiet is already working on this.
Since Oct 23, 2026.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 83/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start with the peerDependencies in packages/agents/package.json and compare the declared ai range with the v4 model implementation in packages/agents/src/models/ai-sdk/models/language.ts. The issue reports that ai@6 rejects the v4 model and says @cloudflare/think already pins ai to ^7.0.0. Check for relevant package tests or validation; done when the peer range matches the supported version and installs no longer accept the reported incompatible combination.
Written by the indexing model from the issue text.
Description
Describe the bug
packages/agents/package.json declares:
"peerDependencies": { "ai": "^6.0.0 || ^7.0.0", "@ai-sdk/provider": "^4.0.0" }
ai@6 satisfies that range but cannot drive the provider. createAI builds a
LanguageModelV4, and ai@6 does not accept one, so every call throws. The
install is clean — no peer warning — and the failure only appears at the first
generateText.
The AI SDK page
already says the right thing ("The provider needs ai@^7 and
@ai-sdk/provider@^4"); it is the range that is wrong.
To Reproduce
npm i [email protected] [email protected] @ai-sdk/[email protected] # no peer warning
import { createAI } from "agents/models/ai-sdk";
import { generateText } from "ai";
const binding = {
aiGatewayLogId: null,
async fetch() { return new Response("x", { status: 501 }); },
async run() {
return new Response(
JSON.stringify({
id: "c1", object: "chat.completion", created: 1, model: "@cf/test",
choices: [{ index: 0, message: { role: "assistant", content: "ok" }, finish_reason: "stop" }],
usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }
}),
{ headers: { "content-type": "application/json" } }
);
}
};
const ai = createAI({ binding: binding as never });
await generateText({ model: ai("@cf/zai-org/glm-4.7-flash"), prompt: "hi", maxRetries: 0 });
UnsupportedModelVersionError [AI_UnsupportedModelVersionError]: Unsupported
model version v4 for provider "cloudflare" and model
"@cf/zai-org/glm-4.7-flash". AI SDK 5 only supports models that implement
specification version "v2".
The binding is a stub, so no account is involved: the throw happens before any
request is sent.
Pinning @ai-sdk/[email protected] instead makes no difference. ai does not
take @ai-sdk/provider as a peer — [email protected] depends on @ai-sdk/[email protected]
directly — so whichever version sits at the top level, ai@6 reads models
through its own copy and rejects a v4 one.
Expected behavior
Either the range matches what works ("ai": "^7.0.0"), or ai@6 is actually
supported and the v4 model is only built when the installed ai can read it.
Root cause
packages/agents/package.json. The provider is a ProviderV4 built against
@ai-sdk/provider@^4 (LanguageModelV4 in
packages/agents/src/models/ai-sdk/models/language.ts), while ai@6 pins
@ai-sdk/provider@3 as a direct dependency. The two halves of the range are not
interchangeable, and the @ai-sdk/provider peer cannot bridge them, so
^6.0.0 || ^7.0.0 admits a combination that cannot work.
@cloudflare/think already pins "ai": "^7.0.0", which is the shape this
needs.
Additional context
Same v6/v7 mix-up as #2647, from the other side: there the docs were behind the
package, here the package range is wider than the code.
Version: [email protected], [email protected], @ai-sdk/[email protected], Node 24.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 788
- Avg merge
- 21h 29m
- Merged PRs (30d)
- 190
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/agents
-
createAI: text-only user content is joined with no separator, which glues parts together and breaks code fencesPossibly taken @akhil9tiet claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cloudflare/agents#2682 · 1 comment ·
Maintainers usually reply within 1 day
-
Think docs: the dependency table lists ai as v6, but think requires ai@^7Possibly taken @mattzcarey claimed this 1 day ago. Openbug priority: low
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/agents#2647 · 2 comments · 2 reactions · 1 assignee ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/agents#2645 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/agents#2635 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cloudflare/agents#2629 ·
Maintainers usually reply within 1 day
All issues in cloudflare/agents
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
db-ux-design-system/core-web#8613 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
foxglove/mcap#1907 · 1 comment ·
Maintainers usually reply within 1 day
-
bug internal-plugin pr-welcome upstream
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dsh-tauri-desk/deepseek-harness-desktop#1225 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
unjs/unhead#1027 · 1 reaction ·
Maintainers usually reply within 1 day