Skip to content

feat(ai-search-provider): add AI Search provider for the AI SDK#602

Draft
aninibread wants to merge 2 commits into
cloudflare:mainfrom
aninibread:update-cloudflare-ai-search
Draft

feat(ai-search-provider): add AI Search provider for the AI SDK#602
aninibread wants to merge 2 commits into
cloudflare:mainfrom
aninibread:update-cloudflare-ai-search

Conversation

@aninibread

@aninibread aninibread commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Adds a standalone ai-search-provider package — a Vercel AI SDK provider wrapping Cloudflare AI Search's new ai_search_namespaces Workers binding. AI SDK apps can upload files to AI Search for indexing, then search that content with natural language or generate chat responses grounded in the retrieved context.

workers-ai-provider is left as-is (its legacy createAISearch/createAutoRAG still wrap the AutoRAG binding); only its AI Search docs section now points to the new package.

API

createAISearchNamespace({ binding }).get(instanceName) returns an instance client with chat() (a LanguageModelV3), search(), and items (upload/uploadAndPoll/list/delete/get().info()/get().download()); the namespace client also exposes list().

Design decisions

  • Namespace binding — the ai_search_namespaces binding is a functional superset of the single-instance ai_search binding (get() is synchronous/lazy; a default namespace exists for every account), giving a clean namespace→instance split with no duplicated chat/search.
  • Minimal surface — cross-instance search, jobs, and instance admin (info/stats/update) are intentionally omitted for the initial release.
  • Retrieved chunks are surfaced as AI SDK source parts (sourceType: "url", with the raw chunk under providerMetadata.aisearch); streaming parses SSE and detects truncation via the documented [DONE] sentinel.

Testing

  • 27 unit tests — pnpm --filter ai-search-provider test:ci.
  • Opt-in e2e against a real instance — AI_SEARCH_INSTANCE=<name> pnpm --filter ai-search-provider test:e2e (skips when unset; not run in CI).

Changesets

  • ai-search-provider: minor (initial 0.1.0)
  • workers-ai-provider: patch (docs pointer only)

New standalone package wrapping Cloudflare AI Search's `ai_search_namespaces`
Workers binding for the Vercel AI SDK:

- createAISearchNamespace({ binding }).get(instanceName) returns an instance
  client with chat() (a LanguageModelV3), search(), and item helpers
  (upload/uploadAndPoll/list/delete/get().info()/get().download()); the
  namespace client also exposes list().
- Chat completions map retrieved chunks to AI SDK `source` parts and support
  streaming (SSE) with truncation detection.
- Namespace-only surface by design: the namespace binding is a superset of the
  single-instance binding (get() is synchronous/lazy; a default namespace
  exists for every account).

Also points workers-ai-provider's AI Search docs at the new package; its own
legacy createAISearch/createAutoRAG (AutoRAG binding) are unchanged.

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

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a6c830e

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

This PR includes changesets to release 2 packages
Name Type
ai-search-provider Minor
workers-ai-provider 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

@aninibread aninibread marked this pull request as draft July 3, 2026 05:55
@pkg-pr-new

pkg-pr-new Bot commented Jul 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/cloudflare/ai/ai-gateway-provider@602
npx https://pkg.pr.new/cloudflare/ai/ai-search-provider@602
npx https://pkg.pr.new/cloudflare/ai/@cloudflare/tanstack-ai@602
npx https://pkg.pr.new/cloudflare/ai/workers-ai-provider@602

commit: a6c830e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant