#721·flue

Anthropic binding client lacks the pi-ai beta messages path

Author: rikbrownCreated Sep 17, 2026Updated Sep 17, 2026

@flue/runtime 2.0.8, Cloudflare target, with @earendil-works/pi-ai overridden from Flue's ^0.83.0 range to 0.85.x.

Summary

createAnthropicBindingClient exposes client.messages.create only. pi-ai 0.85.x calls client.beta.messages.create when an Anthropic request contains beta features, so the binding client throws before it sends a request.

Observed behaviour

A project can override pi-ai to 0.85.x to use a newer model catalogue. With pi-ai 0.85.1, a context with tools names fine-grained-tool-streaming-2025-05-14 in params.betas because the gateway model sets supportsEagerToolInputStreaming: false. The call then fails because client.beta is undefined.

Cause

In packages/runtime/src/cloudflare/workers-ai-provider.ts, createAnthropicBindingClient implements the stable Anthropic client path only:

typescript
return {
  messages: {
    create(params, requestOptions) {
      // calls ai.run(...)
    },
  },
};

pi-ai 0.85.1 supplies beta feature names in params.betas. The Anthropic SDK's beta client removes them from the request body and sends them in the anthropic-beta header. The binding client has neither the beta namespace nor this translation.

Proposed change

Share the existing request implementation and expose a beta path that moves betas into the extra headers:

diff
 return {
   messages: { create: (params, requestOptions) => create(params, requestOptions, {}) },
+  beta: {
+    messages: {
+      create: (params, requestOptions) => {
+        const { betas, ...body } = params;
+        const betaHeaders =
+          Array.isArray(betas) && betas.length > 0
+            ? { 'anthropic-beta': betas.join(',') }
+            : {};
+        return create(body, requestOptions, betaHeaders);
+      },
+    },
+  },
 };

The shared create should merge these headers with the existing binding and gateway headers, then otherwise run the same request as messages.create.

An alternative is to bump or constrain Flue's pi-ai version so the installed version continues to call messages.create for this path.

Impact

Projects can use pi-ai 0.85.x model catalogue updates with the Cloudflare binding provider. Beta names reach Anthropic in the expected header, and they do not leak into the request body.