Skip to content

@tanstack/openai-base@0.13.0

Choose a tag to compare

@github-actions github-actions released this 09 Oct 12:39
· 171 commits to main since this release
Immutable release. Only release title and notes can be modified.
9614cc7

Minor 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.

Patch Changes

  • #1678 13ba1b0 - A RUN_ERROR now tells you how long the provider asks you to wait before a retry.

    • @tanstack/ai: RunErrorEvent has a new retryAfterMs field, in milliseconds. chat() moves it to metadata.tanstack.retryAfterMs. The new toRetryAfterMs(error) helper on @tanstack/ai/adapter-internals reads the retry-after-ms header first, then the retry-after header in seconds or as an HTTP date.
    • @tanstack/openai-base and @tanstack/ai-anthropic: the text adapters set retryAfterMs on a RUN_ERROR when the error response has one of these headers. This includes every adapter that uses @tanstack/openai-base.
  • Updated dependencies [7dbfaf6, 88fd67c, 3aa2e3d, c5ae415, 13ba1b0, 377262c]:

    • @tanstack/ai@0.67.0