- #448
054ccb8Thanks @threepointone! - Fix image inputs for vision-capable chat models- Handle all
LanguageModelV3DataContentvariants (Uint8Array, base64 string, data URL) instead of only Uint8Array - Send images as OpenAI-compatible
image_urlcontent parts inline in messages, enabling vision for models like Llama 4 Scout and Kimi K2.5 - Works with both the binding and REST API paths
- Handle all
-
#435
7381171Thanks @mdhruvil! - Fix workers-ai adapter silently dropping image content parts. -
#424
b2eeca8Thanks @vaibhavshn! - Avoid duplicate tool call IDs by generating unique IDs per tool call index instead of trusting backend-provided IDs -
#411
af08464Thanks @baldyeagle! - Annotate createAnthropicChat to improve client type narrowing -
#398
40e53c8Thanks @vaibhavshn! - fix: addrun/prefix to workers-ai gateway endpoint and make API key optional for gateway bindings -
#444
414b4d5Thanks @mchenco! - AddsessionAffinityoption toWorkersAiAdapterConfigfor prefix-cache optimization. Routes requests with the same key to the same backend replica via thex-session-affinityheader. Supported across binding, REST, and gateway modes.
-
#406
9af703bThanks @vaibhavshn! - Pass API Key properly for Gemini Tanstack AI Adapter -
#400
8822603Thanks @threepointone! - Add config validation to all Workers AI adapter constructors that throws a clear error when neither a binding, credentials (accountId + apiKey), nor a gateway configuration is provided. Widen all model type parameters (WorkersAiTextModel, WorkersAiImageModel, WorkersAiEmbeddingModel, WorkersAiTranscriptionModel, WorkersAiTTSModel, WorkersAiSummarizeModel) to accept arbitrary strings while preserving autocomplete for known models.
- #396
2fb3ca8Thanks @threepointone! - - Update model recommendations: Aura-2 EN for TTS, Llama 4 Scout for chat examples- Add Aura-2 EN/ES to TTS model type
- Preserve image/vision content in user messages instead of stripping to text-only
- Add non-streaming fallback when REST streaming fails (GPT-OSS, Kimi)
- Warn on premature stream termination instead of silently reporting "stop"
- Consistent console.warn prefix for SSE parse errors
- Move @cloudflare/workers-types from optionalDependencies to devDependencies (types-only, no runtime use)
- Fix @openrouter/sdk version mismatch type errors
-
#389
a4b756eThanks @vaibhavshn! - Add@cloudflare/tanstack-ai— adapters for using TanStack AI with Cloudflare Workers AI and AI Gateway.All Workers AI adapters support four configuration modes: plain binding (
env.AI), plain REST (account ID + API key), AI Gateway binding (env.AI.gateway(id)), and AI Gateway REST (account ID + gateway ID).- Chat (
createWorkersAiChat) — Streaming chat completions via the OpenAI-compatible API. Includes tool calling with full round-trip support, structured output viajson_schema, and reasoning text streaming (STEP_STARTED/STEP_FINISHEDAG-UI events) for models like QwQ, DeepSeek R1, and Kimi K2.5. A custom fetch shim translates OpenAI SDK calls toenv.AI.run()for binding mode, with a stream transformer that handles both Workers AI native format and OpenAI-compatible format. - Image generation (
createWorkersAiImage) — Stable Diffusion and other text-to-image models. - Transcription (
createWorkersAiTranscription) — Speech-to-text via Whisper and Deepgram Nova-3. - Text-to-speech (
createWorkersAiTts) — Audio generation via Deepgram Aura-1. - Summarization (
createWorkersAiSummarize) — Text summarization via BART-large-CNN. - Embeddings (
createWorkersAiEmbedding) — Text embeddings (implemented but not yet exported, pending TanStack AI'sBaseEmbeddingAdapter).
Route requests through Cloudflare AI Gateway for caching, rate limiting, and unified billing. Each adapter injects a custom
fetch(orhttpOptionsfor Gemini) that handles both binding and credential-based gateway configurations.- OpenAI — Chat, summarize, image, transcription, TTS, video (
createOpenAi*) - Anthropic — Chat, summarize (
createAnthropic*) - Gemini — Chat, summarize, image, TTS (
createGemini*). Credentials-only (Google GenAI SDK lacks custom fetch support). - Grok — Chat, summarize, image (
createGrok*) - OpenRouter — Chat, summarize, image (
createOpenRouter*). Accepts any model string.
createGatewayFetch— Shared fetch factory that routes requests through AI Gateway (binding or REST), with support for cache control headers (skipCache,cacheTtl,customCacheKey,metadata).createWorkersAiBindingFetch— Fetch shim that makesenv.AIlook like an OpenAI endpoint, including stream transformation and tool call ID sanitization for the binding's strict[a-zA-Z0-9]{9}validation.- Config detection helpers (
isDirectBindingConfig,isDirectCredentialsConfig,isGatewayConfig) using structural typing to discriminateenv.AIfromenv.AI.gateway(id). - Shared binary utilities for normalizing Workers AI responses (Uint8Array, ArrayBuffer, ReadableStream, JSON wrapper) to base64.
- Premature stream termination detection — if Workers AI truncates a response or the connection drops (no
finish_reason), the adapter emits proper closing events so consumers don't hang. - Graceful non-streaming fallback — if a model returns a complete response despite
stream: true, the binding shim wraps it into a valid response. - Deepgram Nova-3 transcription uses raw binary audio via REST (not JSON), automatically detected by model name.
- Comprehensive unit tests (186 tests) covering all adapters, config modes, stream transformation, message building, tool calling, reasoning events, premature termination, and public API surface.
- E2E integration tests against real Workers AI APIs (both binding and REST paths) across 12 chat models + 4 transcription models + image/TTS/summarize, validating chat, multi-turn, tool calling, tool round-trips, structured output, reasoning, and all non-chat capabilities.
- Tree-shakeable package exports with per-adapter entry points for ESM and CJS.
- Chat (