Skip to content

@tanstack/ai-openai@1.0.0

Choose a tag to compare

@github-actions github-actions released this 22 Oct 15:19
· 14 commits to main since this release
Immutable release. Only release title and notes can be modified.
5651e07

Major Changes

  • #1840 f1b3f65 - TanStack AI 1.0.0. This release removes every API that was deprecated in 0.x. Read the upgrade guide before you upgrade: https://tanstack.com/ai/latest/docs/migration/v1
    • Removed all @deprecated exports, options, fields, and type aliases. Each one has a replacement that already shipped in 0.x.
    • Removed addToolApprovalResponse() from ChatClient and every chat hook. Resolve the bound tool-approval interrupt with resolveInterrupt instead. The devtools event tools:approval:responded is also removed.
    • Removed the old wire formats: the CUSTOM approval-requested and tool-input-available events, the [DONE] SSE line, the data copy of forwardedProps, pre-binding interrupt descriptors and their approval_required and client_tool_input reasons, and the STEP events that adapters sent next to REASONING_* events. Use a 1.0 client with a 1.0 server.
    • Removed the toolName alias from TOOL_CALL_START chunks. Read toolCallName instead.
    • threadId is now required on useChat and every other chat hook, ChatClient, the generation hooks and clients, chat(), summarize(), the generation functions, codeModeWithSnippets(), selectRelevantSnippets(), CompactionContext, and SummarizeInput. TanStack AI no longer makes a thread id for you. Pass a stable id for each conversation. createChatHook factory options no longer take threadId: pass it on each hook call. Octane generation hooks take threadId instead of id. @tanstack/ai-sandbox removes resolveDurableThreadId and DurableThreadIdRequiredError.
    • The published @tanstack/ai-octane/ui types are now strict. UI.Messages, UI.Message, UI.Part, and UI.Interrupts type their render children. ToolProps types part.input and part.output for the named tool. toolsComponents and interruptsComponents are required when the chat options declare tools or named interrupts. Code that relied on the old loose types can fail to compile.
    • A connection adapter's connect() and send() need the run context (with threadId) as their fourth argument. ChatClient and the generation clients pass it.
    • @tanstack/ai-sandbox: createToolBridgeCore(), startHostToolBridge(), a ToolBridgeProvisioner, and executeHostTool() take a required threadId. Bridged tools get it in their context.
    • @tanstack/ai-sandbox: the harness tool bridge and executeHostTool() refuse a tool with needsApproval. Before, the tool ran with no approval. Remove needsApproval, or run the tool with an HTTP adapter.
    • stream() and rpcStream() pass the AG-UI RunAgentInput for the run as the fourth factory argument, the same body the HTTP adapters send. Read it on the server with chatParamsFromRequestBody() or generationParamsFromBody(), so threadId, runId, and interrupt resume reach a server function. RunAgentInput is exported from @tanstack/ai/client.
    • A generation fetcher gets threadId and runId in its second argument, next to signal and headers. Pass them to the server generation call.
    • generationParamsFromBody() and generationParamsFromRequest() read the generation input from forwardedProps. A server that reads body.data gets undefined. Read body.forwardedProps instead. They also require threadId and runId and return them as strings, the same as chatParamsFromRequestBody() and the AG-UI RunAgentInput. A body that holds only the input is rejected.
    • Removed the readers for data saved in old 0.x formats (old Cloudflare run-log records, a bare UIMessage[] from client persistence, artifact records without blobKey).
    • Removed provider models that are shut down.
    • @tanstack/ai-react-ui, @tanstack/ai-solid-ui, and @tanstack/ai-vue-ui get no 1.0 release. Import from @tanstack/ai-react/ui, @tanstack/ai-solid/ui, or @tanstack/ai-vue/ui.

