Skip to content

docs: fix outdated adapter/tool APIs and add typed-options guide#635

Merged
AlemTuzlak merged 1 commit into
mainfrom
docs/fix-adapter-and-tool-mistakes
May 25, 2026
Merged

docs: fix outdated adapter/tool APIs and add typed-options guide#635
AlemTuzlak merged 1 commit into
mainfrom
docs/fix-adapter-and-tool-mistakes

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

@AlemTuzlak AlemTuzlak commented May 25, 2026

Summary

Sweep across the docs to bring examples back in line with the current public surface, plus a new guide for the createXxxOptions family. Most fixes were copy-paste blockers — broken imports, fictional APIs, wrong factory signatures. Net -373 + 467 lines across 23 files; most of the additions are the new typed-options guide.

Broken imports / fictional APIs removed

  • TTS → Speech rename propagated through openai.md, gemini.md, media/text-to-speech.md, reference/functions/generateSpeech.md, plus the JSDoc on packages/typescript/ai/src/activities/generateSpeech/index.ts so the auto-generated reference stays correct.
  • Wrong config typesOpenAIChatConfig / AnthropicChatConfig / GeminiChatConfig*TextConfig in the adapter docs.
  • Wrong curry patterncreateXxxChat(apiKey, config)("model") → real createXxxChat(model, apiKey, config?) shape across OpenAI, Anthropic, Gemini, Ollama docs.
  • Fictional groqSpeech removed from groq.md (doesn't exist).
  • False "Grok has no TTS / transcription" corrected; grok.md now documents grokSpeech, grokTranscription, and grokRealtime. Also fixed an toStreamResponse typo to toServerSentEventsResponse.
  • Fictional createFalImage / createFalVideo removed from fal.md.
  • ElevenLabs gaps — added Speech, Audio, and Transcription sections (the package exports them, the doc previously claimed it was realtime-only).
  • Ollama signaturesollamaText(model) / createOllamaChat(model, hostOrConfig?).
  • Fabricated assertMessages removed from advanced/multimodal-content.md; replaced with a Standard-Schema (Zod) runtime validation example.
  • Wrong subpathtoolCacheMiddleware imports in advanced/middleware.md now point at @tanstack/ai/middlewares.
  • Missing zod imports in getting-started/overview.md and quick-start.md.
  • Vue antipatternquick-start-vue.md and api/ai-vue.md no longer tell users to write messages.value / isLoading.value inside <template>. Vue auto-unwraps refs in templates; .value is only needed inside <script setup>. Verified against examples/ts-vue-chat.

Tool docs

  • ToolCallState lifecycle corrected to the real enum (awaiting-input, input-streaming, input-complete, approval-requested, approval-responded, complete). Replaced invented states (executing, output-available, cancelled, completed).
  • part.arguments is a JSON string — tool-approval.md, tool-architecture.md, and client-tools.md now use part.input (already parsed when tools are typed via clientTools(...)) or JSON.parse(part.arguments) when not.
  • "JSON Schema infers any" → the real behavior is unknown; Standard Schema validators (Zod, Valibot, ArkType) give full inference.

Code-mode

  • Removed legacy chat({ model: "..." }) field — model lives on the adapter factory.

New content

  • docs/advanced/typed-options.md (added to config.json nav under Advanced) — covers the full createXxxOptions family (chat, summarize, image, audio, video, speech, transcription). Explains what they do (capture an adapter's full type so options stay narrowed when spread across modules), what they don't (no runtime behavior — identity functions), with journey-style examples for shared chat configuration and pre-configured image generation.

Test plan

  • pnpm test:docs — 298 markdown files scanned, no broken links
  • pnpm build:all — all 31 packages build
  • pnpm --filter @tanstack/ai test:types — clean
  • Visual spot-check on the rendered docs site if a reviewer wants to confirm the new typed-options page renders correctly in the nav

Summary by CodeRabbit

  • Documentation
    • Updated adapter documentation with consistent "factory pair" patterns across all providers.
    • Renamed OpenAI Text-to-Speech to "Speech" adapter for consistency.
    • Added comprehensive guide for typed pre-configured options.
    • Expanded documentation for ElevenLabs capabilities (text-to-speech, audio, transcription).
    • Added documentation for Grok text-to-speech and transcription features.
    • Updated tool approval workflow state lifecycle.
    • Improved Vue template examples for ref auto-unwrapping.

Review Change Stack

Sweep across docs to bring examples back in line with the current
public surface, plus a new guide for the createXxxOptions family.

Broken-import fixes (would have failed for users on copy-paste):
- openai/gemini: openaiTTS/geminiTTS -> openaiSpeech/geminiSpeech
- openai/anthropic/gemini: OpenAIChatConfig/AnthropicChatConfig/
  GeminiChatConfig -> *TextConfig
- openai/anthropic/gemini: corrected the createXxxChat curry pattern
  to the real (model, apiKey, config?) signature
- groq: removed fictional groqSpeech TTS section
- grok: corrected false "no TTS / no transcription" limitations and
  documented grokSpeech, grokTranscription, grokRealtime; fixed
  toStreamResponse -> toServerSentEventsResponse
- fal: removed fictional createFalImage / createFalVideo aliases
- elevenlabs: added Speech / Audio / Transcription sections
- ollama: corrected ollamaText / createOllamaChat factory signatures
- media/text-to-speech: global TTS -> Speech rename, fixed missing
  model args and explicit-API-key examples
- advanced/multimodal-content: removed fabricated assertMessages
  section, replaced with a Standard-Schema validation example
- advanced/middleware: toolCacheMiddleware imports point at the
  @tanstack/ai/middlewares subpath where the symbol actually lives
- getting-started overview / quick-start: added missing `z` imports
- getting-started quick-start-vue + api/ai-vue: corrected Vue
  template antipattern (refs auto-unwrap in templates; .value is
  only needed inside <script setup>)
- tools/tool-approval: corrected ToolCallState lifecycle to the
  real enum (awaiting-input, input-streaming, input-complete,
  approval-requested, approval-responded, complete); use part.input
  instead of stringifying the JSON-string part.arguments
- tools/client-tools: replaced invented `completed` state with the
  real `complete` state and fixed a broken state-check snippet
- tools/tool-architecture: part.arguments.to (string treated as
  object) -> part.input.to
- tools/tools, server-tools: "JSON Schema infers `any`" -> the real
  behavior is `unknown` (Standard Schema validators give full
  inference)
- code-mode: removed legacy chat({ model: "..." }) field
- generateSpeech JSDoc + auto-generated reference: openaiTTS ->
  openaiSpeech so docs stay correct after the next regenerate

New content:
- docs/advanced/typed-options.md — covers the full createXxxOptions
  family (chat, summarize, image, audio, video, speech,
  transcription), what they do (capture an adapter's full type so
  options stay narrowed when spread), what they don't (no runtime
  behavior), with journey-style examples. Added to config.json nav.

Verified with `pnpm test:docs` (298 markdown files, no broken links)
and `pnpm --filter @tanstack/ai test:types`.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR updates TanStack AI documentation to standardize adapter factory APIs across providers, rename OpenAI TTS to Speech, expand ElevenLabs and Grok capabilities, update tool approval states, clarify Vue ref handling, and introduce a new typed options guide.

Changes

Adapter Factory API Standardization

Layer / File(s) Summary
Anthropic and Gemini factory standardization
docs/adapters/anthropic.md, docs/adapters/gemini.md
Anthropic and Gemini adapters refactored to show consistent model-first parameter ordering: createAnthropicChat(model, apiKey, config?) and createGeminiChat(model, apiKey, config?), with updated examples and API reference documentation.
OpenAI and Ollama factory standardization
docs/adapters/openai.md, docs/adapters/ollama.md
OpenAI and Ollama documentation updated to factory pair pattern with model as first argument; OpenAI examples move to createOpenaiChat(model, apiKey, config?) form; Ollama transitions from host-only to createOllamaChat(model, hostOrConfig?).

Adapter Capability Updates

Layer / File(s) Summary
ElevenLabs speech, audio, and transcription support
docs/adapters/elevenlabs.md
ElevenLabs adapter documentation expanded with new sections for one-shot generation: generateSpeech with elevenlabsSpeech, generateAudio with elevenlabsAudio, and generateTranscription with elevenlabsTranscription; API reference and limitations updated.
Grok TTS, transcription, and realtime voice support
docs/adapters/grok.md
Grok documentation expanded with text-to-speech, transcription, and realtime voice sections; streaming example updated to use toServerSentEventsResponse; API reference extended with new adapter signatures; limitations section updated to remove TTS/transcription restrictions.
Groq TTS removal and Fal alias cleanup
docs/adapters/groq.md, docs/adapters/fal.md
Groq TTS documentation and API reference removed with expanded limitations section; Fal createFalImage and createFalVideo alias documentation removed from API reference.

OpenAI Speech API Renaming

Layer / File(s) Summary
Adapter and examples
docs/adapters/openai.md
OpenAI TTS renamed to Speech in API reference; example imports and adapter calls updated from openaiTTS to openaiSpeech.
Text-to-speech guide and function reference
docs/media/text-to-speech.md, docs/reference/functions/generateSpeech.md
All text-to-speech examples updated throughout to use openaiSpeech instead of openaiTTS, including streaming, server function, error handling, and explicit API key examples.
generateSpeech JSDoc examples
packages/typescript/ai/src/activities/generateSpeech/index.ts
generateSpeech source code JSDoc examples updated to use openaiSpeech.

Tool Approval and State Updates

Layer / File(s) Summary
Tool call states and lifecycle
docs/tools/client-tools.md, docs/tools/tool-approval.md, docs/tools/tool-architecture.md
Tool states documentation updated: completed renamed to complete, new approval-requested and approval-responded states added; examples updated to use part.state === "complete" and part.input instead of part.arguments.

Vue Ref Handling and Runtime Validation

Layer / File(s) Summary
Vue template ref auto-unwrapping
docs/api/ai-vue.md, docs/getting-started/quick-start-vue.md
Vue documentation clarified for template ref auto-unwrapping; useChat examples updated to use bare ref names in templates instead of .value access.
Dynamic message validation guidance
docs/advanced/multimodal-content.md
Validation guidance updated to recommend runtime schema validation (Zod) for externally sourced messages instead of type-only assertions.

New Documentation Pages and Configuration

Layer / File(s) Summary
Typed pre-configured options documentation
docs/advanced/typed-options.md
New comprehensive guide explaining createXxxOptions pattern for building reusable typed configuration objects for AI activities; includes examples for chat, image generation, and related guides.
Middleware import path updates
docs/advanced/middleware.md
Middleware documentation updated to import toolCacheMiddleware and related types from @tanstack/ai/middlewares submodule.
Documentation config updates and code example fixes
docs/config.json, docs/getting-started/overview.md, docs/getting-started/quick-start.md, docs/code-mode/code-mode.md
Navigation config updated with new Advanced section entries; example imports consolidated; code-mode example simplified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • crutchcorn
  • tombeckenham

🐰 A Carrot's Ode to Clearer Docs

The factory signatures hop in line,
With model first, the patterns shine,
From TTS speech now comes its name,
Tool states dance in approval's game,
And Vue templates, unwrapped and free—
Better docs make code harmony!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main changes: fixing outdated adapter/tool APIs in documentation and adding a new typed-options guide.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering all required sections: changes, checklist, and release impact with clear details about what was fixed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/fix-adapter-and-tool-mistakes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: lockfile failed supply-chain policy check. Run pnpm install locally to update the lockfile.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 25, 2026

View your CI Pipeline Execution ↗ for commit b243024

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 1m 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-25 13:07:53 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 25, 2026

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@635

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@635

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@635

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@635

@tanstack/ai-code-mode-skills

npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@635

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@635

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@635

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@635

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@635

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@635

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@635

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@635

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@635

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@635

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@635

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@635

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@635

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@635

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@635

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@635

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@635

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@635

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@635

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@635

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@635

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@635

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@635

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@635

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@635

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@635

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@635

commit: b243024

@AlemTuzlak AlemTuzlak merged commit 3796438 into main May 25, 2026
9 of 10 checks passed
@AlemTuzlak AlemTuzlak deleted the docs/fix-adapter-and-tool-mistakes branch May 25, 2026 13:14
@coderabbitai coderabbitai Bot mentioned this pull request May 28, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant