You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a sessionAffinity option across Workers AI adapters/providers to route requests with the same key to the same backend replica via the x-session-affinity header for prefix-cache optimization. Implementation details:
- Extend WorkersAiAdapterConfig with an optional sessionAffinity string.
- Propagate sessionAffinity as x-session-affinity to binding.run() via createWorkersAiBindingFetch(extraHeaders), to REST requests via defaultHeaders, and to gateway mode via createGatewayFetch call.
- Merge sessionAffinity with user-provided extraHeaders in the WorkersAI provider so both headers are forwarded together.
Other changes:
- Add and update tests covering binding.fetch, adapter behavior, and REST/binding header merging.
- Update README docs for tanstack-ai and workers-ai-provider to document sessionAffinity usage.
- Add changeset files to trigger a patch release for the relevant packages and minor formatting updates to demos.json.
Add `sessionAffinity` setting to send `x-session-affinity` header for prefix-cache optimization. Also forward `extraHeaders` in the REST API path instead of discarding them.
Add `sessionAffinity` option to `WorkersAiAdapterConfig` for prefix-cache optimization. Routes requests with the same key to the same backend replica via the `x-session-affinity` header. Supported across binding, REST, and gateway modes.
Copy file name to clipboardExpand all lines: packages/tanstack-ai/README.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -275,6 +275,15 @@ Workers AI supports four configuration modes:
275
275
276
276
Third-party providers (OpenAI, Anthropic, Gemini, Grok, OpenRouter) only support the gateway modes.
277
277
278
+
All Workers AI config modes also accept `sessionAffinity` to route requests with the same key to the same backend replica for prefix-cache optimization:
0 commit comments