Minor Changes

  • #1743 959f43e - Add EvaluateError, a typed error an evaluate adapter throws when the provider answered but the call cannot become a result. @tanstack/ai and @tanstack/ai/adapters export the class, the isEvaluateError() type guard, the EvaluateErrorInit type and EVALUATE_REFUSAL_CODE. The error keeps what the provider sent back:

    • code: a stable code to branch on. A refused question uses EVALUATE_REFUSAL_CODE ('refusal').
    • usage: the tokens the call used.
    • model: the model that answered.
    • answers: the raw wire answers that came back, before decide() maps them. A choice() answer has choice (for example { type: 'choice', choice: 'billing', ... }), and a boolean() answer is { type: 'noul', noul: 0.9 }, not { value }. The refused question has no key.

    When OpenAI refuses to answer a question, decide() now throws an EvaluateError with code: 'refusal' instead of a plain Error. If more than one question is refused, the message names the first one.

    Use isEvaluateError(error) to narrow a caught error. It checks name and code, not instanceof, so it still works when the app installs more than one copy of @tanstack/ai.

    When an adapter throws an EvaluateError that carries usage, decide() reports that usage through the evaluate:usage event and the middleware onUsage hook, then runs onError and rethrows the same error. onFinish does not run.

    try {
      await decide({ adapter, state, questions })
    } catch (error) {
      if (isEvaluateError(error) && error.code === EVALUATE_REFUSAL_CODE) {
        console.log(error.usage, error.answers)
      }
      throw error
    }

    The message text does not change. The error is still an Error, but its name is now 'EvaluateError', so logs and the OpenTelemetry error.type show that name instead of 'Error'.

Patch Changes

  • #1857 483f59a - Drop temperature, top_p, and top_logprobs on GPT-6 reasoning models, and request encrypted reasoning for those models. OpenAI returns 400 when these fields are sent. They are kept when reasoning effort is none, which OpenAI accepts.

  • #1868 fe83aa0 - Remove model ids that providers have retired. Each one now fails on the provider's API, so the types no longer accept it.

    • Groq: llama-3.3-70b-versatile, llama-3.1-8b-instant, meta-llama/llama-4-maverick-17b-128e-instruct, meta-llama/llama-4-scout-17b-16e-instruct, meta-llama/llama-guard-4-12b, moonshotai/kimi-k2-instruct-0905, qwen/qwen3-32b. Adds qwen/qwen3.8-27b.
    • Mistral: pixtral-large-latest, pixtral-12b-2409, open-mistral-nemo.
    • OpenAI: chatgpt-4o-latest, codex-mini-latest, gpt-4o-audio, gpt-4o-mini-audio, gpt-5.6, dall-e-2, dall-e-3, computer-use-preview. The speech model gpt-4o-audio-preview is replaced by gpt-4o-mini-tts.
    • Anthropic: claude-opus-4-1, claude-opus-5-fast.
    • Gemini: imagen-4.0-generate-001, imagen-4.0-ultra-generate-001, imagen-4.0-fast-generate-001.

    Types and helpers that only served those models are removed:

    • @tanstack/ai-gemini: GeminiImageProviderOptions, GeminiAnyImageProviderOptions, GeminiAspectRatio, PersonGeneration, SafetyFilterLevel, ImagePromptLanguage, GEMINI_NATIVE_IMAGE_MODELS, isGeminiNativeImageModel. Every Gemini image model uses GeminiNativeImageProviderOptions.
    • @tanstack/openai-base: OpenAIComputerToolName. resolveComputerUseTool(tool) no longer takes a model.
    • @tanstack/ai-openai: the dall-e option and size types.
  • Updated dependencies [fcbd199, 39c1c79, 959f43e, 39c1c79, fa2a291, f7e7cce, 028f30f, 7a0a48b, 468063c, 36eab88, fe83aa0, 85204ea, 781a3a8, 39abb7e, f1b3f65, 49dbcf9]:

    • @tanstack/ai@1.0.0
    • @tanstack/ai-utils@1.0.0
    • @tanstack/openai-base@1.0.0