Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

CHANGELOG.md

234 lines19.1 KB

@tanstack/ai-cloudflare

0.3.2

Patch Changes

0.3.1

Patch Changes

0.3.0

Minor Changes

  • #1721 4069e0e - Add cloudflareBindingFetch({ binding, vendor, gateway }). It sends the requests of the Anthropic and OpenAI text adapters (createAnthropicChat, createOpenaiChat) through the Workers AI binding (env.AI.run) to the AI Gateway anthropic/... and openai/... models, so a Worker can use Claude and GPT with no provider key.

    • vendor: 'anthropic' carries Anthropic Messages requests, and vendor: 'openai' carries OpenAI Responses requests.
    • The request body goes to env.AI.run('<vendor>/<model>', body). Headers such as anthropic-beta go along as extraHeaders, and the SDK's auth and transport headers are dropped.
    • A Cloudflare error body is rewrapped so the SDK reports its message.
  • #1739 a0150c2 - Text adapters now set one stable code on RUN_ERROR when the input does not fit in the model's context window: code: 'context_overflow'. @tanstack/ai exports it as CONTEXT_OVERFLOW_CODE. The provider's own text stays in message.

    if (chunk.type === 'RUN_ERROR' && chunk.code === CONTEXT_OVERFLOW_CODE) {
      // shorten the messages, then call chat() again
    }

    These adapters set it: OpenAI and the other OpenAI-compatible adapters (from code: 'context_length_exceeded'), Anthropic, Gemini, Bedrock (Converse, Chat Completions, and Responses), OpenRouter, Grok, Cloudflare Workers AI, and BytePlus.

    Changes to code that reads the old values:

    • OpenAI-compatible adapters gave code: 'context_length_exceeded'. They now give 'context_overflow'. rawEvent still has the provider's code.
    • Anthropic, Grok, OpenRouter, and BytePlus gave the HTTP status or a general bad-request code for this error. Gemini and Bedrock Converse gave no code.
    • The Anthropic adapter now sends RUN_ERROR with this code when the model stops with stop_reason: 'model_context_window_exceeded'. Before, it sent RUN_FINISHED with finishReason: 'stop', so a cut-off answer looked complete.
  • #1692 7532b2b - Set reasoning with chat({ reasoning }).

    • The adapter sends reasoning_effort, and null for off.
    • The reasoning data is in utils/models.ts, keyed by model id. CloudflareModelReasoningByName and CLOUDFLARE_MODEL_REASONING come from it.
    • chat_template_kwargs stays in modelOptions. It picks the output format, not the effort.

    Breaking: reasoning_effort is no longer in modelOptions.

    // Before
    chat({
      adapter: cloudflareText('@cf/zai-org/glm-5.3'),
      messages,
      modelOptions: { reasoning_effort: 'low' },
    })
    
    // After
    chat({
      adapter: cloudflareText('@cf/zai-org/glm-5.3'),
      messages,
      reasoning: 'low',
    })

Patch Changes

0.2.7

Patch Changes

  • Updated dependencies [723b4a4, d84a49e]:
    • @tanstack/ai@0.68.0
    • @tanstack/openai-base@0.13.1

0.2.6

Patch Changes

  • #1680 377262c - Add wrapFetch to chat(), to the middleware onConfig config, and to TextOptions. A wrapper gets the next fetch and gives back a new fetch. Use it to change the URL, the headers, the request, or the response of a model call. The new FetchWrapper type names the wrapper.

    The engine chains the chat() wrapper and the middleware wrappers into one function. A middleware wrapper runs inside the chat() wrapper and applies to one model call only.

    These text adapters send their requests through the wrapper: every adapter on @tanstack/openai-base (OpenAI, the OpenAI-compatible adapters, Grok, Groq, BytePlus, LLM Gateway, Lovable, Vercel AI Gateway, Cloudflare, and the Bedrock Chat Completions and Responses APIs), Anthropic, Mistral, Ollama, and OpenRouter. The wrapper wraps the fetch of the adapter config, not the global fetch. An Anthropic or Ollama adapter with an injected client ignores wrapFetch. In Cloudflare binding mode, the wrapper runs, but the binding does not send the URL or the headers. Without wrapFetch, the requests do not change.

  • Updated dependencies [7dbfaf6, 88fd67c, 3aa2e3d, c5ae415, 13ba1b0, 377262c]:

    • @tanstack/ai@0.67.0
    • @tanstack/openai-base@0.13.0

0.2.5

Patch Changes

  • #1652 13a5c4c - Update the openai SDK dependency to ^7.30.0. openai 7 requires Node.js 22 or later.

  • Updated dependencies [13a5c4c]:

    • @tanstack/openai-base@0.12.6

0.2.4

Patch Changes

0.2.3

Patch Changes

0.2.2

Patch Changes

0.2.1

Patch Changes

0.2.0

Minor Changes

  • #1499 f822940 - Warn in development when a tool is sent with strict: false because its schema cannot be strict. The warning names the tool and the reason, for example tool "lookup_user" sent with strict: false: schema uses $ref, which strict mode does not support. It runs once per tool, never when NODE_ENV is production, and you can turn it off with strictFallbackWarning: false in the adapter config.

Patch Changes

0.1.8

Patch Changes

0.1.7

Patch Changes

  • Updated dependencies [ef0a00f, 222ebed]:
    • @tanstack/ai@0.60.0
    • @tanstack/openai-base@0.11.0

0.1.6

Patch Changes

0.1.5

Patch Changes

  • Updated dependencies [796f2b5]:
    • @tanstack/ai@0.58.0
    • @tanstack/openai-base@0.10.15

0.1.4

Patch Changes

  • #1419 04bfd8c - Add decide() and TypeSafe Jev evaluate adapters.

    Callers await one decide({ adapter, state, questions }) call. Questions use choice(), score(), and boolean(). Answers sit on the result (value, probability, confidence). Usage sits on result.meta.

    Jev transports:

    • @tanstack/ai-typesafe (typesafeDecider)
    • @tanstack/ai-openrouter (openRouterDecider)
    • @tanstack/ai-vercel-gateway (vercelGatewayDecider)
    • @tanstack/ai-cloudflare (cloudflareDecider)
  • Updated dependencies [04bfd8c, 254ab5f]:

    • @tanstack/ai@0.57.0
    • @tanstack/openai-base@0.10.14

0.1.3

Patch Changes

  • Updated dependencies [7c4b25e, f60f736]:
    • @tanstack/ai@0.56.0
    • @tanstack/openai-base@0.10.13

0.1.2

Patch Changes

  • Updated dependencies [fa13446, 0945a79]:
    • @tanstack/ai@0.55.0
    • @tanstack/openai-base@0.10.12

0.1.1

Patch Changes

0.1.0

Minor Changes

  • #1309 21775ee - Add @tanstack/ai-cloudflare: a Cloudflare adapter for Workers AI chat, summarization, embeddings, image generation, text-to-speech, and transcription over the env.AI binding or the REST API, with AI Gateway routing (gateway option and cloudflareGateway() helper for other providers). @tanstack/ai learns the cloudflare max-tokens key for summarize, lets defineByokProvider declare companion credentials with with, and adds getByokKeys(request, { name: provider }) to @tanstack/ai/byok/server. @tanstack/ai-client's defineByok takes providers: a send for a provider with companions (Cloudflare token plus account id) carries every x-byok-* header and prompts for each missing value.

Patch Changes

  • Updated dependencies [21775ee]:
    • @tanstack/ai@0.53.0
    • @tanstack/openai-base@0.10.10