Skip to content

Add Cloudflare AiSearch component#6777

Draft
msdbcardoso wants to merge 7 commits intoanomalyco:devfrom
msdbcardoso:add-cloudflare-ai-search
Draft

Add Cloudflare AiSearch component#6777
msdbcardoso wants to merge 7 commits intoanomalyco:devfrom
msdbcardoso:add-cloudflare-ai-search

Conversation

@msdbcardoso
Copy link
Copy Markdown

Adds a new sst.cloudflare.AiSearch component for the AI Search Workers binding.

Supports both binding types:

  • Instance binding (ai_search) — binds to a single instance by name
  • Namespace binding (ai_search_namespaces) — binds to a namespace for multi-instance access
// Instance binding
const search = new sst.cloudflare.AiSearch("MySearch", {
  instance: "my-docs-index"
});

// Namespace binding
const search = new sst.cloudflare.AiSearch("MySearch", {
  namespace: "my-namespace"
});

Note: The instance binding (instanceName property) requires @pulumi/cloudflare to bridge a Terraform provider version that includes the instance_name field on WorkerScriptBinding. The field is already in the Terraform provider and the Cloudflare OpenAPI spec, but hasn't been bridged to Pulumi yet. The namespace binding and sst dev mode work today.

Copy link
Copy Markdown
Collaborator

@vimtor vimtor left a comment

Choose a reason for hiding this comment

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

thanks for your contribution @msdbcardoso

i left some comments but this looks very promising

besides solving them, would you mind adding a cloudflare-ai-search working example to the examples directory?

Comment thread platform/src/components/cloudflare/binding.ts
Comment thread platform/src/components/cloudflare/helpers/wrangler.ts
Comment thread platform/src/components/cloudflare/helpers/wrangler.ts
@msdbcardoso
Copy link
Copy Markdown
Author

thanks for your contribution @msdbcardoso

i left some comments but this looks very promising

besides solving them, would you mind adding a cloudflare-ai-search working example to the examples directory?

Thanks, of course!

I did notice just now fixing the conflicts messed up thing -/-, thanks for calling those out!

- Fix missing closing braces in AiSearchNamespaceBinding interface
- Fix missing });/break in aiSearchNamespaceBindings wrangler case
- Fix missing closing } in aiSearchNamespaces config block
- Fix duplicate semicolon in Binding union type
- Register aiSearchBindings/aiSearchNamespaceBindings in typescript.go
- Add cloudflare-ai-search example
Cover create, list, upload, search, and delete operations
using the namespace binding.
@msdbcardoso msdbcardoso marked this pull request as draft April 24, 2026 14:32
Rewrite cloudflare-ai-search to use instance binding (the common case)
with routes for search, filtered search, chat completions, and streaming.

Add cloudflare-ai-search-namespace for the advanced namespace binding
with multi-instance management and cross-instance search.

Both examples now follow repo conventions: minimal package.json, JSDoc
for docs generation, workers-types in devDependencies, and all API calls
verified against @cloudflare/workers-types.
@msdbcardoso msdbcardoso marked this pull request as ready for review April 27, 2026 09:52
@vimtor
Copy link
Copy Markdown
Collaborator

vimtor commented Apr 27, 2026

the deployed example fails because the pulumi provider doesn't support that binding in the latest version

Error  WorkerScript cloudflare:index:WorkersScript
Attribute bindings[1].type value must be one of:
["ai" "analytics_engine" "assets" "browser" "d1" ... "workflow" "wasm_module"],
got: "ai_search_namespace"

we'll need to wait for the provider to be updated

@msdbcardoso msdbcardoso requested a review from vimtor April 27, 2026 13:50
@msdbcardoso msdbcardoso marked this pull request as draft April 27, 2026 14:53
@msdbcardoso
Copy link
Copy Markdown
Author

We'll handle the upstream dependency and move to ready when it's done

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants