diff --git a/.changeset/audio-activity.md b/.changeset/audio-activity.md new file mode 100644 index 000000000..4553377d1 --- /dev/null +++ b/.changeset/audio-activity.md @@ -0,0 +1,12 @@ +--- +'@tanstack/ai': minor +--- + +feat: add generateAudio activity for music and sound-effect generation + +Adds a new `audio` activity kind alongside the existing `tts` and `transcription` activities: + +- `generateAudio()` / `createAudioOptions()` functions +- `AudioAdapter` interface and `BaseAudioAdapter` base class +- `AudioGenerationOptions` / `AudioGenerationResult` / `GeneratedAudio` types +- `audio:request:started`, `audio:request:completed`, and `audio:usage` devtools events diff --git a/.changeset/audio-example-pages.md b/.changeset/audio-example-pages.md new file mode 100644 index 000000000..f2c3e3e4b --- /dev/null +++ b/.changeset/audio-example-pages.md @@ -0,0 +1,15 @@ +--- +--- + +chore: add ts-react-chat example pages and E2E coverage for audio providers + +**Example pages** (`examples/ts-react-chat`): + +- Updated text-to-speech and transcription pages with provider tabs (OpenAI, Gemini, Fal for TTS; OpenAI, Fal for transcription) +- Added a new `/generations/audio` page covering Gemini Lyria and Fal audio generation +- Added a shared `audio-providers` catalog and server-side adapter factories for audio, speech, and transcription + +**Tests**: + +- Added `@tanstack/ai-gemini` unit tests covering the Gemini TTS adapter (single-speaker default, multi-speaker config, missing-audio errors) +- Added a new `audio-gen` feature to the E2E harness with a Gemini Lyria adapter factory, route, UI, fixture, and spec diff --git a/.changeset/audio-generation-hook.md b/.changeset/audio-generation-hook.md new file mode 100644 index 000000000..c2decf396 --- /dev/null +++ b/.changeset/audio-generation-hook.md @@ -0,0 +1,24 @@ +--- +'@tanstack/ai': minor +'@tanstack/ai-client': minor +'@tanstack/ai-react': minor +'@tanstack/ai-solid': minor +'@tanstack/ai-vue': minor +'@tanstack/ai-svelte': minor +--- + +feat: add `useGenerateAudio` hook and streaming support for `generateAudio()` + +Closes the parity gap between audio generation and the other media +activities (image, speech, video, transcription, summarize): + +- `generateAudio()` now accepts `stream: true`, returning an + `AsyncIterable` that can be piped through + `toServerSentEventsResponse()`. +- `AudioGenerateInput` type added to `@tanstack/ai-client`. +- `useGenerateAudio` hook added to `@tanstack/ai-react`, + `@tanstack/ai-solid`, and `@tanstack/ai-vue`; matching + `createGenerateAudio` added to `@tanstack/ai-svelte`. All follow the same + `{ generate, result, isLoading, error, status, stop, reset }` shape as + the existing media hooks and support both `connection` (SSE) and + `fetcher` transports. diff --git a/.changeset/fal-audio-speech-transcription.md b/.changeset/fal-audio-speech-transcription.md new file mode 100644 index 000000000..54bee2ceb --- /dev/null +++ b/.changeset/fal-audio-speech-transcription.md @@ -0,0 +1,11 @@ +--- +'@tanstack/ai-fal': minor +--- + +feat: add audio, speech, and transcription adapters to @tanstack/ai-fal + +Adds three new tree-shakeable adapters alongside the existing `falImage()` and `falVideo()`: + +- `falSpeech()` — text-to-speech via models like Google `fal-ai/gemini-3.1-flash-tts`, `fal-ai/elevenlabs/tts/eleven-v3`, `fal-ai/minimax/speech-2.6-hd`, `fal-ai/kokoro/*` +- `falTranscription()` — speech-to-text via `fal-ai/whisper`, `fal-ai/wizper`, `fal-ai/speech-to-text/turbo`, `fal-ai/elevenlabs/speech-to-text` +- `falAudio()` — music and sound-effect generation via `fal-ai/minimax-music/v2.6`, `fal-ai/diffrhythm`, `fal-ai/lyria2`, `fal-ai/stable-audio-25/text-to-audio`, `fal-ai/elevenlabs/sound-effects/v2` diff --git a/.changeset/gemini-audio.md b/.changeset/gemini-audio.md new file mode 100644 index 000000000..b9e334a7d --- /dev/null +++ b/.changeset/gemini-audio.md @@ -0,0 +1,14 @@ +--- +'@tanstack/ai-gemini': minor +--- + +feat(ai-gemini): add Lyria 3 Pro / Clip audio adapter and Gemini 3.1 Flash TTS + +**New adapter:** + +- `geminiAudio()` for Google Lyria music generation — supports `lyria-3-pro-preview` (full-length songs, MP3/WAV 48 kHz stereo) and `lyria-3-clip-preview` (30-second MP3 clips) + +**Enhanced:** + +- Added `gemini-3.1-flash-tts-preview` to the TTS model list (70+ languages, 200+ audio tags for expressive control) +- Added `multiSpeakerVoiceConfig` to `GeminiTTSProviderOptions` for 2-speaker dialogue generation diff --git a/.changeset/generated-media-union.md b/.changeset/generated-media-union.md new file mode 100644 index 000000000..06c0b2a2f --- /dev/null +++ b/.changeset/generated-media-union.md @@ -0,0 +1,20 @@ +--- +'@tanstack/ai': minor +'@tanstack/ai-openrouter': patch +'@tanstack/ai-fal': patch +'@tanstack/ai-openai': patch +'@tanstack/ai-gemini': patch +'@tanstack/ai-grok': patch +--- + +Tighten `GeneratedImage` and `GeneratedAudio` to enforce exactly one of `url` or `b64Json` via a mutually-exclusive `GeneratedMediaSource` union. + +Both types previously declared `url?` and `b64Json?` as independently optional, which allowed meaningless `{}` values and objects that set both fields. They now require exactly one: + +```ts +type GeneratedMediaSource = + | { url: string; b64Json?: never } + | { b64Json: string; url?: never } +``` + +Existing read patterns like `img.url || \`data:image/png;base64,${img.b64Json}\``continue to work unchanged. The only runtime-visible change is that the`@tanstack/ai-openrouter`and`@tanstack/ai-fal`image adapters no longer populate`url`with a synthesized`data:image/png;base64,...`URI when the provider returns base64 — they return`{ b64Json }`only. Consumers that want a data URI should build it from`b64Json` at render time. diff --git a/docs/adapters/fal.md b/docs/adapters/fal.md index 22e4c4e2b..76ae71599 100644 --- a/docs/adapters/fal.md +++ b/docs/adapters/fal.md @@ -13,7 +13,7 @@ keywords: - adapter --- -The fal.ai adapter provides access to 600+ models on the fal.ai platform for image generation and video generation. Unlike text-focused adapters, the fal adapter is **media-focused** — it supports `generateImage()` and `generateVideo()` but does not support `chat()` or tools. Audio and speech support are coming soon. +The fal.ai adapter provides access to 600+ models on the fal.ai platform for image, video, audio, speech, and transcription. Unlike text-focused adapters, the fal adapter is **media-focused** — it supports `generateImage()`, `generateVideo()`, `generateAudio()`, `generateSpeech()`, and `generateTranscription()` but does not support `chat()` or tools. For a full working example, see the [fal.ai example app](https://github.com/TanStack/ai/tree/main/examples/ts-react-media). @@ -209,6 +209,113 @@ const job = await generateVideo({ }); ``` +## Text-to-Speech + +Text-to-speech uses `falSpeech()` with the `generateSpeech()` activity. The adapter fetches the generated audio from fal's CDN and returns it as base64-encoded data to match the `TTSResult` contract. + +```typescript +import { generateSpeech } from "@tanstack/ai"; +import { falSpeech } from "@tanstack/ai-fal"; + +const result = await generateSpeech({ + adapter: falSpeech("fal-ai/kokoro/american-english"), + text: "Hello from fal!", + voice: "af_heart", + speed: 1.0, +}); + +// result.audio is a base64-encoded string +console.log(result.format); // e.g. "wav" +console.log(result.contentType); // e.g. "audio/wav" +``` + +### Google Gemini 3.1 Flash TTS + +Google's newest TTS model (`fal-ai/gemini-3.1-flash-tts`) supports 80+ languages and introduces **granular audio tags** for expressive control — you can embed speaker tags and style cues directly in the text. + +```typescript +const result = await generateSpeech({ + adapter: falSpeech("fal-ai/gemini-3.1-flash-tts"), + text: "[warm, enthusiastic] Welcome to TanStack AI! [pause] Let's build something great.", + voice: "Kore", +}); +``` + +> **Note:** This model is newer than `@fal-ai/client@1.9.1`'s type map, so `modelOptions` won't autocomplete. The call still works — the fal adapter accepts any model ID as a string. Type-safe autocomplete will land when fal's SDK types catch up. + +### ElevenLabs v3 + +```typescript +const result = await generateSpeech({ + adapter: falSpeech("fal-ai/elevenlabs/tts/eleven-v3"), + text: "Welcome to TanStack AI.", + modelOptions: { + voice: "Rachel", + stability: 0.5, + }, +}); +``` + +## Transcription + +Speech-to-text uses `falTranscription()` with the `generateTranscription()` activity. The `audio` input accepts a URL string, `Blob`, `File`, or `ArrayBuffer` — `ArrayBuffer` is automatically wrapped in a `Blob` for upload. + +```typescript +import { generateTranscription } from "@tanstack/ai"; +import { falTranscription } from "@tanstack/ai-fal"; + +const result = await generateTranscription({ + adapter: falTranscription("fal-ai/whisper"), + audio: "https://example.com/recording.mp3", + language: "en", +}); + +console.log(result.text); +console.log(result.language); + +// When the model returns word/segment timestamps, they're mapped to result.segments +for (const segment of result.segments ?? []) { + console.log(`[${segment.start}s → ${segment.end}s] ${segment.text}`); +} +``` + +## Audio Generation (Music & Sound Effects) + +Music and sound-effect generation uses `falAudio()` with the `generateAudio()` activity. Unlike TTS, the result is returned as a URL in `result.audio.url` (you can fetch it yourself if you need raw bytes). + +```typescript +import { generateAudio } from "@tanstack/ai"; +import { falAudio } from "@tanstack/ai-fal"; + +// Music generation with MiniMax Music 2.6 (latest) +const music = await generateAudio({ + adapter: falAudio("fal-ai/minimax-music/v2.6"), + prompt: "City Pop, 80s retro, groovy synth bass, warm female vocal, 104 BPM, nostalgic urban night", +}); + +console.log(music.audio.url); +``` + +```typescript +// DiffRhythm with explicit lyrics +const lyrical = await generateAudio({ + adapter: falAudio("fal-ai/diffrhythm"), + prompt: "An upbeat electronic track with synths", + modelOptions: { + lyrics: "[verse]\nHello world\n[chorus]\nLa la la", + }, +}); +``` + +```typescript +// Sound effects +const sfx = await generateAudio({ + adapter: falAudio("fal-ai/elevenlabs/sound-effects/v2"), + prompt: "Thunderclap with rain", + duration: 5, +}); +``` + ## Popular Models ### Image Models @@ -233,6 +340,49 @@ const job = await generateVideo({ | `fal-ai/ltx-2/text-to-video/fast` | Text-to-Video | Fast text-to-video | | `fal-ai/ltx-2/image-to-video/fast` | Image-to-Video | Fast image-to-video animation | +### Text-to-Speech Models + +| Model | Description | +|-------|-------------| +| `fal-ai/gemini-3.1-flash-tts` | **New** — Google's flagship TTS with 80+ languages and expressive audio tags | +| `fal-ai/elevenlabs/tts/eleven-v3` | ElevenLabs v3 expressive multi-voice TTS | +| `fal-ai/elevenlabs/tts/turbo-v2.5` | Low-latency ElevenLabs TTS | +| `fal-ai/minimax/speech-2.6-hd` | MiniMax HD speech synthesis | +| `fal-ai/minimax/speech-2.6-turbo` | MiniMax low-latency variant | +| `fal-ai/kokoro/american-english` | Kokoro multilingual TTS — also `british-english`, `french`, `spanish`, `italian`, `japanese`, `mandarin-chinese`, `hindi`, `brazilian-portuguese` | +| `fal-ai/inworld-tts` | Inworld TTS-1.5 Max | +| `fal-ai/chatterbox/text-to-speech/multilingual` | Chatterbox multilingual TTS | +| `fal-ai/dia-tts` | Dia expressive dialogue TTS | +| `fal-ai/orpheus-tts` | Orpheus open-source TTS | +| `fal-ai/f5-tts` | F5-TTS voice cloning | +| `fal-ai/vibevoice/7b` | VibeVoice 7B conversational TTS | + +### Transcription Models + +| Model | Description | +|-------|-------------| +| `fal-ai/whisper` | OpenAI Whisper on fal infra | +| `fal-ai/wizper` | Faster-whisper variant with word-level timestamps | +| `fal-ai/speech-to-text/turbo` | Turbo STT with diarization | +| `fal-ai/elevenlabs/speech-to-text` | ElevenLabs STT | + +### Audio / Music Models + +| Model | Mode | Description | +|-------|------|-------------| +| `fal-ai/minimax-music/v2.6` | Music | **New** — MiniMax Music 2.6, full vocal + instrumental compositions from a prompt | +| `fal-ai/minimax-music/v2.5` | Music | MiniMax Music 2.5 | +| `fal-ai/minimax-music/v2` | Music | MiniMax Music v2 — supports `lyrics_prompt` | +| `fal-ai/diffrhythm` | Music | DiffRhythm — prompt + lyrics | +| `fal-ai/lyria2` | Music | Google Lyria 2 high-fidelity music | +| `fal-ai/stable-audio-25/text-to-audio` | Music / Audio | Stability AI Stable Audio 2.5 | +| `fal-ai/mmaudio-v2/text-to-audio` | Audio | MMAudio v2 text-to-audio | +| `fal-ai/elevenlabs/sound-effects/v2` | SFX | ElevenLabs sound-effect generation | +| `fal-ai/beatoven/sound-effect-generation` | SFX | Beatoven professional sound effects | +| `fal-ai/thinksound` | Audio | Thinksound reasoning-based audio generation | + +> **Very new models** (e.g. `gemini-3.1-flash-tts`, `minimax-music/v2.6`, `beatoven/sound-effect-generation`) may not yet appear in `@fal-ai/client`'s type map — they still work as plain string model IDs, you just won't get autocomplete for their `modelOptions`. + ## Environment Variables Create an API key at [fal.ai](https://fal.ai) and set it in your environment: @@ -275,6 +425,42 @@ Creates a fal.ai video adapter using the `FAL_KEY` environment variable or an ex Alias for `falVideo()`. +### `falSpeech(model, config?)` + +Creates a fal.ai text-to-speech adapter. + +**Parameters:** + +- `model` - The fal.ai TTS model ID (e.g., `"fal-ai/kokoro/american-english"`) +- `config.apiKey?` - Your fal.ai API key (falls back to `FAL_KEY` env var) +- `config.proxyUrl?` - Proxy URL for client-side usage + +**Returns:** A `FalSpeechAdapter` instance for use with `generateSpeech()`. The adapter fetches the generated audio URL from fal and returns it as base64 in `result.audio`. + +### `falTranscription(model, config?)` + +Creates a fal.ai transcription (speech-to-text) adapter. + +**Parameters:** + +- `model` - The fal.ai STT model ID (e.g., `"fal-ai/whisper"`) +- `config.apiKey?` - Your fal.ai API key (falls back to `FAL_KEY` env var) +- `config.proxyUrl?` - Proxy URL for client-side usage + +**Returns:** A `FalTranscriptionAdapter` instance for use with `generateTranscription()`. + +### `falAudio(model, config?)` + +Creates a fal.ai audio generation adapter (music and sound effects). + +**Parameters:** + +- `model` - The fal.ai audio model ID (e.g., `"fal-ai/diffrhythm"`, `"fal-ai/minimax-music/v2"`) +- `config.apiKey?` - Your fal.ai API key (falls back to `FAL_KEY` env var) +- `config.proxyUrl?` - Proxy URL for client-side usage + +**Returns:** A `FalAudioAdapter` instance for use with `generateAudio()`. The result contains a URL at `result.audio.url`. + ### `getFalApiKeyFromEnv()` Reads the `FAL_KEY` environment variable. Throws if not set. @@ -288,9 +474,8 @@ Configures the underlying `@fal-ai/client`. Called automatically by adapter cons ## Limitations - **No text/chat support** — Use OpenAI, Anthropic, Gemini, or another text adapter for `chat()` -- **No tools support** — Tool definitions are not applicable to image/video generation +- **No tools support** — Tool definitions are not applicable to media generation - **No summarization** — Use a text adapter for `summarize()` -- **No TTS or transcription yet** — Audio and speech support are coming soon - **Video is experimental** — The video generation API may change in future releases ## Next Steps diff --git a/docs/advanced/debug-logging.md b/docs/advanced/debug-logging.md index c480024c2..3ebec740b 100644 --- a/docs/advanced/debug-logging.md +++ b/docs/advanced/debug-logging.md @@ -128,7 +128,7 @@ const logger: Logger = { | Category | Logs | Applies to | |----------|------|------------| | `request` | Outgoing call to a provider (model, message count, tool count) | All activities | -| `provider` | Every raw chunk/frame received from a provider SDK | Streaming activities (chat, realtime) | +| `provider` | Every raw chunk/frame received from a provider SDK | Streaming activities (`chat`, `realtime`, and streaming `generateAudio`/`generateSpeech`/`generateTranscription`) | | `output` | Every chunk or result yielded to the caller | All activities | | `middleware` | Inputs and outputs around every middleware hook | `chat()` only | | `tools` | Before/after tool call execution | `chat()` only | @@ -154,8 +154,12 @@ The same `debug` option works on every activity: summarize({ adapter, text, debug: true }); generateImage({ adapter, prompt: "a cat", debug: { logger } }); generateSpeech({ adapter, text, debug: { request: true } }); +generateAudio({ adapter, prompt: "ambient piano", debug: true }); +generateTranscription({ adapter, audio, debug: { provider: true } }); ``` +When streaming any of these (`generateAudio`, `generateSpeech`, `generateTranscription` with `stream: true`), the `provider` category emits the raw SDK chunks and `output` emits the AG-UI-shaped chunks yielded to the caller — useful when a media pipeline looks stuck or the bytes arriving don't match what you expected. + The chat-only categories (`middleware`, `tools`, `agentLoop`, `config`) simply never fire for these activities because those concepts don't exist in their pipelines. ## Related diff --git a/docs/config.json b/docs/config.json index 97818bc8b..f24a5fa0a 100644 --- a/docs/config.json +++ b/docs/config.json @@ -146,6 +146,10 @@ "label": "Transcription", "to": "media/transcription" }, + { + "label": "Audio Generation", + "to": "media/audio-generation" + }, { "label": "Image Generation", "to": "media/image-generation" diff --git a/docs/media/audio-generation.md b/docs/media/audio-generation.md new file mode 100644 index 000000000..6cc3e5aeb --- /dev/null +++ b/docs/media/audio-generation.md @@ -0,0 +1,218 @@ +--- +title: Audio Generation +id: audio-generation +order: 15 +--- + +# Audio Generation + +TanStack AI's `generateAudio()` activity produces audio content — music, soundscapes, or sound effects — from a text prompt. It's distinct from [Text-to-Speech](./text-to-speech), which is optimized for spoken-word synthesis. + +## Overview + +Audio generation is handled by audio adapters that follow the same tree-shakeable architecture as other adapters in TanStack AI. + +Currently supported: + +- **Google Gemini**: Lyria 3 Pro and Lyria 3 Clip music generation +- **fal.ai**: MiniMax Music, DiffRhythm, Google Lyria 2, Stable Audio 2.5, MMAudio, ElevenLabs sound effects, Thinksound, and more + +## Basic Usage + +### Google Lyria (Music) + +Google's Lyria models generate full-length songs with vocals and instrumentation. `lyria-3-pro-preview` handles multi-verse compositions, while `lyria-3-clip-preview` produces 30-second clips. + +```typescript +import { generateAudio } from '@tanstack/ai' +import { geminiAudio } from '@tanstack/ai-gemini' + +const result = await generateAudio({ + adapter: geminiAudio('lyria-3-pro-preview'), + prompt: 'Uplifting indie pop with layered vocals and jangly guitars', +}) + +console.log(result.audio.url) // URL to the generated audio file +console.log(result.audio.contentType) // e.g. "audio/mpeg" +``` + +### fal.ai + +fal.ai gives access to a broad catalogue of music, SFX, and general audio models through a single `falAudio` adapter. + +#### Music Generation (MiniMax Music 2.6) + +MiniMax's latest music model creates full compositions — vocals, backing music, and arrangements — from a single prompt. + +```typescript +import { generateAudio } from '@tanstack/ai' +import { falAudio } from '@tanstack/ai-fal' + +const result = await generateAudio({ + adapter: falAudio('fal-ai/minimax-music/v2.6'), + prompt: 'City Pop, 80s retro, groovy synth bass, warm female vocal, 104 BPM', +}) + +console.log(result.audio.url) // URL to the generated audio file +console.log(result.audio.contentType) // e.g. "audio/wav" +``` + +#### Music with Explicit Lyrics (DiffRhythm) + +```typescript +const result = await generateAudio({ + adapter: falAudio('fal-ai/diffrhythm'), + prompt: 'An upbeat electronic track with synths', + modelOptions: { + lyrics: '[verse]\nHello world\n[chorus]\nLa la la', + }, +}) +``` + +#### Sound Effects + +```typescript +const result = await generateAudio({ + adapter: falAudio('fal-ai/elevenlabs/sound-effects/v2'), + prompt: 'Thunderclap followed by heavy rain', + duration: 5, +}) +``` + +#### MiniMax Music v2 (lyrics_prompt) + +Earlier MiniMax variants use a `lyrics_prompt` field for lyric guidance. + +```typescript +const result = await generateAudio({ + adapter: falAudio('fal-ai/minimax-music/v2'), + prompt: 'A dreamy pop ballad in the style of the 80s', + modelOptions: { + lyrics_prompt: '[instrumental]', + }, +}) +``` + +If a request doesn't return the audio you expected — a model silently truncates, a provider rejects a prompt, or the response shape looks off — pass `debug: true` to see every chunk the provider SDK emits. See [Debug Logging](../advanced/debug-logging). + +## Options + +| Option | Type | Description | +|--------|------|-------------| +| `adapter` | `AudioAdapter` | The adapter created via `falAudio()` (required) | +| `prompt` | `string` | Text description of the audio to generate (required) | +| `duration` | `number` | Desired duration in seconds (model-dependent) | +| `modelOptions` | `object` | Provider-specific options (fully typed when the model ID is passed as a string literal) | +| `debug` | `DebugOption` | Enable per-category debug logging (`true`, `false`, or a `DebugConfig` — see [Debug Logging](../advanced/debug-logging)) | + +## Result Shape + +```typescript +interface AudioGenerationResult { + id: string + model: string + audio: { + url?: string + b64Json?: string + contentType?: string + duration?: number + } + usage?: { inputTokens?: number; outputTokens?: number; totalTokens?: number } +} +``` + +Gemini returns base64-encoded bytes in `result.audio.b64Json`. The fal adapter returns a URL in `result.audio.url` — if you need raw bytes, `fetch()` the URL yourself: + +```typescript +const bytes = new Uint8Array( + await (await fetch(result.audio.url!)).arrayBuffer() +) +``` + +## Client Hook (`useGenerateAudio`) + +For client-side usage, framework integrations expose a `useGenerateAudio` +hook (or `createGenerateAudio` in Svelte) that wraps the same generation +flow. It mirrors the API of `useGenerateSpeech`, `useGenerateImage`, and +other media hooks — see [Generation Hooks](./generation-hooks) for the full +shape. + +### Server (streaming SSE route) + +```typescript +// routes/api/generate/audio.ts +import { generateAudio, toServerSentEventsResponse } from '@tanstack/ai' +import { falAudio } from '@tanstack/ai-fal' + +export async function POST(req: Request) { + const { prompt, duration } = await req.json() + + return toServerSentEventsResponse( + generateAudio({ + adapter: falAudio('fal-ai/diffrhythm'), + prompt, + duration, + stream: true, + }), + ) +} +``` + +### Client (React) + +```tsx +import { useGenerateAudio } from '@tanstack/ai-react' +import { fetchServerSentEvents } from '@tanstack/ai-client' + +function AudioGenerator() { + const { generate, result, isLoading, error, reset } = useGenerateAudio({ + connection: fetchServerSentEvents('/api/generate/audio'), + }) + + return ( +
+ + {error &&

Error: {error.message}

} + {result?.audio.url &&
+ ) +} +``` + +Use the `fetcher` option instead of `connection` when calling a TanStack +Start server function directly. + +## Differences vs Text-to-Speech + +| | `generateAudio()` | `generateSpeech()` | +|---|---|---| +| Purpose | Music, soundscapes, SFX | Spoken-word TTS | +| Result | `result.audio.url` or `result.audio.b64Json` | Base64 in `result.audio` | +| Primary input | `prompt` | `text` | +| Voice/speed controls | No | Yes (`voice`, `speed`) | + +Use `generateSpeech()` when you want a spoken voice, and `generateAudio()` when you want non-speech audio. + +## Environment Variables + +Each provider reads its own API key from the environment by default: + +```bash +GOOGLE_API_KEY=your-google-api-key +FAL_KEY=your-fal-api-key +``` + +Or pass it explicitly to the adapter: + +```typescript +geminiAudio('lyria-3-pro-preview', { apiKey: 'your-key' }) +falAudio('fal-ai/diffrhythm', { apiKey: 'your-key' }) +``` diff --git a/docs/media/generation-hooks.md b/docs/media/generation-hooks.md index 81d1b4cc6..d9adadc6a 100644 --- a/docs/media/generation-hooks.md +++ b/docs/media/generation-hooks.md @@ -2,11 +2,12 @@ title: Generation Hooks id: generation-hooks order: 7 -description: "Framework hooks for every TanStack AI media generation type — useGenerateImage, useGenerateSpeech, useTranscription, useSummarize, useGenerateVideo." +description: "Framework hooks for every TanStack AI media generation type — useGenerateImage, useGenerateAudio, useGenerateSpeech, useTranscription, useSummarize, useGenerateVideo." keywords: - tanstack ai - generation hooks - useGenerateImage + - useGenerateAudio - useGenerateSpeech - useTranscription - useSummarize @@ -16,7 +17,7 @@ keywords: # Generation Hooks -TanStack AI provides framework hooks for every generation type: image, speech, transcription, summarization, and video. Each hook connects to a server endpoint and manages loading, error, and result state for you. +TanStack AI provides framework hooks for every generation type: image, audio, speech, transcription, summarization, and video. Each hook connects to a server endpoint and manages loading, error, and result state for you. ## Overview @@ -25,6 +26,7 @@ Generation hooks share a consistent API across all media types: | Hook | Input | Result Type | |------|-------|-------------| | `useGenerateImage` | `ImageGenerateInput` | `ImageGenerationResult` | +| `useGenerateAudio` | `AudioGenerateInput` | `AudioGenerationResult` | | `useGenerateSpeech` | `SpeechGenerateInput` | `TTSResult` | | `useTranscription` | `TranscriptionGenerateInput` | `TranscriptionResult` | | `useSummarize` | `SummarizeGenerateInput` | `SummarizationResult` | diff --git a/docs/media/text-to-speech.md b/docs/media/text-to-speech.md index 18040e963..e281ff69b 100644 --- a/docs/media/text-to-speech.md +++ b/docs/media/text-to-speech.md @@ -23,6 +23,7 @@ Text-to-speech (TTS) is handled by TTS adapters that follow the same tree-shakea - **OpenAI**: TTS-1, TTS-1-HD, and audio-capable GPT-4o models - **Gemini**: Gemini 2.5 Flash TTS (experimental) +- **fal.ai**: Kokoro, ElevenLabs, MiniMax, Chatterbox, Dia, Orpheus, F5-TTS, VibeVoice, and more ## Basic Usage @@ -65,6 +66,47 @@ const result = await generateSpeech({ console.log(result.audio) // Base64 encoded audio ``` +### fal.ai Text-to-Speech + +fal.ai offers a broad selection of TTS models — Google's brand-new `gemini-3.1-flash-tts`, ElevenLabs v3, MiniMax 2.6 HD, Kokoro's multilingual voices, and more. Pass the model ID as a string literal for fully typed `modelOptions`. + +```typescript +import { generateSpeech } from '@tanstack/ai' +import { falSpeech } from '@tanstack/ai-fal' + +// Google Gemini 3.1 Flash TTS — 80+ languages, expressive audio tags +const result = await generateSpeech({ + adapter: falSpeech('fal-ai/gemini-3.1-flash-tts'), + text: '[warm, enthusiastic] Welcome to TanStack AI!', + voice: 'Kore', +}) +``` + +```typescript +// Kokoro multilingual +const result = await generateSpeech({ + adapter: falSpeech('fal-ai/kokoro/american-english'), + text: 'Hello from fal!', + voice: 'af_heart', + speed: 1.0, +}) + +console.log(result.audio) // Base64 encoded audio +console.log(result.format) // e.g. "wav" +``` + +```typescript +// ElevenLabs v3 with model-specific options +const result = await generateSpeech({ + adapter: falSpeech('fal-ai/elevenlabs/tts/eleven-v3'), + text: 'Welcome to TanStack AI.', + modelOptions: { + voice: 'Rachel', + stability: 0.5, + }, +}) +``` + ## Options ### Common Options @@ -444,6 +486,8 @@ try { > **Tip:** To trigger speech generation from your frontend with loading states, see [Generation Hooks](./generation-hooks). +> **Debugging:** When a TTS request fails or produces unexpected output, pass `debug: true` on `generateSpeech({...})` to log the outgoing request, every raw provider chunk, and any caught error. See [Debug Logging](../advanced/debug-logging). + ## Environment Variables The TTS adapters use the same environment variables as other adapters: diff --git a/docs/media/transcription.md b/docs/media/transcription.md index 3ef7cfe06..eaf64dfad 100644 --- a/docs/media/transcription.md +++ b/docs/media/transcription.md @@ -23,6 +23,7 @@ Audio transcription is handled by transcription adapters that follow the same tr Currently supported: - **OpenAI**: Whisper-1, GPT-4o-transcribe, GPT-4o-mini-transcribe +- **fal.ai**: Whisper, Wizper, speech-to-text turbo, ElevenLabs speech-to-text ## Basic Usage @@ -75,6 +76,29 @@ const result = await generateTranscription({ }) ``` +### fal.ai Transcription + +fal.ai offers Whisper, Wizper, and other STT models. The `audio` input accepts a URL, `File`, `Blob`, or `ArrayBuffer` (auto-wrapped in a `Blob`). + +```typescript +import { generateTranscription } from '@tanstack/ai' +import { falTranscription } from '@tanstack/ai-fal' + +const result = await generateTranscription({ + adapter: falTranscription('fal-ai/whisper'), + audio: 'https://example.com/recording.mp3', + language: 'en', +}) + +console.log(result.text) +console.log(result.language) + +// Models that return word/chunk timestamps populate result.segments +for (const segment of result.segments ?? []) { + console.log(`[${segment.start}s → ${segment.end}s] ${segment.text}`) +} +``` + ## Options ### Common Options @@ -488,6 +512,8 @@ try { } ``` +> **Debugging:** When a transcription returns garbage, empty segments, or the provider rejects your audio format, pass `debug: true` on `generateTranscription({...})` to log the outgoing request and every raw provider chunk. See [Debug Logging](../advanced/debug-logging). + ## Environment Variables The transcription adapter uses: diff --git a/docs/reference/classes/ConsoleLogger.md b/docs/reference/classes/ConsoleLogger.md new file mode 100644 index 000000000..400b565de --- /dev/null +++ b/docs/reference/classes/ConsoleLogger.md @@ -0,0 +1,146 @@ +--- +id: ConsoleLogger +title: ConsoleLogger +--- + +# Class: ConsoleLogger + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L25) + +Pluggable logger interface consumed by every `@tanstack/ai` activity when `debug` is enabled. Supply a custom implementation via `debug: { logger }` on `chat()`, `summarize()`, `generateImage()`, etc. The four methods correspond to log levels: use `debug` for chunk-level diagnostic output, `info`/`warn` for notable events, `error` for caught exceptions. + +## Implements + +- [`Logger`](../interfaces/Logger.md) + +## Constructors + +### Constructor + +```ts +new ConsoleLogger(): ConsoleLogger; +``` + +#### Returns + +`ConsoleLogger` + +## Methods + +### debug() + +```ts +debug(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L27) + +Log a debug-level message; forwards to `console.debug`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`debug`](../interfaces/Logger.md#debug) + +*** + +### error() + +```ts +error(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L45) + +Log an error-level message; forwards to `console.error`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`error`](../interfaces/Logger.md#error) + +*** + +### info() + +```ts +info(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L33) + +Log an info-level message; forwards to `console.info`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`info`](../interfaces/Logger.md#info) + +*** + +### warn() + +```ts +warn(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:39](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L39) + +Log a warning-level message; forwards to `console.warn`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`warn`](../interfaces/Logger.md#warn) diff --git a/docs/reference/functions/chat.md b/docs/reference/functions/chat.md index 9d8c7315a..f65c579a8 100644 --- a/docs/reference/functions/chat.md +++ b/docs/reference/functions/chat.md @@ -9,7 +9,7 @@ title: chat function chat(options): TextActivityResult; ``` -Defined in: [packages/typescript/ai/src/activities/chat/index.ts:1451](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L1451) +Defined in: [packages/typescript/ai/src/activities/chat/index.ts:1512](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L1512) Text activity - handles agentic text generation, one-shot text generation, and agentic structured output. diff --git a/docs/reference/functions/createChatOptions.md b/docs/reference/functions/createChatOptions.md index 06f56e2fd..a05f78cf2 100644 --- a/docs/reference/functions/createChatOptions.md +++ b/docs/reference/functions/createChatOptions.md @@ -9,7 +9,7 @@ title: createChatOptions function createChatOptions(options): TextActivityOptions; ``` -Defined in: [packages/typescript/ai/src/activities/chat/index.ts:203](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L203) +Defined in: [packages/typescript/ai/src/activities/chat/index.ts:213](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L213) Create typed options for the chat() function without executing. This is useful for pre-defining configurations with full type inference. diff --git a/docs/reference/functions/createImageOptions.md b/docs/reference/functions/createImageOptions.md index 041ad8dd5..af24183cc 100644 --- a/docs/reference/functions/createImageOptions.md +++ b/docs/reference/functions/createImageOptions.md @@ -9,7 +9,7 @@ title: createImageOptions function createImageOptions(options): ImageActivityOptions; ``` -Defined in: [packages/typescript/ai/src/activities/generateImage/index.ts:244](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L244) +Defined in: [packages/typescript/ai/src/activities/generateImage/index.ts:270](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L270) Create typed options for the generateImage() function without executing. diff --git a/docs/reference/functions/createSpeechOptions.md b/docs/reference/functions/createSpeechOptions.md index e6df25ebb..c28f1d955 100644 --- a/docs/reference/functions/createSpeechOptions.md +++ b/docs/reference/functions/createSpeechOptions.md @@ -9,7 +9,7 @@ title: createSpeechOptions function createSpeechOptions(options): TTSActivityOptions; ``` -Defined in: [packages/typescript/ai/src/activities/generateSpeech/index.ts:181](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L181) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/index.ts:213](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L213) Create typed options for the generateSpeech() function without executing. diff --git a/docs/reference/functions/createSummarizeOptions.md b/docs/reference/functions/createSummarizeOptions.md index 89ef07c99..4423c9e1b 100644 --- a/docs/reference/functions/createSummarizeOptions.md +++ b/docs/reference/functions/createSummarizeOptions.md @@ -9,7 +9,7 @@ title: createSummarizeOptions function createSummarizeOptions(options): SummarizeActivityOptions; ``` -Defined in: [packages/typescript/ai/src/activities/summarize/index.ts:254](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L254) +Defined in: [packages/typescript/ai/src/activities/summarize/index.ts:300](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L300) Create typed options for the summarize() function without executing. diff --git a/docs/reference/functions/createTranscriptionOptions.md b/docs/reference/functions/createTranscriptionOptions.md index 1013de271..bd6fbbc4b 100644 --- a/docs/reference/functions/createTranscriptionOptions.md +++ b/docs/reference/functions/createTranscriptionOptions.md @@ -9,7 +9,7 @@ title: createTranscriptionOptions function createTranscriptionOptions(options): TranscriptionActivityOptions; ``` -Defined in: [packages/typescript/ai/src/activities/generateTranscription/index.ts:199](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L199) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/index.ts:231](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L231) Create typed options for the generateTranscription() function without executing. diff --git a/docs/reference/functions/createVideoOptions.md b/docs/reference/functions/createVideoOptions.md index 5a022e189..ad322b459 100644 --- a/docs/reference/functions/createVideoOptions.md +++ b/docs/reference/functions/createVideoOptions.md @@ -9,7 +9,7 @@ title: createVideoOptions function createVideoOptions(options): VideoCreateOptions; ``` -Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:488](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L488) +Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:547](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L547) Create typed options for the generateVideo() function without executing. diff --git a/docs/reference/functions/generateImage.md b/docs/reference/functions/generateImage.md index b83ede64c..bd3d002b3 100644 --- a/docs/reference/functions/generateImage.md +++ b/docs/reference/functions/generateImage.md @@ -9,7 +9,7 @@ title: generateImage function generateImage(options): ImageActivityResult; ``` -Defined in: [packages/typescript/ai/src/activities/generateImage/index.ts:167](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L167) +Defined in: [packages/typescript/ai/src/activities/generateImage/index.ts:176](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L176) Image activity - generates images from text prompts. diff --git a/docs/reference/functions/generateSpeech.md b/docs/reference/functions/generateSpeech.md index ccc909cfc..c33d777dc 100644 --- a/docs/reference/functions/generateSpeech.md +++ b/docs/reference/functions/generateSpeech.md @@ -9,7 +9,7 @@ title: generateSpeech function generateSpeech(options): TTSActivityResult; ``` -Defined in: [packages/typescript/ai/src/activities/generateSpeech/index.ts:119](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L119) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/index.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L128) TTS activity - generates speech from text. diff --git a/docs/reference/functions/generateTranscription.md b/docs/reference/functions/generateTranscription.md index 3bf6ec8c7..bfa949fc4 100644 --- a/docs/reference/functions/generateTranscription.md +++ b/docs/reference/functions/generateTranscription.md @@ -9,7 +9,7 @@ title: generateTranscription function generateTranscription(options): TranscriptionActivityResult; ``` -Defined in: [packages/typescript/ai/src/activities/generateTranscription/index.ts:134](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L134) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/index.ts:143](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L143) Transcription activity - converts audio to text. diff --git a/docs/reference/functions/generateVideo.md b/docs/reference/functions/generateVideo.md index 22cc2693e..f679c5fa6 100644 --- a/docs/reference/functions/generateVideo.md +++ b/docs/reference/functions/generateVideo.md @@ -9,7 +9,7 @@ title: generateVideo function generateVideo(options): TStream extends true ? AsyncIterable : Promise; ``` -Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:221](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L221) +Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:230](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L230) **`Experimental`** diff --git a/docs/reference/functions/getVideoJobStatus.md b/docs/reference/functions/getVideoJobStatus.md index 3e057d759..44247c5b5 100644 --- a/docs/reference/functions/getVideoJobStatus.md +++ b/docs/reference/functions/getVideoJobStatus.md @@ -14,7 +14,7 @@ function getVideoJobStatus(options): Promise<{ }>; ``` -Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L388) +Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:447](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L447) **`Experimental`** diff --git a/docs/reference/functions/summarize.md b/docs/reference/functions/summarize.md index dfa9201fc..e35280189 100644 --- a/docs/reference/functions/summarize.md +++ b/docs/reference/functions/summarize.md @@ -9,7 +9,7 @@ title: summarize function summarize(options): SummarizeActivityResult; ``` -Defined in: [packages/typescript/ai/src/activities/summarize/index.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L147) +Defined in: [packages/typescript/ai/src/activities/summarize/index.ts:156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L156) Summarize activity - generates summaries from text. diff --git a/docs/reference/index.md b/docs/reference/index.md index 0a9c3eb8b..d74201b3c 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -9,6 +9,7 @@ title: "@tanstack/ai" - [BatchStrategy](classes/BatchStrategy.md) - [CompositeStrategy](classes/CompositeStrategy.md) +- [ConsoleLogger](classes/ConsoleLogger.md) - [ImmediateStrategy](classes/ImmediateStrategy.md) - [PartialJSONParser](classes/PartialJSONParser.md) - [PunctuationStrategy](classes/PunctuationStrategy.md) @@ -33,6 +34,8 @@ title: "@tanstack/ai" - [ContentPartDataSource](interfaces/ContentPartDataSource.md) - [ContentPartUrlSource](interfaces/ContentPartUrlSource.md) - [CustomEvent](interfaces/CustomEvent.md) +- [DebugCategories](interfaces/DebugCategories.md) +- [DebugConfig](interfaces/DebugConfig.md) - [DefaultMessageMetadataByModality](interfaces/DefaultMessageMetadataByModality.md) - [DocumentPart](interfaces/DocumentPart.md) - [ErrorInfo](interfaces/ErrorInfo.md) @@ -47,6 +50,7 @@ title: "@tanstack/ai" - [IterationInfo](interfaces/IterationInfo.md) - [JSONParser](interfaces/JSONParser.md) - [JSONSchema](interfaces/JSONSchema.md) +- [Logger](interfaces/Logger.md) - [MessagesSnapshotEvent](interfaces/MessagesSnapshotEvent.md) - [ModelMessage](interfaces/ModelMessage.md) - [ProcessorResult](interfaces/ProcessorResult.md) @@ -146,6 +150,7 @@ title: "@tanstack/ai" - [ContentPart](type-aliases/ContentPart.md) - [ContentPartForInputModalitiesTypes](type-aliases/ContentPartForInputModalitiesTypes.md) - [ContentPartSource](type-aliases/ContentPartSource.md) +- [DebugOption](type-aliases/DebugOption.md) - [InferSchemaType](type-aliases/InferSchemaType.md) - [InferToolInput](type-aliases/InferToolInput.md) - [InferToolName](type-aliases/InferToolName.md) diff --git a/docs/reference/interfaces/AgentLoopState.md b/docs/reference/interfaces/AgentLoopState.md index 534d0a714..7135a6645 100644 --- a/docs/reference/interfaces/AgentLoopState.md +++ b/docs/reference/interfaces/AgentLoopState.md @@ -5,7 +5,7 @@ title: AgentLoopState # Interface: AgentLoopState -Defined in: [packages/typescript/ai/src/types.ts:630](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L630) +Defined in: [packages/typescript/ai/src/types.ts:631](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L631) State passed to agent loop strategy for determining whether to continue @@ -17,7 +17,7 @@ State passed to agent loop strategy for determining whether to continue finishReason: string | null; ``` -Defined in: [packages/typescript/ai/src/types.ts:636](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L636) +Defined in: [packages/typescript/ai/src/types.ts:637](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L637) Finish reason from the last response @@ -29,7 +29,7 @@ Finish reason from the last response iterationCount: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:632](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L632) +Defined in: [packages/typescript/ai/src/types.ts:633](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L633) Current iteration count (0-indexed) @@ -44,6 +44,6 @@ messages: ModelMessage< | null>[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:634](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L634) +Defined in: [packages/typescript/ai/src/types.ts:635](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L635) Current messages array diff --git a/docs/reference/interfaces/AudioPart.md b/docs/reference/interfaces/AudioPart.md index e968a1ccc..f9aae479b 100644 --- a/docs/reference/interfaces/AudioPart.md +++ b/docs/reference/interfaces/AudioPart.md @@ -5,7 +5,7 @@ title: AudioPart # Interface: AudioPart\ -Defined in: [packages/typescript/ai/src/types.ts:201](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L201) +Defined in: [packages/typescript/ai/src/types.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L202) Audio content part for multimodal messages. @@ -25,7 +25,7 @@ Provider-specific metadata type optional metadata: TMetadata; ``` -Defined in: [packages/typescript/ai/src/types.ts:206](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L206) +Defined in: [packages/typescript/ai/src/types.ts:207](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L207) Provider-specific metadata (e.g., format, sample rate) @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., format, sample rate) source: ContentPartSource; ``` -Defined in: [packages/typescript/ai/src/types.ts:204](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L204) +Defined in: [packages/typescript/ai/src/types.ts:205](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L205) Source of the audio content @@ -49,4 +49,4 @@ Source of the audio content type: "audio"; ``` -Defined in: [packages/typescript/ai/src/types.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L202) +Defined in: [packages/typescript/ai/src/types.ts:203](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L203) diff --git a/docs/reference/interfaces/BaseAGUIEvent.md b/docs/reference/interfaces/BaseAGUIEvent.md index 64cec4272..c2d5a5557 100644 --- a/docs/reference/interfaces/BaseAGUIEvent.md +++ b/docs/reference/interfaces/BaseAGUIEvent.md @@ -5,7 +5,7 @@ title: BaseAGUIEvent # Interface: BaseAGUIEvent -Defined in: [packages/typescript/ai/src/types.ts:785](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L785) +Defined in: [packages/typescript/ai/src/types.ts:794](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L794) Base structure for AG-UI events. Extends @ag-ui/core BaseEvent with TanStack AI additions. @@ -31,6 +31,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:787](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L787) +Defined in: [packages/typescript/ai/src/types.ts:796](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L796) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ContentPartDataSource.md b/docs/reference/interfaces/ContentPartDataSource.md index f97479f13..f56a29cbb 100644 --- a/docs/reference/interfaces/ContentPartDataSource.md +++ b/docs/reference/interfaces/ContentPartDataSource.md @@ -5,7 +5,7 @@ title: ContentPartDataSource # Interface: ContentPartDataSource -Defined in: [packages/typescript/ai/src/types.ts:142](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L142) +Defined in: [packages/typescript/ai/src/types.ts:143](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L143) Source specification for inline data content (base64). Requires a mimeType to ensure providers receive proper content type information. @@ -18,7 +18,7 @@ Requires a mimeType to ensure providers receive proper content type information. mimeType: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:155](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L155) +Defined in: [packages/typescript/ai/src/types.ts:156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L156) The MIME type of the content (e.g., 'image/png', 'audio/wav'). Required for data sources to ensure proper handling by providers. @@ -31,7 +31,7 @@ Required for data sources to ensure proper handling by providers. type: "data"; ``` -Defined in: [packages/typescript/ai/src/types.ts:146](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L146) +Defined in: [packages/typescript/ai/src/types.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L147) Indicates this is inline data content. @@ -43,6 +43,6 @@ Indicates this is inline data content. value: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:150](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L150) +Defined in: [packages/typescript/ai/src/types.ts:151](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L151) The base64-encoded content value. diff --git a/docs/reference/interfaces/ContentPartUrlSource.md b/docs/reference/interfaces/ContentPartUrlSource.md index a14d570ac..1c8847777 100644 --- a/docs/reference/interfaces/ContentPartUrlSource.md +++ b/docs/reference/interfaces/ContentPartUrlSource.md @@ -5,7 +5,7 @@ title: ContentPartUrlSource # Interface: ContentPartUrlSource -Defined in: [packages/typescript/ai/src/types.ts:162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L162) +Defined in: [packages/typescript/ai/src/types.ts:163](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L163) Source specification for URL-based content. mimeType is optional as it can often be inferred from the URL or response headers. @@ -18,7 +18,7 @@ mimeType is optional as it can often be inferred from the URL or response header optional mimeType: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L174) +Defined in: [packages/typescript/ai/src/types.ts:175](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L175) Optional MIME type hint for cases where providers can't infer it from the URL. @@ -30,7 +30,7 @@ Optional MIME type hint for cases where providers can't infer it from the URL. type: "url"; ``` -Defined in: [packages/typescript/ai/src/types.ts:166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L166) +Defined in: [packages/typescript/ai/src/types.ts:167](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L167) Indicates this is URL-referenced content. @@ -42,6 +42,6 @@ Indicates this is URL-referenced content. value: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:170](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L170) +Defined in: [packages/typescript/ai/src/types.ts:171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L171) HTTP(S) URL or data URI pointing to the content. diff --git a/docs/reference/interfaces/CustomEvent.md b/docs/reference/interfaces/CustomEvent.md index 789f6cedf..1b213a7a8 100644 --- a/docs/reference/interfaces/CustomEvent.md +++ b/docs/reference/interfaces/CustomEvent.md @@ -5,7 +5,7 @@ title: CustomEvent # Interface: CustomEvent -Defined in: [packages/typescript/ai/src/types.ts:1033](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1033) +Defined in: [packages/typescript/ai/src/types.ts:1042](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1042) Custom event for extensibility. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1035](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1035) +Defined in: [packages/typescript/ai/src/types.ts:1044](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1044) Model identifier for multi-model support diff --git a/docs/reference/interfaces/DebugCategories.md b/docs/reference/interfaces/DebugCategories.md new file mode 100644 index 000000000..4cc461279 --- /dev/null +++ b/docs/reference/interfaces/DebugCategories.md @@ -0,0 +1,110 @@ +--- +id: DebugCategories +title: DebugCategories +--- + +# Interface: DebugCategories + +Defined in: [packages/typescript/ai/src/logger/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L30) + +Per-category toggles for debug logging. Each flag enables or disables one class of log message. Unspecified flags default to `true` when `DebugConfig` is partially specified; `undefined` on the `debug` option defaults all flags to `false` except `errors`. + +## Extended by + +- [`DebugConfig`](DebugConfig.md) + +## Properties + +### agentLoop? + +```ts +optional agentLoop: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L50) + +Iteration markers and phase transitions in the chat agent loop. Chat-only. + +*** + +### config? + +```ts +optional config: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L54) + +Config transforms returned by middleware `onConfig` hooks. Chat-only. + +*** + +### errors? + +```ts +optional errors: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L58) + +Caught errors throughout the pipeline. Unlike other categories, defaults to `true` even when `debug` is unspecified. Explicitly set `errors: false` or `debug: false` to silence. + +*** + +### middleware? + +```ts +optional middleware: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L42) + +Inputs and outputs around each middleware hook invocation. Chat-only. + +*** + +### output? + +```ts +optional output: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L38) + +Chunks/results yielded to the consumer after all middleware. For streaming activities this fires per chunk; for non-streaming activities it fires once per result. + +*** + +### provider? + +```ts +optional provider: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L34) + +Raw chunks/frames received from a provider SDK (OpenAI, Anthropic, Gemini, Ollama, Grok, Groq, OpenRouter, fal, ElevenLabs). Emitted inside every streaming adapter's chunk loop. + +*** + +### request? + +```ts +optional request: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L62) + +Outgoing call metadata (provider, model, message/tool counts) emitted before each adapter SDK call. + +*** + +### tools? + +```ts +optional tools: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L46) + +Before/after tool-call execution in the chat agent loop. Chat-only. diff --git a/docs/reference/interfaces/DebugConfig.md b/docs/reference/interfaces/DebugConfig.md new file mode 100644 index 000000000..1bfd337ef --- /dev/null +++ b/docs/reference/interfaces/DebugConfig.md @@ -0,0 +1,154 @@ +--- +id: DebugConfig +title: DebugConfig +--- + +# Interface: DebugConfig + +Defined in: [packages/typescript/ai/src/logger/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L68) + +Granular debug configuration combining per-category toggles with an optional custom logger. Any unspecified category flag defaults to `true`. + +## Extends + +- [`DebugCategories`](DebugCategories.md) + +## Properties + +### agentLoop? + +```ts +optional agentLoop: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L50) + +Iteration markers and phase transitions in the chat agent loop. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`agentLoop`](DebugCategories.md#agentloop) + +*** + +### config? + +```ts +optional config: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L54) + +Config transforms returned by middleware `onConfig` hooks. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`config`](DebugCategories.md#config) + +*** + +### errors? + +```ts +optional errors: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L58) + +Caught errors throughout the pipeline. Unlike other categories, defaults to `true` even when `debug` is unspecified. Explicitly set `errors: false` or `debug: false` to silence. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`errors`](DebugCategories.md#errors) + +*** + +### logger? + +```ts +optional logger: Logger; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L72) + +Custom `Logger` implementation. When omitted, a default `ConsoleLogger` routes output to `console.debug`/`info`/`warn`/`error`. + +*** + +### middleware? + +```ts +optional middleware: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L42) + +Inputs and outputs around each middleware hook invocation. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`middleware`](DebugCategories.md#middleware) + +*** + +### output? + +```ts +optional output: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L38) + +Chunks/results yielded to the consumer after all middleware. For streaming activities this fires per chunk; for non-streaming activities it fires once per result. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`output`](DebugCategories.md#output) + +*** + +### provider? + +```ts +optional provider: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L34) + +Raw chunks/frames received from a provider SDK (OpenAI, Anthropic, Gemini, Ollama, Grok, Groq, OpenRouter, fal, ElevenLabs). Emitted inside every streaming adapter's chunk loop. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`provider`](DebugCategories.md#provider) + +*** + +### request? + +```ts +optional request: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L62) + +Outgoing call metadata (provider, model, message/tool counts) emitted before each adapter SDK call. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`request`](DebugCategories.md#request) + +*** + +### tools? + +```ts +optional tools: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L46) + +Before/after tool-call execution in the chat agent loop. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`tools`](DebugCategories.md#tools) diff --git a/docs/reference/interfaces/DefaultMessageMetadataByModality.md b/docs/reference/interfaces/DefaultMessageMetadataByModality.md index 508ed7020..d6e52317d 100644 --- a/docs/reference/interfaces/DefaultMessageMetadataByModality.md +++ b/docs/reference/interfaces/DefaultMessageMetadataByModality.md @@ -5,7 +5,7 @@ title: DefaultMessageMetadataByModality # Interface: DefaultMessageMetadataByModality -Defined in: [packages/typescript/ai/src/types.ts:1421](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1421) +Defined in: [packages/typescript/ai/src/types.ts:1457](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1457) Default metadata type for adapters that don't define custom metadata. Uses unknown for all modalities. @@ -18,7 +18,7 @@ Uses unknown for all modalities. audio: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:1424](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1424) +Defined in: [packages/typescript/ai/src/types.ts:1460](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1460) *** @@ -28,7 +28,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1424](https://github.com/TanSta document: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:1426](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1426) +Defined in: [packages/typescript/ai/src/types.ts:1462](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1462) *** @@ -38,7 +38,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1426](https://github.com/TanSta image: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:1423](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1423) +Defined in: [packages/typescript/ai/src/types.ts:1459](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1459) *** @@ -48,7 +48,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1423](https://github.com/TanSta text: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:1422](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1422) +Defined in: [packages/typescript/ai/src/types.ts:1458](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1458) *** @@ -58,4 +58,4 @@ Defined in: [packages/typescript/ai/src/types.ts:1422](https://github.com/TanSta video: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:1425](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1425) +Defined in: [packages/typescript/ai/src/types.ts:1461](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1461) diff --git a/docs/reference/interfaces/DocumentPart.md b/docs/reference/interfaces/DocumentPart.md index 8f452df63..040f058af 100644 --- a/docs/reference/interfaces/DocumentPart.md +++ b/docs/reference/interfaces/DocumentPart.md @@ -5,7 +5,7 @@ title: DocumentPart # Interface: DocumentPart\ -Defined in: [packages/typescript/ai/src/types.ts:225](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L225) +Defined in: [packages/typescript/ai/src/types.ts:226](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L226) Document content part for multimodal messages (e.g., PDFs). @@ -25,7 +25,7 @@ Provider-specific metadata type (e.g., Anthropic's media_type) optional metadata: TMetadata; ``` -Defined in: [packages/typescript/ai/src/types.ts:230](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L230) +Defined in: [packages/typescript/ai/src/types.ts:231](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L231) Provider-specific metadata (e.g., media_type for PDFs) @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., media_type for PDFs) source: ContentPartSource; ``` -Defined in: [packages/typescript/ai/src/types.ts:228](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L228) +Defined in: [packages/typescript/ai/src/types.ts:229](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L229) Source of the document content @@ -49,4 +49,4 @@ Source of the document content type: "document"; ``` -Defined in: [packages/typescript/ai/src/types.ts:226](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L226) +Defined in: [packages/typescript/ai/src/types.ts:227](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L227) diff --git a/docs/reference/interfaces/GeneratedImage.md b/docs/reference/interfaces/GeneratedImage.md index 71e2eaf66..e964d6dcf 100644 --- a/docs/reference/interfaces/GeneratedImage.md +++ b/docs/reference/interfaces/GeneratedImage.md @@ -5,7 +5,7 @@ title: GeneratedImage # Interface: GeneratedImage -Defined in: [packages/typescript/ai/src/types.ts:1206](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1206) +Defined in: [packages/typescript/ai/src/types.ts:1225](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1225) A single generated image @@ -17,7 +17,7 @@ A single generated image optional b64Json: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1208](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1208) +Defined in: [packages/typescript/ai/src/types.ts:1227](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1227) Base64-encoded image data @@ -29,7 +29,7 @@ Base64-encoded image data optional revisedPrompt: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1212) +Defined in: [packages/typescript/ai/src/types.ts:1231](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1231) Revised prompt used by the model (if applicable) @@ -41,6 +41,6 @@ Revised prompt used by the model (if applicable) optional url: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1210](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1210) +Defined in: [packages/typescript/ai/src/types.ts:1229](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1229) URL to the generated image (may be temporary) diff --git a/docs/reference/interfaces/ImageGenerationOptions.md b/docs/reference/interfaces/ImageGenerationOptions.md index 532cbfb90..b7dca106b 100644 --- a/docs/reference/interfaces/ImageGenerationOptions.md +++ b/docs/reference/interfaces/ImageGenerationOptions.md @@ -5,7 +5,7 @@ title: ImageGenerationOptions # Interface: ImageGenerationOptions\ -Defined in: [packages/typescript/ai/src/types.ts:1187](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1187) +Defined in: [packages/typescript/ai/src/types.ts:1201](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1201) Options for image generation. These are the common options supported across providers. @@ -22,13 +22,26 @@ These are the common options supported across providers. ## Properties +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1219](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1219) + +Internal logger threaded from the generateImage() entry point. Adapters must +call logger.request() before the SDK call and logger.errors() in catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1192](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1192) +Defined in: [packages/typescript/ai/src/types.ts:1206](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1206) The model to use for image generation @@ -40,7 +53,7 @@ The model to use for image generation optional modelOptions: TProviderOptions; ``` -Defined in: [packages/typescript/ai/src/types.ts:1200](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1200) +Defined in: [packages/typescript/ai/src/types.ts:1214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1214) Model-specific options for image generation @@ -52,7 +65,7 @@ Model-specific options for image generation optional numberOfImages: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1196](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1196) +Defined in: [packages/typescript/ai/src/types.ts:1210](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1210) Number of images to generate (default: 1) @@ -64,7 +77,7 @@ Number of images to generate (default: 1) prompt: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1194](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1194) +Defined in: [packages/typescript/ai/src/types.ts:1208](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1208) Text description of the desired image(s) @@ -76,6 +89,6 @@ Text description of the desired image(s) optional size: TSize; ``` -Defined in: [packages/typescript/ai/src/types.ts:1198](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1198) +Defined in: [packages/typescript/ai/src/types.ts:1212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1212) Image size in WIDTHxHEIGHT format (e.g., "1024x1024") diff --git a/docs/reference/interfaces/ImageGenerationResult.md b/docs/reference/interfaces/ImageGenerationResult.md index d40aefa1e..7b4ab34ba 100644 --- a/docs/reference/interfaces/ImageGenerationResult.md +++ b/docs/reference/interfaces/ImageGenerationResult.md @@ -5,7 +5,7 @@ title: ImageGenerationResult # Interface: ImageGenerationResult -Defined in: [packages/typescript/ai/src/types.ts:1218](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1218) +Defined in: [packages/typescript/ai/src/types.ts:1237](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1237) Result of image generation @@ -17,7 +17,7 @@ Result of image generation id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1220](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1220) +Defined in: [packages/typescript/ai/src/types.ts:1239](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1239) Unique identifier for the generation @@ -29,7 +29,7 @@ Unique identifier for the generation images: GeneratedImage[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:1224](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1224) +Defined in: [packages/typescript/ai/src/types.ts:1243](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1243) Array of generated images @@ -41,7 +41,7 @@ Array of generated images model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1222](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1222) +Defined in: [packages/typescript/ai/src/types.ts:1241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1241) Model used for generation @@ -53,7 +53,7 @@ Model used for generation optional usage: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:1226](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1226) +Defined in: [packages/typescript/ai/src/types.ts:1245](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1245) Token usage information (if available) diff --git a/docs/reference/interfaces/ImagePart.md b/docs/reference/interfaces/ImagePart.md index ddb7a6012..1cf7f928b 100644 --- a/docs/reference/interfaces/ImagePart.md +++ b/docs/reference/interfaces/ImagePart.md @@ -5,7 +5,7 @@ title: ImagePart # Interface: ImagePart\ -Defined in: [packages/typescript/ai/src/types.ts:189](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L189) +Defined in: [packages/typescript/ai/src/types.ts:190](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L190) Image content part for multimodal messages. @@ -25,7 +25,7 @@ Provider-specific metadata type (e.g., OpenAI's detail level) optional metadata: TMetadata; ``` -Defined in: [packages/typescript/ai/src/types.ts:194](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L194) +Defined in: [packages/typescript/ai/src/types.ts:195](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L195) Provider-specific metadata (e.g., OpenAI's detail: 'auto' | 'low' | 'high') @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., OpenAI's detail: 'auto' | 'low' | 'high') source: ContentPartSource; ``` -Defined in: [packages/typescript/ai/src/types.ts:192](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L192) +Defined in: [packages/typescript/ai/src/types.ts:193](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L193) Source of the image content @@ -49,4 +49,4 @@ Source of the image content type: "image"; ``` -Defined in: [packages/typescript/ai/src/types.ts:190](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L190) +Defined in: [packages/typescript/ai/src/types.ts:191](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L191) diff --git a/docs/reference/interfaces/JSONSchema.md b/docs/reference/interfaces/JSONSchema.md index 20d4df6c9..23072a667 100644 --- a/docs/reference/interfaces/JSONSchema.md +++ b/docs/reference/interfaces/JSONSchema.md @@ -5,7 +5,7 @@ title: JSONSchema # Interface: JSONSchema -Defined in: [packages/typescript/ai/src/types.ts:51](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L51) +Defined in: [packages/typescript/ai/src/types.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L52) JSON Schema type for defining tool input/output schemas as raw JSON Schema objects. This allows tools to be defined without schema libraries when you have JSON Schema definitions available. @@ -24,7 +24,7 @@ This allows tools to be defined without schema libraries when you have JSON Sche optional $defs: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L61) +Defined in: [packages/typescript/ai/src/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L62) *** @@ -34,7 +34,7 @@ Defined in: [packages/typescript/ai/src/types.ts:61](https://github.com/TanStack optional $ref: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:60](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L60) +Defined in: [packages/typescript/ai/src/types.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L61) *** @@ -44,7 +44,7 @@ Defined in: [packages/typescript/ai/src/types.ts:60](https://github.com/TanStack optional additionalItems: boolean | JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L82) +Defined in: [packages/typescript/ai/src/types.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L83) *** @@ -54,7 +54,7 @@ Defined in: [packages/typescript/ai/src/types.ts:82](https://github.com/TanStack optional additionalProperties: boolean | JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L81) +Defined in: [packages/typescript/ai/src/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L82) *** @@ -64,7 +64,7 @@ Defined in: [packages/typescript/ai/src/types.ts:81](https://github.com/TanStack optional allOf: JSONSchema[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L63) +Defined in: [packages/typescript/ai/src/types.ts:64](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L64) *** @@ -74,7 +74,7 @@ Defined in: [packages/typescript/ai/src/types.ts:63](https://github.com/TanStack optional anyOf: JSONSchema[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:64](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L64) +Defined in: [packages/typescript/ai/src/types.ts:65](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L65) *** @@ -84,7 +84,7 @@ Defined in: [packages/typescript/ai/src/types.ts:64](https://github.com/TanStack optional const: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L57) +Defined in: [packages/typescript/ai/src/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L58) *** @@ -94,7 +94,7 @@ Defined in: [packages/typescript/ai/src/types.ts:57](https://github.com/TanStack optional default: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L59) +Defined in: [packages/typescript/ai/src/types.ts:60](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L60) *** @@ -104,7 +104,7 @@ Defined in: [packages/typescript/ai/src/types.ts:59](https://github.com/TanStack optional definitions: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L62) +Defined in: [packages/typescript/ai/src/types.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L63) *** @@ -114,7 +114,7 @@ Defined in: [packages/typescript/ai/src/types.ts:62](https://github.com/TanStack optional description: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L58) +Defined in: [packages/typescript/ai/src/types.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L59) *** @@ -124,7 +124,7 @@ Defined in: [packages/typescript/ai/src/types.ts:58](https://github.com/TanStack optional else: JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:69](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L69) +Defined in: [packages/typescript/ai/src/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L70) *** @@ -134,7 +134,7 @@ Defined in: [packages/typescript/ai/src/types.ts:69](https://github.com/TanStack optional enum: unknown[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L56) +Defined in: [packages/typescript/ai/src/types.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L57) *** @@ -144,7 +144,7 @@ Defined in: [packages/typescript/ai/src/types.ts:56](https://github.com/TanStack optional examples: unknown[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:88](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L88) +Defined in: [packages/typescript/ai/src/types.ts:89](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L89) *** @@ -154,7 +154,7 @@ Defined in: [packages/typescript/ai/src/types.ts:88](https://github.com/TanStack optional exclusiveMaximum: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:73](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L73) +Defined in: [packages/typescript/ai/src/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L74) *** @@ -164,7 +164,7 @@ Defined in: [packages/typescript/ai/src/types.ts:73](https://github.com/TanStack optional exclusiveMinimum: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L72) +Defined in: [packages/typescript/ai/src/types.ts:73](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L73) *** @@ -174,7 +174,7 @@ Defined in: [packages/typescript/ai/src/types.ts:72](https://github.com/TanStack optional format: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L77) +Defined in: [packages/typescript/ai/src/types.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L78) *** @@ -184,7 +184,7 @@ Defined in: [packages/typescript/ai/src/types.ts:77](https://github.com/TanStack optional if: JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:67](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L67) +Defined in: [packages/typescript/ai/src/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L68) *** @@ -194,7 +194,7 @@ Defined in: [packages/typescript/ai/src/types.ts:67](https://github.com/TanStack optional items: JSONSchema | JSONSchema[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L54) +Defined in: [packages/typescript/ai/src/types.ts:55](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L55) *** @@ -204,7 +204,7 @@ Defined in: [packages/typescript/ai/src/types.ts:54](https://github.com/TanStack optional maximum: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L71) +Defined in: [packages/typescript/ai/src/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L72) *** @@ -214,7 +214,7 @@ Defined in: [packages/typescript/ai/src/types.ts:71](https://github.com/TanStack optional maxItems: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L79) +Defined in: [packages/typescript/ai/src/types.ts:80](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L80) *** @@ -224,7 +224,7 @@ Defined in: [packages/typescript/ai/src/types.ts:79](https://github.com/TanStack optional maxLength: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L75) +Defined in: [packages/typescript/ai/src/types.ts:76](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L76) *** @@ -234,7 +234,7 @@ Defined in: [packages/typescript/ai/src/types.ts:75](https://github.com/TanStack optional maxProperties: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L86) +Defined in: [packages/typescript/ai/src/types.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L87) *** @@ -244,7 +244,7 @@ Defined in: [packages/typescript/ai/src/types.ts:86](https://github.com/TanStack optional minimum: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L70) +Defined in: [packages/typescript/ai/src/types.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L71) *** @@ -254,7 +254,7 @@ Defined in: [packages/typescript/ai/src/types.ts:70](https://github.com/TanStack optional minItems: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L78) +Defined in: [packages/typescript/ai/src/types.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L79) *** @@ -264,7 +264,7 @@ Defined in: [packages/typescript/ai/src/types.ts:78](https://github.com/TanStack optional minLength: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L74) +Defined in: [packages/typescript/ai/src/types.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L75) *** @@ -274,7 +274,7 @@ Defined in: [packages/typescript/ai/src/types.ts:74](https://github.com/TanStack optional minProperties: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L85) +Defined in: [packages/typescript/ai/src/types.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L86) *** @@ -284,7 +284,7 @@ Defined in: [packages/typescript/ai/src/types.ts:85](https://github.com/TanStack optional not: JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L66) +Defined in: [packages/typescript/ai/src/types.ts:67](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L67) *** @@ -294,7 +294,7 @@ Defined in: [packages/typescript/ai/src/types.ts:66](https://github.com/TanStack optional oneOf: JSONSchema[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:65](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L65) +Defined in: [packages/typescript/ai/src/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L66) *** @@ -304,7 +304,7 @@ Defined in: [packages/typescript/ai/src/types.ts:65](https://github.com/TanStack optional pattern: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:76](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L76) +Defined in: [packages/typescript/ai/src/types.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L77) *** @@ -314,7 +314,7 @@ Defined in: [packages/typescript/ai/src/types.ts:76](https://github.com/TanStack optional patternProperties: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L83) +Defined in: [packages/typescript/ai/src/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L84) *** @@ -324,7 +324,7 @@ Defined in: [packages/typescript/ai/src/types.ts:83](https://github.com/TanStack optional properties: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:53](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L53) +Defined in: [packages/typescript/ai/src/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L54) *** @@ -334,7 +334,7 @@ Defined in: [packages/typescript/ai/src/types.ts:53](https://github.com/TanStack optional propertyNames: JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L84) +Defined in: [packages/typescript/ai/src/types.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L85) *** @@ -344,7 +344,7 @@ Defined in: [packages/typescript/ai/src/types.ts:84](https://github.com/TanStack optional required: string[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:55](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L55) +Defined in: [packages/typescript/ai/src/types.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L56) *** @@ -354,7 +354,7 @@ Defined in: [packages/typescript/ai/src/types.ts:55](https://github.com/TanStack optional then: JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L68) +Defined in: [packages/typescript/ai/src/types.ts:69](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L69) *** @@ -364,7 +364,7 @@ Defined in: [packages/typescript/ai/src/types.ts:68](https://github.com/TanStack optional title: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L87) +Defined in: [packages/typescript/ai/src/types.ts:88](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L88) *** @@ -374,7 +374,7 @@ Defined in: [packages/typescript/ai/src/types.ts:87](https://github.com/TanStack optional type: string | string[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L52) +Defined in: [packages/typescript/ai/src/types.ts:53](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L53) *** @@ -384,4 +384,4 @@ Defined in: [packages/typescript/ai/src/types.ts:52](https://github.com/TanStack optional uniqueItems: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:80](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L80) +Defined in: [packages/typescript/ai/src/types.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L81) diff --git a/docs/reference/interfaces/Logger.md b/docs/reference/interfaces/Logger.md new file mode 100644 index 000000000..05463eeba --- /dev/null +++ b/docs/reference/interfaces/Logger.md @@ -0,0 +1,122 @@ +--- +id: Logger +title: Logger +--- + +# Interface: Logger + +Defined in: [packages/typescript/ai/src/logger/types.ts:4](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L4) + +Pluggable logger interface consumed by every `@tanstack/ai` activity when `debug` is enabled. Supply a custom implementation via `debug: { logger }` on `chat()`, `summarize()`, `generateImage()`, etc. The four methods correspond to log levels: use `debug` for chunk-level diagnostic output, `info`/`warn` for notable events, `error` for caught exceptions. + +## Properties + +### debug() + +```ts +debug: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:9](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L9) + +Called for chunk-level diagnostic output (raw provider chunks, per-chunk output, agent-loop iteration markers). + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` + +*** + +### error() + +```ts +error: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L24) + +Called for caught exceptions throughout the pipeline. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` + +*** + +### info() + +```ts +info: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L14) + +Called for notable informational events (outgoing requests, tool invocations, middleware transitions). + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` + +*** + +### warn() + +```ts +warn: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:19](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L19) + +Called for notable warnings that don't halt execution (deprecations, recoverable anomalies). + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` diff --git a/docs/reference/interfaces/MessagesSnapshotEvent.md b/docs/reference/interfaces/MessagesSnapshotEvent.md index a97713b08..7a41d6d2c 100644 --- a/docs/reference/interfaces/MessagesSnapshotEvent.md +++ b/docs/reference/interfaces/MessagesSnapshotEvent.md @@ -5,7 +5,7 @@ title: MessagesSnapshotEvent # Interface: MessagesSnapshotEvent -Defined in: [packages/typescript/ai/src/types.ts:995](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L995) +Defined in: [packages/typescript/ai/src/types.ts:1004](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1004) Emitted to provide a snapshot of all messages in a conversation. @@ -36,6 +36,6 @@ Use converters to transform to/from TanStack UIMessage format. optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:997](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L997) +Defined in: [packages/typescript/ai/src/types.ts:1006](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1006) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ModelMessage.md b/docs/reference/interfaces/ModelMessage.md index a1842db18..f1a8187a6 100644 --- a/docs/reference/interfaces/ModelMessage.md +++ b/docs/reference/interfaces/ModelMessage.md @@ -5,7 +5,7 @@ title: ModelMessage # Interface: ModelMessage\ -Defined in: [packages/typescript/ai/src/types.ts:288](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L288) +Defined in: [packages/typescript/ai/src/types.ts:289](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L289) ## Type Parameters @@ -21,7 +21,7 @@ Defined in: [packages/typescript/ai/src/types.ts:288](https://github.com/TanStac content: TContent; ``` -Defined in: [packages/typescript/ai/src/types.ts:295](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L295) +Defined in: [packages/typescript/ai/src/types.ts:296](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L296) *** @@ -31,7 +31,7 @@ Defined in: [packages/typescript/ai/src/types.ts:295](https://github.com/TanStac optional name: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:296](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L296) +Defined in: [packages/typescript/ai/src/types.ts:297](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L297) *** @@ -41,7 +41,7 @@ Defined in: [packages/typescript/ai/src/types.ts:296](https://github.com/TanStac role: "user" | "assistant" | "tool"; ``` -Defined in: [packages/typescript/ai/src/types.ts:294](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L294) +Defined in: [packages/typescript/ai/src/types.ts:295](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L295) *** @@ -51,7 +51,7 @@ Defined in: [packages/typescript/ai/src/types.ts:294](https://github.com/TanStac optional toolCallId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:298](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L298) +Defined in: [packages/typescript/ai/src/types.ts:299](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L299) *** @@ -61,4 +61,4 @@ Defined in: [packages/typescript/ai/src/types.ts:298](https://github.com/TanStac optional toolCalls: ToolCall[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:297](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L297) +Defined in: [packages/typescript/ai/src/types.ts:298](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L298) diff --git a/docs/reference/interfaces/ProviderTool.md b/docs/reference/interfaces/ProviderTool.md index be6015ffc..19a6efc20 100644 --- a/docs/reference/interfaces/ProviderTool.md +++ b/docs/reference/interfaces/ProviderTool.md @@ -65,7 +65,7 @@ Defined in: [packages/typescript/ai/src/tools/provider-tool.ts:24](https://githu description: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:439](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L439) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -90,7 +90,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [packages/typescript/ai/src/types.ts:519](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L519) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -138,7 +138,7 @@ execute: async (args) => { optional inputSchema: SchemaInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:479](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L479) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -196,7 +196,7 @@ type({ optional lazy: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:525](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L525) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -212,7 +212,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:528](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L528) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -228,7 +228,7 @@ Additional metadata for adapters or custom extensions name: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:429](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L429) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -253,7 +253,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:522](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L522) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -269,7 +269,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: SchemaInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:500](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L500) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/RealtimeSessionConfig.md b/docs/reference/interfaces/RealtimeSessionConfig.md index faa111957..a362658ed 100644 --- a/docs/reference/interfaces/RealtimeSessionConfig.md +++ b/docs/reference/interfaces/RealtimeSessionConfig.md @@ -74,7 +74,7 @@ Provider-specific options ### semanticEagerness? ```ts -optional semanticEagerness: "low" | "high" | "medium"; +optional semanticEagerness: "low" | "medium" | "high"; ``` Defined in: [packages/typescript/ai/src/realtime/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L50) diff --git a/docs/reference/interfaces/ReasoningEncryptedValueEvent.md b/docs/reference/interfaces/ReasoningEncryptedValueEvent.md index 2b6742271..85e72381b 100644 --- a/docs/reference/interfaces/ReasoningEncryptedValueEvent.md +++ b/docs/reference/interfaces/ReasoningEncryptedValueEvent.md @@ -5,7 +5,7 @@ title: ReasoningEncryptedValueEvent # Interface: ReasoningEncryptedValueEvent -Defined in: [packages/typescript/ai/src/types.ts:1103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1103) +Defined in: [packages/typescript/ai/src/types.ts:1112](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1112) Emitted for encrypted reasoning values. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1105](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1105) +Defined in: [packages/typescript/ai/src/types.ts:1114](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1114) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningEndEvent.md b/docs/reference/interfaces/ReasoningEndEvent.md index dba9ca353..afaa42e4b 100644 --- a/docs/reference/interfaces/ReasoningEndEvent.md +++ b/docs/reference/interfaces/ReasoningEndEvent.md @@ -5,7 +5,7 @@ title: ReasoningEndEvent # Interface: ReasoningEndEvent -Defined in: [packages/typescript/ai/src/types.ts:1092](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1092) +Defined in: [packages/typescript/ai/src/types.ts:1101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1101) Emitted when reasoning ends for a message. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1094](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1094) +Defined in: [packages/typescript/ai/src/types.ts:1103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1103) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningMessageContentEvent.md b/docs/reference/interfaces/ReasoningMessageContentEvent.md index a4fa35d31..7a5b9186d 100644 --- a/docs/reference/interfaces/ReasoningMessageContentEvent.md +++ b/docs/reference/interfaces/ReasoningMessageContentEvent.md @@ -5,7 +5,7 @@ title: ReasoningMessageContentEvent # Interface: ReasoningMessageContentEvent -Defined in: [packages/typescript/ai/src/types.ts:1070](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1070) +Defined in: [packages/typescript/ai/src/types.ts:1079](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1079) Emitted when reasoning message content is generated. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1072](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1072) +Defined in: [packages/typescript/ai/src/types.ts:1081](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1081) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningMessageEndEvent.md b/docs/reference/interfaces/ReasoningMessageEndEvent.md index f01ce57d4..c08bd1637 100644 --- a/docs/reference/interfaces/ReasoningMessageEndEvent.md +++ b/docs/reference/interfaces/ReasoningMessageEndEvent.md @@ -5,7 +5,7 @@ title: ReasoningMessageEndEvent # Interface: ReasoningMessageEndEvent -Defined in: [packages/typescript/ai/src/types.ts:1081](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1081) +Defined in: [packages/typescript/ai/src/types.ts:1090](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1090) Emitted when a reasoning message ends. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1083](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1083) +Defined in: [packages/typescript/ai/src/types.ts:1092](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1092) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningMessageStartEvent.md b/docs/reference/interfaces/ReasoningMessageStartEvent.md index 94e730e08..277d1377f 100644 --- a/docs/reference/interfaces/ReasoningMessageStartEvent.md +++ b/docs/reference/interfaces/ReasoningMessageStartEvent.md @@ -5,7 +5,7 @@ title: ReasoningMessageStartEvent # Interface: ReasoningMessageStartEvent -Defined in: [packages/typescript/ai/src/types.ts:1059](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1059) +Defined in: [packages/typescript/ai/src/types.ts:1068](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1068) Emitted when a reasoning message starts. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1061](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1061) +Defined in: [packages/typescript/ai/src/types.ts:1070](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1070) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningStartEvent.md b/docs/reference/interfaces/ReasoningStartEvent.md index 1c6d5b90d..96805bdd6 100644 --- a/docs/reference/interfaces/ReasoningStartEvent.md +++ b/docs/reference/interfaces/ReasoningStartEvent.md @@ -5,7 +5,7 @@ title: ReasoningStartEvent # Interface: ReasoningStartEvent -Defined in: [packages/typescript/ai/src/types.ts:1048](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1048) +Defined in: [packages/typescript/ai/src/types.ts:1057](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1057) Emitted when reasoning starts for a message. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1050](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1050) +Defined in: [packages/typescript/ai/src/types.ts:1059](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1059) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ResponseFormat.md b/docs/reference/interfaces/ResponseFormat.md index a2806c983..064c60c0f 100644 --- a/docs/reference/interfaces/ResponseFormat.md +++ b/docs/reference/interfaces/ResponseFormat.md @@ -5,7 +5,7 @@ title: ResponseFormat # Interface: ResponseFormat\ -Defined in: [packages/typescript/ai/src/types.ts:546](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L546) +Defined in: [packages/typescript/ai/src/types.ts:547](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L547) Structured output format specification. @@ -33,7 +33,7 @@ TypeScript type of the expected data structure (for type safety) optional __data: TData; ``` -Defined in: [packages/typescript/ai/src/types.ts:624](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L624) +Defined in: [packages/typescript/ai/src/types.ts:625](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L625) **`Internal`** @@ -50,7 +50,7 @@ Allows the SDK to know what type to expect when parsing the response. optional json_schema: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:563](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L563) +Defined in: [packages/typescript/ai/src/types.ts:564](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L564) JSON schema specification (required when type is "json_schema"). @@ -139,7 +139,7 @@ https://platform.openai.com/docs/guides/structured-outputs#strict-mode type: "json_object" | "json_schema"; ``` -Defined in: [packages/typescript/ai/src/types.ts:555](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L555) +Defined in: [packages/typescript/ai/src/types.ts:556](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L556) Type of structured output. diff --git a/docs/reference/interfaces/RunErrorEvent.md b/docs/reference/interfaces/RunErrorEvent.md index eb9f5f1f7..54d136c77 100644 --- a/docs/reference/interfaces/RunErrorEvent.md +++ b/docs/reference/interfaces/RunErrorEvent.md @@ -5,7 +5,7 @@ title: RunErrorEvent # Interface: RunErrorEvent -Defined in: [packages/typescript/ai/src/types.ts:831](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L831) +Defined in: [packages/typescript/ai/src/types.ts:840](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L840) Emitted when an error occurs during a run. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `error?` (deprecated nested form) optional error: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:838](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L838) +Defined in: [packages/typescript/ai/src/types.ts:847](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L847) #### ~~code?~~ @@ -57,6 +57,6 @@ Kept for backward compatibility. optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:833](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L833) +Defined in: [packages/typescript/ai/src/types.ts:842](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L842) Model identifier for multi-model support diff --git a/docs/reference/interfaces/RunFinishedEvent.md b/docs/reference/interfaces/RunFinishedEvent.md index 8fd6bc355..be612fbeb 100644 --- a/docs/reference/interfaces/RunFinishedEvent.md +++ b/docs/reference/interfaces/RunFinishedEvent.md @@ -5,7 +5,7 @@ title: RunFinishedEvent # Interface: RunFinishedEvent -Defined in: [packages/typescript/ai/src/types.ts:812](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L812) +Defined in: [packages/typescript/ai/src/types.ts:821](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L821) Emitted when a run completes successfully. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `finishReason?`, `usage?` optional finishReason: "length" | "stop" | "content_filter" | "tool_calls" | null; ``` -Defined in: [packages/typescript/ai/src/types.ts:816](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L816) +Defined in: [packages/typescript/ai/src/types.ts:825](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L825) Why the generation stopped @@ -42,7 +42,7 @@ Why the generation stopped optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:814](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L814) +Defined in: [packages/typescript/ai/src/types.ts:823](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L823) Model identifier for multi-model support @@ -54,7 +54,7 @@ Model identifier for multi-model support optional usage: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:818](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L818) +Defined in: [packages/typescript/ai/src/types.ts:827](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L827) Token usage statistics diff --git a/docs/reference/interfaces/RunStartedEvent.md b/docs/reference/interfaces/RunStartedEvent.md index 68de5024c..d4f3289ca 100644 --- a/docs/reference/interfaces/RunStartedEvent.md +++ b/docs/reference/interfaces/RunStartedEvent.md @@ -5,7 +5,7 @@ title: RunStartedEvent # Interface: RunStartedEvent -Defined in: [packages/typescript/ai/src/types.ts:801](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L801) +Defined in: [packages/typescript/ai/src/types.ts:810](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L810) Emitted when a run starts. This is the first event in any streaming response. @@ -31,6 +31,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:803](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L803) +Defined in: [packages/typescript/ai/src/types.ts:812](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L812) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ServerTool.md b/docs/reference/interfaces/ServerTool.md index b9febb14e..d3140ed71 100644 --- a/docs/reference/interfaces/ServerTool.md +++ b/docs/reference/interfaces/ServerTool.md @@ -45,7 +45,7 @@ Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts description: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:439](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L439) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -70,7 +70,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [packages/typescript/ai/src/types.ts:519](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L519) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -118,7 +118,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:479](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L479) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -176,7 +176,7 @@ type({ optional lazy: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:525](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L525) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -192,7 +192,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:528](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L528) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -208,7 +208,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [packages/typescript/ai/src/types.ts:429](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L429) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -233,7 +233,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:522](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L522) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -249,7 +249,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [packages/typescript/ai/src/types.ts:500](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L500) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/StateDeltaEvent.md b/docs/reference/interfaces/StateDeltaEvent.md index eb563726b..0692ca789 100644 --- a/docs/reference/interfaces/StateDeltaEvent.md +++ b/docs/reference/interfaces/StateDeltaEvent.md @@ -5,7 +5,7 @@ title: StateDeltaEvent # Interface: StateDeltaEvent -Defined in: [packages/typescript/ai/src/types.ts:1022](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1022) +Defined in: [packages/typescript/ai/src/types.ts:1031](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1031) Emitted to provide an incremental state update. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1024](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1024) +Defined in: [packages/typescript/ai/src/types.ts:1033](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1033) Model identifier for multi-model support diff --git a/docs/reference/interfaces/StateSnapshotEvent.md b/docs/reference/interfaces/StateSnapshotEvent.md index 2e63e7238..c350f72f8 100644 --- a/docs/reference/interfaces/StateSnapshotEvent.md +++ b/docs/reference/interfaces/StateSnapshotEvent.md @@ -5,7 +5,7 @@ title: StateSnapshotEvent # Interface: StateSnapshotEvent -Defined in: [packages/typescript/ai/src/types.ts:1006](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1006) +Defined in: [packages/typescript/ai/src/types.ts:1015](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1015) Emitted to provide a full state snapshot. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `state?` (deprecated alias for snapshot) optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1008](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1008) +Defined in: [packages/typescript/ai/src/types.ts:1017](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1017) Model identifier for multi-model support @@ -42,7 +42,7 @@ Model identifier for multi-model support optional state: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:1013](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1013) +Defined in: [packages/typescript/ai/src/types.ts:1022](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1022) #### Deprecated diff --git a/docs/reference/interfaces/StepFinishedEvent.md b/docs/reference/interfaces/StepFinishedEvent.md index b2e6e1592..d62b12367 100644 --- a/docs/reference/interfaces/StepFinishedEvent.md +++ b/docs/reference/interfaces/StepFinishedEvent.md @@ -5,7 +5,7 @@ title: StepFinishedEvent # Interface: StepFinishedEvent -Defined in: [packages/typescript/ai/src/types.ts:969](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L969) +Defined in: [packages/typescript/ai/src/types.ts:978](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L978) Emitted when a thinking/reasoning step finishes. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `stepId?` (deprecated alias), `delta?`, `content?` optional content: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:980](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L980) +Defined in: [packages/typescript/ai/src/types.ts:989](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L989) Full accumulated thinking content (TanStack AI internal) @@ -42,7 +42,7 @@ Full accumulated thinking content (TanStack AI internal) optional delta: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:978](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L978) +Defined in: [packages/typescript/ai/src/types.ts:987](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L987) Incremental thinking content (TanStack AI internal) @@ -54,7 +54,7 @@ Incremental thinking content (TanStack AI internal) optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:971](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L971) +Defined in: [packages/typescript/ai/src/types.ts:980](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L980) Model identifier for multi-model support @@ -66,7 +66,7 @@ Model identifier for multi-model support optional stepId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:976](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L976) +Defined in: [packages/typescript/ai/src/types.ts:985](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L985) #### Deprecated diff --git a/docs/reference/interfaces/StepStartedEvent.md b/docs/reference/interfaces/StepStartedEvent.md index 6c2b202c1..8eda593c1 100644 --- a/docs/reference/interfaces/StepStartedEvent.md +++ b/docs/reference/interfaces/StepStartedEvent.md @@ -5,7 +5,7 @@ title: StepStartedEvent # Interface: StepStartedEvent -Defined in: [packages/typescript/ai/src/types.ts:951](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L951) +Defined in: [packages/typescript/ai/src/types.ts:960](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L960) Emitted when a thinking/reasoning step starts. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `stepId?` (deprecated alias), `stepType?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:953](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L953) +Defined in: [packages/typescript/ai/src/types.ts:962](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L962) Model identifier for multi-model support @@ -42,7 +42,7 @@ Model identifier for multi-model support optional stepId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:958](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L958) +Defined in: [packages/typescript/ai/src/types.ts:967](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L967) #### Deprecated @@ -57,6 +57,6 @@ Kept for backward compatibility. optional stepType: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:960](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L960) +Defined in: [packages/typescript/ai/src/types.ts:969](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L969) Type of step (e.g., 'thinking', 'planning') diff --git a/docs/reference/interfaces/SummarizationOptions.md b/docs/reference/interfaces/SummarizationOptions.md index 505f92adb..7851fefba 100644 --- a/docs/reference/interfaces/SummarizationOptions.md +++ b/docs/reference/interfaces/SummarizationOptions.md @@ -5,7 +5,7 @@ title: SummarizationOptions # Interface: SummarizationOptions -Defined in: [packages/typescript/ai/src/types.ts:1160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1160) +Defined in: [packages/typescript/ai/src/types.ts:1169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1169) ## Properties @@ -15,7 +15,20 @@ Defined in: [packages/typescript/ai/src/types.ts:1160](https://github.com/TanSta optional focus: string[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:1165](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1165) +Defined in: [packages/typescript/ai/src/types.ts:1174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1174) + +*** + +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1179](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1179) + +Internal logger threaded from the summarize() entry point. Adapters must +call logger.request() before the SDK call and logger.errors() in catch blocks. *** @@ -25,7 +38,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1165](https://github.com/TanSta optional maxLength: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1163](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1163) +Defined in: [packages/typescript/ai/src/types.ts:1172](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1172) *** @@ -35,7 +48,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1163](https://github.com/TanSta model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1161](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1161) +Defined in: [packages/typescript/ai/src/types.ts:1170](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1170) *** @@ -45,7 +58,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1161](https://github.com/TanSta optional style: "bullet-points" | "paragraph" | "concise"; ``` -Defined in: [packages/typescript/ai/src/types.ts:1164](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1164) +Defined in: [packages/typescript/ai/src/types.ts:1173](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1173) *** @@ -55,4 +68,4 @@ Defined in: [packages/typescript/ai/src/types.ts:1164](https://github.com/TanSta text: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1162) +Defined in: [packages/typescript/ai/src/types.ts:1171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1171) diff --git a/docs/reference/interfaces/SummarizationResult.md b/docs/reference/interfaces/SummarizationResult.md index 21380920f..87f5d7aef 100644 --- a/docs/reference/interfaces/SummarizationResult.md +++ b/docs/reference/interfaces/SummarizationResult.md @@ -5,7 +5,7 @@ title: SummarizationResult # Interface: SummarizationResult -Defined in: [packages/typescript/ai/src/types.ts:1168](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1168) +Defined in: [packages/typescript/ai/src/types.ts:1182](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1182) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1168](https://github.com/TanSta id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1169) +Defined in: [packages/typescript/ai/src/types.ts:1183](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1183) *** @@ -25,7 +25,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1169](https://github.com/TanSta model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1170](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1170) +Defined in: [packages/typescript/ai/src/types.ts:1184](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1184) *** @@ -35,7 +35,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1170](https://github.com/TanSta summary: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1171) +Defined in: [packages/typescript/ai/src/types.ts:1185](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1185) *** @@ -45,7 +45,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1171](https://github.com/TanSta usage: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:1172](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1172) +Defined in: [packages/typescript/ai/src/types.ts:1186](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1186) #### completionTokens diff --git a/docs/reference/interfaces/TTSOptions.md b/docs/reference/interfaces/TTSOptions.md index 0585150f1..d5983f2b8 100644 --- a/docs/reference/interfaces/TTSOptions.md +++ b/docs/reference/interfaces/TTSOptions.md @@ -5,7 +5,7 @@ title: TTSOptions # Interface: TTSOptions\ -Defined in: [packages/typescript/ai/src/types.ts:1309](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1309) +Defined in: [packages/typescript/ai/src/types.ts:1333](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1333) Options for text-to-speech generation. These are the common options supported across providers. @@ -24,19 +24,33 @@ These are the common options supported across providers. optional format: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm"; ``` -Defined in: [packages/typescript/ai/src/types.ts:1317](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1317) +Defined in: [packages/typescript/ai/src/types.ts:1341](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1341) The output audio format *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1351](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1351) + +Internal logger threaded from the generateSpeech() entry point. Adapters +must call logger.request() before the SDK call and logger.errors() in +catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1311](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1311) +Defined in: [packages/typescript/ai/src/types.ts:1335](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1335) The model to use for TTS generation @@ -48,7 +62,7 @@ The model to use for TTS generation optional modelOptions: TProviderOptions; ``` -Defined in: [packages/typescript/ai/src/types.ts:1321](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1321) +Defined in: [packages/typescript/ai/src/types.ts:1345](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1345) Model-specific options for TTS generation @@ -60,7 +74,7 @@ Model-specific options for TTS generation optional speed: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1319](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1319) +Defined in: [packages/typescript/ai/src/types.ts:1343](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1343) The speed of the generated audio (0.25 to 4.0) @@ -72,7 +86,7 @@ The speed of the generated audio (0.25 to 4.0) text: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1313) +Defined in: [packages/typescript/ai/src/types.ts:1337](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1337) The text to convert to speech @@ -84,6 +98,6 @@ The text to convert to speech optional voice: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1315](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1315) +Defined in: [packages/typescript/ai/src/types.ts:1339](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1339) The voice to use for generation diff --git a/docs/reference/interfaces/TTSResult.md b/docs/reference/interfaces/TTSResult.md index 09eecd418..26e0c55e9 100644 --- a/docs/reference/interfaces/TTSResult.md +++ b/docs/reference/interfaces/TTSResult.md @@ -5,7 +5,7 @@ title: TTSResult # Interface: TTSResult -Defined in: [packages/typescript/ai/src/types.ts:1327](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1327) +Defined in: [packages/typescript/ai/src/types.ts:1357](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1357) Result of text-to-speech generation. @@ -17,7 +17,7 @@ Result of text-to-speech generation. audio: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1333](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1333) +Defined in: [packages/typescript/ai/src/types.ts:1363](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1363) Base64-encoded audio data @@ -29,7 +29,7 @@ Base64-encoded audio data optional contentType: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1339](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1339) +Defined in: [packages/typescript/ai/src/types.ts:1369](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1369) Content type of the audio (e.g., 'audio/mp3') @@ -41,7 +41,7 @@ Content type of the audio (e.g., 'audio/mp3') optional duration: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1337](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1337) +Defined in: [packages/typescript/ai/src/types.ts:1367](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1367) Duration of the audio in seconds, if available @@ -53,7 +53,7 @@ Duration of the audio in seconds, if available format: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1335](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1335) +Defined in: [packages/typescript/ai/src/types.ts:1365](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1365) Audio format of the generated audio @@ -65,7 +65,7 @@ Audio format of the generated audio id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1329](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1329) +Defined in: [packages/typescript/ai/src/types.ts:1359](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1359) Unique identifier for the generation @@ -77,6 +77,6 @@ Unique identifier for the generation model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1331) +Defined in: [packages/typescript/ai/src/types.ts:1361](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1361) Model used for generation diff --git a/docs/reference/interfaces/TextAdapter.md b/docs/reference/interfaces/TextAdapter.md index 9146c032a..507a26e4b 100644 --- a/docs/reference/interfaces/TextAdapter.md +++ b/docs/reference/interfaces/TextAdapter.md @@ -5,7 +5,7 @@ title: TextAdapter # Interface: TextAdapter\ -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:53](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L53) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L58) Text adapter interface with pre-resolved generics. @@ -49,7 +49,7 @@ Generic parameters: ~types: object; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L70) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L75) **`Internal`** @@ -87,7 +87,7 @@ toolCapabilities: TToolCapabilities; chatStream: (options) => AsyncIterable; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:80](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L80) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L85) Stream text completions from the model @@ -109,7 +109,7 @@ Stream text completions from the model readonly kind: "text"; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L61) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L66) Discriminator for adapter kind @@ -121,7 +121,7 @@ Discriminator for adapter kind readonly model: TModel; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:65](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L65) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L70) The model this adapter is configured for @@ -133,7 +133,7 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L63) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L68) Provider name identifier (e.g., 'openai', 'anthropic') @@ -145,7 +145,7 @@ Provider name identifier (e.g., 'openai', 'anthropic') structuredOutput: (options) => Promise>; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:92](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L92) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:97](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L97) Generate structured output using the provider's native structured output API. This method uses stream: false and sends the JSON schema to the provider diff --git a/docs/reference/interfaces/TextCompletionChunk.md b/docs/reference/interfaces/TextCompletionChunk.md index 94dee8567..d6c788d9b 100644 --- a/docs/reference/interfaces/TextCompletionChunk.md +++ b/docs/reference/interfaces/TextCompletionChunk.md @@ -5,7 +5,7 @@ title: TextCompletionChunk # Interface: TextCompletionChunk -Defined in: [packages/typescript/ai/src/types.ts:1147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1147) +Defined in: [packages/typescript/ai/src/types.ts:1156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1156) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1147](https://github.com/TanSta content: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1150](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1150) +Defined in: [packages/typescript/ai/src/types.ts:1159](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1159) *** @@ -25,7 +25,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1150](https://github.com/TanSta optional finishReason: "length" | "stop" | "content_filter" | null; ``` -Defined in: [packages/typescript/ai/src/types.ts:1152](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1152) +Defined in: [packages/typescript/ai/src/types.ts:1161](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1161) *** @@ -35,7 +35,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1152](https://github.com/TanSta id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1148](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1148) +Defined in: [packages/typescript/ai/src/types.ts:1157](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1157) *** @@ -45,7 +45,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1148](https://github.com/TanSta model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1149](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1149) +Defined in: [packages/typescript/ai/src/types.ts:1158](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1158) *** @@ -55,7 +55,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1149](https://github.com/TanSta optional role: "assistant"; ``` -Defined in: [packages/typescript/ai/src/types.ts:1151](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1151) +Defined in: [packages/typescript/ai/src/types.ts:1160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1160) *** @@ -65,7 +65,7 @@ Defined in: [packages/typescript/ai/src/types.ts:1151](https://github.com/TanSta optional usage: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:1153](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1153) +Defined in: [packages/typescript/ai/src/types.ts:1162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1162) #### completionTokens diff --git a/docs/reference/interfaces/TextMessageContentEvent.md b/docs/reference/interfaces/TextMessageContentEvent.md index cfd78a93f..5e254bfca 100644 --- a/docs/reference/interfaces/TextMessageContentEvent.md +++ b/docs/reference/interfaces/TextMessageContentEvent.md @@ -5,7 +5,7 @@ title: TextMessageContentEvent # Interface: TextMessageContentEvent -Defined in: [packages/typescript/ai/src/types.ts:861](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L861) +Defined in: [packages/typescript/ai/src/types.ts:870](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L870) Emitted when text content is generated (streaming tokens). @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `content?` (accumulated) optional content: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:865](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L865) +Defined in: [packages/typescript/ai/src/types.ts:874](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L874) Full accumulated content so far (TanStack AI internal, for debugging) @@ -42,6 +42,6 @@ Full accumulated content so far (TanStack AI internal, for debugging) optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:863](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L863) +Defined in: [packages/typescript/ai/src/types.ts:872](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L872) Model identifier for multi-model support diff --git a/docs/reference/interfaces/TextMessageEndEvent.md b/docs/reference/interfaces/TextMessageEndEvent.md index 1a276b962..1cfbed6dc 100644 --- a/docs/reference/interfaces/TextMessageEndEvent.md +++ b/docs/reference/interfaces/TextMessageEndEvent.md @@ -5,7 +5,7 @@ title: TextMessageEndEvent # Interface: TextMessageEndEvent -Defined in: [packages/typescript/ai/src/types.ts:874](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L874) +Defined in: [packages/typescript/ai/src/types.ts:883](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L883) Emitted when a text message completes. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:876](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L876) +Defined in: [packages/typescript/ai/src/types.ts:885](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L885) Model identifier for multi-model support diff --git a/docs/reference/interfaces/TextMessageStartEvent.md b/docs/reference/interfaces/TextMessageStartEvent.md index e8f4dd5fa..22fb7998e 100644 --- a/docs/reference/interfaces/TextMessageStartEvent.md +++ b/docs/reference/interfaces/TextMessageStartEvent.md @@ -5,7 +5,7 @@ title: TextMessageStartEvent # Interface: TextMessageStartEvent -Defined in: [packages/typescript/ai/src/types.ts:850](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L850) +Defined in: [packages/typescript/ai/src/types.ts:859](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L859) Emitted when a text message starts. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:852](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L852) +Defined in: [packages/typescript/ai/src/types.ts:861](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L861) Model identifier for multi-model support diff --git a/docs/reference/interfaces/TextOptions.md b/docs/reference/interfaces/TextOptions.md index a8984e59a..803bdd8f0 100644 --- a/docs/reference/interfaces/TextOptions.md +++ b/docs/reference/interfaces/TextOptions.md @@ -5,7 +5,7 @@ title: TextOptions # Interface: TextOptions\ -Defined in: [packages/typescript/ai/src/types.ts:656](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L656) +Defined in: [packages/typescript/ai/src/types.ts:657](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L657) Options passed into the SDK and further piped to the AI provider. @@ -27,7 +27,7 @@ Options passed into the SDK and further piped to the AI provider. optional abortController: AbortController; ``` -Defined in: [packages/typescript/ai/src/types.ts:740](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L740) +Defined in: [packages/typescript/ai/src/types.ts:741](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L741) AbortController for request cancellation. @@ -54,7 +54,7 @@ https://developer.mozilla.org/en-US/docs/Web/API/AbortController optional agentLoopStrategy: AgentLoopStrategy; ``` -Defined in: [packages/typescript/ai/src/types.ts:664](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L664) +Defined in: [packages/typescript/ai/src/types.ts:665](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L665) *** @@ -64,20 +64,34 @@ Defined in: [packages/typescript/ai/src/types.ts:664](https://github.com/TanStac optional conversationId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:726](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L726) +Defined in: [packages/typescript/ai/src/types.ts:727](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L727) Conversation ID for correlating client and server-side devtools events. When provided, server-side events will be linked to the client conversation in devtools. *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:748](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L748) + +Internal logger threaded from the chat entry point. Adapter implementations +must call `logger.request()` before SDK calls, `logger.provider()` for each +chunk received, and `logger.errors()` in catch blocks. + +*** + ### maxTokens? ```ts optional maxTokens: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:699](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L699) +Defined in: [packages/typescript/ai/src/types.ts:700](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L700) The maximum number of tokens to generate in the response. @@ -97,7 +111,7 @@ messages: ModelMessage< | null>[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:661](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L661) +Defined in: [packages/typescript/ai/src/types.ts:662](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L662) *** @@ -107,7 +121,7 @@ Defined in: [packages/typescript/ai/src/types.ts:661](https://github.com/TanStac optional metadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:710](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L710) +Defined in: [packages/typescript/ai/src/types.ts:711](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L711) Additional metadata to attach to the request. Can be used for tracking, debugging, or passing custom information. @@ -126,7 +140,7 @@ Provider usage: model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:660](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L660) +Defined in: [packages/typescript/ai/src/types.ts:661](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L661) *** @@ -136,7 +150,7 @@ Defined in: [packages/typescript/ai/src/types.ts:660](https://github.com/TanStac optional modelOptions: TProviderOptionsForModel; ``` -Defined in: [packages/typescript/ai/src/types.ts:711](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L711) +Defined in: [packages/typescript/ai/src/types.ts:712](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L712) *** @@ -146,7 +160,7 @@ Defined in: [packages/typescript/ai/src/types.ts:711](https://github.com/TanStac optional outputSchema: SchemaInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:721](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L721) +Defined in: [packages/typescript/ai/src/types.ts:722](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L722) Schema for structured output. When provided, the adapter should use the provider's native structured output API @@ -162,7 +176,7 @@ Supports any Standard JSON Schema compliant library (Zod, ArkType, Valibot, etc. optional request: Request | RequestInit; ``` -Defined in: [packages/typescript/ai/src/types.ts:712](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L712) +Defined in: [packages/typescript/ai/src/types.ts:713](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L713) *** @@ -172,7 +186,7 @@ Defined in: [packages/typescript/ai/src/types.ts:712](https://github.com/TanStac optional runId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:751](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L751) +Defined in: [packages/typescript/ai/src/types.ts:760](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L760) Run ID for AG-UI protocol run correlation. When provided, this will be used in RunStartedEvent and RunFinishedEvent. @@ -186,7 +200,7 @@ If not provided, a unique ID will be generated. optional systemPrompts: string[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:663](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L663) +Defined in: [packages/typescript/ai/src/types.ts:664](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L664) *** @@ -196,7 +210,7 @@ Defined in: [packages/typescript/ai/src/types.ts:663](https://github.com/TanStac optional temperature: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:677](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L677) +Defined in: [packages/typescript/ai/src/types.ts:678](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L678) Controls the randomness of the output. Higher values (e.g., 0.8) make output more random, lower values (e.g., 0.2) make it more focused and deterministic. @@ -217,7 +231,7 @@ Provider usage: optional threadId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:745](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L745) +Defined in: [packages/typescript/ai/src/types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) Thread ID for AG-UI protocol run correlation. When provided, this will be used in RunStartedEvent and RunFinishedEvent. @@ -230,7 +244,7 @@ When provided, this will be used in RunStartedEvent and RunFinishedEvent. optional tools: Tool[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:662](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L662) +Defined in: [packages/typescript/ai/src/types.ts:663](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L663) *** @@ -240,7 +254,7 @@ Defined in: [packages/typescript/ai/src/types.ts:662](https://github.com/TanStac optional topP: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:690](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L690) +Defined in: [packages/typescript/ai/src/types.ts:691](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L691) Nucleus sampling parameter. An alternative to temperature sampling. The model considers the results of tokens with topP probability mass. diff --git a/docs/reference/interfaces/TextPart.md b/docs/reference/interfaces/TextPart.md index 08b251aec..f2d33db71 100644 --- a/docs/reference/interfaces/TextPart.md +++ b/docs/reference/interfaces/TextPart.md @@ -5,7 +5,7 @@ title: TextPart # Interface: TextPart\ -Defined in: [packages/typescript/ai/src/types.ts:304](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L304) +Defined in: [packages/typescript/ai/src/types.ts:305](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L305) Message parts - building blocks of UIMessage @@ -23,7 +23,7 @@ Message parts - building blocks of UIMessage content: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:306](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L306) +Defined in: [packages/typescript/ai/src/types.ts:307](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L307) *** @@ -33,7 +33,7 @@ Defined in: [packages/typescript/ai/src/types.ts:306](https://github.com/TanStac optional metadata: TMetadata; ``` -Defined in: [packages/typescript/ai/src/types.ts:307](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L307) +Defined in: [packages/typescript/ai/src/types.ts:308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L308) *** @@ -43,4 +43,4 @@ Defined in: [packages/typescript/ai/src/types.ts:307](https://github.com/TanStac type: "text"; ``` -Defined in: [packages/typescript/ai/src/types.ts:305](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L305) +Defined in: [packages/typescript/ai/src/types.ts:306](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L306) diff --git a/docs/reference/interfaces/ThinkingPart.md b/docs/reference/interfaces/ThinkingPart.md index 9bdce16c4..2a0eac96e 100644 --- a/docs/reference/interfaces/ThinkingPart.md +++ b/docs/reference/interfaces/ThinkingPart.md @@ -5,7 +5,7 @@ title: ThinkingPart # Interface: ThinkingPart -Defined in: [packages/typescript/ai/src/types.ts:334](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L334) +Defined in: [packages/typescript/ai/src/types.ts:335](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L335) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/typescript/ai/src/types.ts:334](https://github.com/TanStac content: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L336) +Defined in: [packages/typescript/ai/src/types.ts:337](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L337) *** @@ -25,4 +25,4 @@ Defined in: [packages/typescript/ai/src/types.ts:336](https://github.com/TanStac type: "thinking"; ``` -Defined in: [packages/typescript/ai/src/types.ts:335](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L335) +Defined in: [packages/typescript/ai/src/types.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L336) diff --git a/docs/reference/interfaces/Tool.md b/docs/reference/interfaces/Tool.md index 8f06dc565..fa7071cb3 100644 --- a/docs/reference/interfaces/Tool.md +++ b/docs/reference/interfaces/Tool.md @@ -5,7 +5,7 @@ title: Tool # Interface: Tool\ -Defined in: [packages/typescript/ai/src/types.ts:416](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L416) +Defined in: [packages/typescript/ai/src/types.ts:417](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L417) Tool/Function definition for function calling. @@ -49,7 +49,7 @@ or plain JSON Schema objects for runtime validation and type safety. description: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:439](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L439) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -70,7 +70,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [packages/typescript/ai/src/types.ts:519](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L519) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -114,7 +114,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:479](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L479) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -168,7 +168,7 @@ type({ optional lazy: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:525](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L525) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -180,7 +180,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:528](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L528) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -192,7 +192,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [packages/typescript/ai/src/types.ts:429](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L429) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -213,7 +213,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:522](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L522) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -225,7 +225,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [packages/typescript/ai/src/types.ts:500](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L500) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/ToolCall.md b/docs/reference/interfaces/ToolCall.md index 123d0109a..9ca298739 100644 --- a/docs/reference/interfaces/ToolCall.md +++ b/docs/reference/interfaces/ToolCall.md @@ -5,7 +5,7 @@ title: ToolCall # Interface: ToolCall -Defined in: [packages/typescript/ai/src/types.ts:113](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L113) +Defined in: [packages/typescript/ai/src/types.ts:114](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L114) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/typescript/ai/src/types.ts:113](https://github.com/TanStac function: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:116](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L116) +Defined in: [packages/typescript/ai/src/types.ts:117](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L117) #### arguments @@ -37,7 +37,7 @@ name: string; id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:114](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L114) +Defined in: [packages/typescript/ai/src/types.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L115) *** @@ -47,7 +47,7 @@ Defined in: [packages/typescript/ai/src/types.ts:114](https://github.com/TanStac optional providerMetadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:121](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L121) +Defined in: [packages/typescript/ai/src/types.ts:122](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L122) Provider-specific metadata to carry through the tool call lifecycle @@ -59,4 +59,4 @@ Provider-specific metadata to carry through the tool call lifecycle type: "function"; ``` -Defined in: [packages/typescript/ai/src/types.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L115) +Defined in: [packages/typescript/ai/src/types.ts:116](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L116) diff --git a/docs/reference/interfaces/ToolCallArgsEvent.md b/docs/reference/interfaces/ToolCallArgsEvent.md index f81665ba2..78065958c 100644 --- a/docs/reference/interfaces/ToolCallArgsEvent.md +++ b/docs/reference/interfaces/ToolCallArgsEvent.md @@ -5,7 +5,7 @@ title: ToolCallArgsEvent # Interface: ToolCallArgsEvent -Defined in: [packages/typescript/ai/src/types.ts:905](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L905) +Defined in: [packages/typescript/ai/src/types.ts:914](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L914) Emitted when tool call arguments are streaming. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `args?` (accumulated) optional args: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:909](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L909) +Defined in: [packages/typescript/ai/src/types.ts:918](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L918) Full accumulated arguments so far (TanStack AI internal) @@ -42,6 +42,6 @@ Full accumulated arguments so far (TanStack AI internal) optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:907](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L907) +Defined in: [packages/typescript/ai/src/types.ts:916](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L916) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ToolCallEndEvent.md b/docs/reference/interfaces/ToolCallEndEvent.md index 2070ddf70..151d22e12 100644 --- a/docs/reference/interfaces/ToolCallEndEvent.md +++ b/docs/reference/interfaces/ToolCallEndEvent.md @@ -5,7 +5,7 @@ title: ToolCallEndEvent # Interface: ToolCallEndEvent -Defined in: [packages/typescript/ai/src/types.ts:918](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L918) +Defined in: [packages/typescript/ai/src/types.ts:927](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L927) Emitted when a tool call completes. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `toolCallName?`, `toolName?` (deprecated), `input?`, optional input: unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:929](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L929) +Defined in: [packages/typescript/ai/src/types.ts:938](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L938) Final parsed input arguments (TanStack AI internal) @@ -42,7 +42,7 @@ Final parsed input arguments (TanStack AI internal) optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:920](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L920) +Defined in: [packages/typescript/ai/src/types.ts:929](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L929) Model identifier for multi-model support @@ -54,7 +54,7 @@ Model identifier for multi-model support optional result: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:931](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L931) +Defined in: [packages/typescript/ai/src/types.ts:940](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L940) Tool execution result (TanStack AI internal) @@ -66,7 +66,7 @@ Tool execution result (TanStack AI internal) optional toolCallName: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:922](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L922) +Defined in: [packages/typescript/ai/src/types.ts:931](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L931) Name of the tool that completed @@ -78,7 +78,7 @@ Name of the tool that completed optional toolName: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:927](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L927) +Defined in: [packages/typescript/ai/src/types.ts:936](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L936) #### Deprecated diff --git a/docs/reference/interfaces/ToolCallPart.md b/docs/reference/interfaces/ToolCallPart.md index 61794bd5b..587147737 100644 --- a/docs/reference/interfaces/ToolCallPart.md +++ b/docs/reference/interfaces/ToolCallPart.md @@ -5,7 +5,7 @@ title: ToolCallPart # Interface: ToolCallPart -Defined in: [packages/typescript/ai/src/types.ts:310](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L310) +Defined in: [packages/typescript/ai/src/types.ts:311](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L311) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/typescript/ai/src/types.ts:310](https://github.com/TanStac optional approval: object; ``` -Defined in: [packages/typescript/ai/src/types.ts:317](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L317) +Defined in: [packages/typescript/ai/src/types.ts:318](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L318) Approval metadata if tool requires user approval @@ -45,7 +45,7 @@ needsApproval: boolean; arguments: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:314](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L314) +Defined in: [packages/typescript/ai/src/types.ts:315](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L315) *** @@ -55,7 +55,7 @@ Defined in: [packages/typescript/ai/src/types.ts:314](https://github.com/TanStac id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:312](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L312) +Defined in: [packages/typescript/ai/src/types.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L313) *** @@ -65,7 +65,7 @@ Defined in: [packages/typescript/ai/src/types.ts:312](https://github.com/TanStac name: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L313) +Defined in: [packages/typescript/ai/src/types.ts:314](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L314) *** @@ -75,7 +75,7 @@ Defined in: [packages/typescript/ai/src/types.ts:313](https://github.com/TanStac optional output: any; ``` -Defined in: [packages/typescript/ai/src/types.ts:323](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L323) +Defined in: [packages/typescript/ai/src/types.ts:324](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L324) Tool execution output (for client tools or after approval) @@ -87,7 +87,7 @@ Tool execution output (for client tools or after approval) state: ToolCallState; ``` -Defined in: [packages/typescript/ai/src/types.ts:315](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L315) +Defined in: [packages/typescript/ai/src/types.ts:316](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L316) *** @@ -97,4 +97,4 @@ Defined in: [packages/typescript/ai/src/types.ts:315](https://github.com/TanStac type: "tool-call"; ``` -Defined in: [packages/typescript/ai/src/types.ts:311](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L311) +Defined in: [packages/typescript/ai/src/types.ts:312](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L312) diff --git a/docs/reference/interfaces/ToolCallResultEvent.md b/docs/reference/interfaces/ToolCallResultEvent.md index f262ae1dc..d30915c7c 100644 --- a/docs/reference/interfaces/ToolCallResultEvent.md +++ b/docs/reference/interfaces/ToolCallResultEvent.md @@ -5,7 +5,7 @@ title: ToolCallResultEvent # Interface: ToolCallResultEvent -Defined in: [packages/typescript/ai/src/types.ts:940](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L940) +Defined in: [packages/typescript/ai/src/types.ts:949](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L949) Emitted when a tool call result is available. @@ -30,6 +30,6 @@ TanStack AI adds: `model?` optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:942](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L942) +Defined in: [packages/typescript/ai/src/types.ts:951](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L951) Model identifier for multi-model support diff --git a/docs/reference/interfaces/ToolCallStartEvent.md b/docs/reference/interfaces/ToolCallStartEvent.md index 94c3f13e3..910719f6e 100644 --- a/docs/reference/interfaces/ToolCallStartEvent.md +++ b/docs/reference/interfaces/ToolCallStartEvent.md @@ -5,7 +5,7 @@ title: ToolCallStartEvent # Interface: ToolCallStartEvent -Defined in: [packages/typescript/ai/src/types.ts:885](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L885) +Defined in: [packages/typescript/ai/src/types.ts:894](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L894) Emitted when a tool call starts. @@ -30,7 +30,7 @@ TanStack AI adds: `model?`, `toolName` (deprecated alias), `index?`, `providerMe optional index: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:894](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L894) +Defined in: [packages/typescript/ai/src/types.ts:903](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L903) Index for parallel tool calls @@ -42,7 +42,7 @@ Index for parallel tool calls optional model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:887](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L887) +Defined in: [packages/typescript/ai/src/types.ts:896](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L896) Model identifier for multi-model support @@ -54,7 +54,7 @@ Model identifier for multi-model support optional providerMetadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:896](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L896) +Defined in: [packages/typescript/ai/src/types.ts:905](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L905) Provider-specific metadata to carry into the ToolCall @@ -66,7 +66,7 @@ Provider-specific metadata to carry into the ToolCall toolName: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:892](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L892) +Defined in: [packages/typescript/ai/src/types.ts:901](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L901) #### Deprecated diff --git a/docs/reference/interfaces/ToolConfig.md b/docs/reference/interfaces/ToolConfig.md index eb56d9a6b..8536a21e8 100644 --- a/docs/reference/interfaces/ToolConfig.md +++ b/docs/reference/interfaces/ToolConfig.md @@ -5,7 +5,7 @@ title: ToolConfig # Interface: ToolConfig -Defined in: [packages/typescript/ai/src/types.ts:531](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L531) +Defined in: [packages/typescript/ai/src/types.ts:532](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L532) ## Indexable diff --git a/docs/reference/interfaces/ToolDefinition.md b/docs/reference/interfaces/ToolDefinition.md index f8d69290f..bd1443841 100644 --- a/docs/reference/interfaces/ToolDefinition.md +++ b/docs/reference/interfaces/ToolDefinition.md @@ -73,7 +73,7 @@ Create a client-side tool with optional execute function description: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:439](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L439) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -98,7 +98,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [packages/typescript/ai/src/types.ts:519](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L519) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -146,7 +146,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:479](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L479) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -204,7 +204,7 @@ type({ optional lazy: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:525](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L525) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -220,7 +220,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:528](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L528) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -236,7 +236,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [packages/typescript/ai/src/types.ts:429](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L429) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -261,7 +261,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:522](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L522) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -277,7 +277,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [packages/typescript/ai/src/types.ts:500](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L500) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/ToolDefinitionInstance.md b/docs/reference/interfaces/ToolDefinitionInstance.md index 3b3f2e14f..397adaa71 100644 --- a/docs/reference/interfaces/ToolDefinitionInstance.md +++ b/docs/reference/interfaces/ToolDefinitionInstance.md @@ -49,7 +49,7 @@ Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts description: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:439](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L439) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -74,7 +74,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [packages/typescript/ai/src/types.ts:519](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L519) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -122,7 +122,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [packages/typescript/ai/src/types.ts:479](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L479) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -180,7 +180,7 @@ type({ optional lazy: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:525](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L525) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -196,7 +196,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [packages/typescript/ai/src/types.ts:528](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L528) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -212,7 +212,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [packages/typescript/ai/src/types.ts:429](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L429) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -237,7 +237,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:522](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L522) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -253,7 +253,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [packages/typescript/ai/src/types.ts:500](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L500) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/ToolExecutionContext.md b/docs/reference/interfaces/ToolExecutionContext.md index f34f90025..6b06c4ead 100644 --- a/docs/reference/interfaces/ToolExecutionContext.md +++ b/docs/reference/interfaces/ToolExecutionContext.md @@ -5,7 +5,7 @@ title: ToolExecutionContext # Interface: ToolExecutionContext -Defined in: [packages/typescript/ai/src/types.ts:379](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L379) +Defined in: [packages/typescript/ai/src/types.ts:380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L380) Context passed to tool execute functions, providing capabilities like emitting custom events during execution. @@ -18,7 +18,7 @@ emitting custom events during execution. emitCustomEvent: (eventName, value) => void; ``` -Defined in: [packages/typescript/ai/src/types.ts:400](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L400) +Defined in: [packages/typescript/ai/src/types.ts:401](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L401) Emit a custom event during tool execution. Events are streamed to the client in real-time as AG-UI CUSTOM events. @@ -61,6 +61,6 @@ const tool = toolDefinition({ ... }).server(async (args, context) => { optional toolCallId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:381](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L381) +Defined in: [packages/typescript/ai/src/types.ts:382](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L382) The ID of the tool call being executed diff --git a/docs/reference/interfaces/ToolResultPart.md b/docs/reference/interfaces/ToolResultPart.md index 1137710ad..6d800be69 100644 --- a/docs/reference/interfaces/ToolResultPart.md +++ b/docs/reference/interfaces/ToolResultPart.md @@ -5,7 +5,7 @@ title: ToolResultPart # Interface: ToolResultPart -Defined in: [packages/typescript/ai/src/types.ts:326](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L326) +Defined in: [packages/typescript/ai/src/types.ts:327](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L327) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/typescript/ai/src/types.ts:326](https://github.com/TanStac content: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:329](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L329) +Defined in: [packages/typescript/ai/src/types.ts:330](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L330) *** @@ -25,7 +25,7 @@ Defined in: [packages/typescript/ai/src/types.ts:329](https://github.com/TanStac optional error: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L331) +Defined in: [packages/typescript/ai/src/types.ts:332](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L332) *** @@ -35,7 +35,7 @@ Defined in: [packages/typescript/ai/src/types.ts:331](https://github.com/TanStac state: ToolResultState; ``` -Defined in: [packages/typescript/ai/src/types.ts:330](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L330) +Defined in: [packages/typescript/ai/src/types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L331) *** @@ -45,7 +45,7 @@ Defined in: [packages/typescript/ai/src/types.ts:330](https://github.com/TanStac toolCallId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:328](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L328) +Defined in: [packages/typescript/ai/src/types.ts:329](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L329) *** @@ -55,4 +55,4 @@ Defined in: [packages/typescript/ai/src/types.ts:328](https://github.com/TanStac type: "tool-result"; ``` -Defined in: [packages/typescript/ai/src/types.ts:327](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L327) +Defined in: [packages/typescript/ai/src/types.ts:328](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L328) diff --git a/docs/reference/interfaces/TranscriptionOptions.md b/docs/reference/interfaces/TranscriptionOptions.md index 22eee6b10..a91271464 100644 --- a/docs/reference/interfaces/TranscriptionOptions.md +++ b/docs/reference/interfaces/TranscriptionOptions.md @@ -5,7 +5,7 @@ title: TranscriptionOptions # Interface: TranscriptionOptions\ -Defined in: [packages/typescript/ai/src/types.ts:1350](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1350) +Defined in: [packages/typescript/ai/src/types.ts:1380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1380) Options for audio transcription. These are the common options supported across providers. @@ -24,7 +24,7 @@ These are the common options supported across providers. audio: string | File | Blob | ArrayBuffer; ``` -Defined in: [packages/typescript/ai/src/types.ts:1356](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1356) +Defined in: [packages/typescript/ai/src/types.ts:1386](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1386) The audio data to transcribe - can be base64 string, File, Blob, or Buffer @@ -36,19 +36,33 @@ The audio data to transcribe - can be base64 string, File, Blob, or Buffer optional language: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1358](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1358) +Defined in: [packages/typescript/ai/src/types.ts:1388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1388) The language of the audio in ISO-639-1 format (e.g., 'en') *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1400](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1400) + +Internal logger threaded from the generateTranscription() entry point. +Adapters must call logger.request() before the SDK call and logger.errors() +in catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1354](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1354) +Defined in: [packages/typescript/ai/src/types.ts:1384](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1384) The model to use for transcription @@ -60,7 +74,7 @@ The model to use for transcription optional modelOptions: TProviderOptions; ``` -Defined in: [packages/typescript/ai/src/types.ts:1364](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1364) +Defined in: [packages/typescript/ai/src/types.ts:1394](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1394) Model-specific options for transcription @@ -72,7 +86,7 @@ Model-specific options for transcription optional prompt: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1360](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1360) +Defined in: [packages/typescript/ai/src/types.ts:1390](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1390) An optional prompt to guide the transcription @@ -84,6 +98,6 @@ An optional prompt to guide the transcription optional responseFormat: "text" | "json" | "srt" | "verbose_json" | "vtt"; ``` -Defined in: [packages/typescript/ai/src/types.ts:1362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1362) +Defined in: [packages/typescript/ai/src/types.ts:1392](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1392) The format of the transcription output diff --git a/docs/reference/interfaces/TranscriptionResult.md b/docs/reference/interfaces/TranscriptionResult.md index 264b93e83..37b1adf96 100644 --- a/docs/reference/interfaces/TranscriptionResult.md +++ b/docs/reference/interfaces/TranscriptionResult.md @@ -5,7 +5,7 @@ title: TranscriptionResult # Interface: TranscriptionResult -Defined in: [packages/typescript/ai/src/types.ts:1400](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1400) +Defined in: [packages/typescript/ai/src/types.ts:1436](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1436) Result of audio transcription. @@ -17,7 +17,7 @@ Result of audio transcription. optional duration: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1410](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1410) +Defined in: [packages/typescript/ai/src/types.ts:1446](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1446) Duration of the audio in seconds @@ -29,7 +29,7 @@ Duration of the audio in seconds id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1402](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1402) +Defined in: [packages/typescript/ai/src/types.ts:1438](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1438) Unique identifier for the transcription @@ -41,7 +41,7 @@ Unique identifier for the transcription optional language: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1408](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1408) +Defined in: [packages/typescript/ai/src/types.ts:1444](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1444) Language detected or specified @@ -53,7 +53,7 @@ Language detected or specified model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1404](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1404) +Defined in: [packages/typescript/ai/src/types.ts:1440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1440) Model used for transcription @@ -65,7 +65,7 @@ Model used for transcription optional segments: TranscriptionSegment[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:1412](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1412) +Defined in: [packages/typescript/ai/src/types.ts:1448](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1448) Detailed segments with timing, if available @@ -77,7 +77,7 @@ Detailed segments with timing, if available text: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1406](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1406) +Defined in: [packages/typescript/ai/src/types.ts:1442](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1442) The full transcribed text @@ -89,6 +89,6 @@ The full transcribed text optional words: TranscriptionWord[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:1414](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1414) +Defined in: [packages/typescript/ai/src/types.ts:1450](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1450) Word-level timestamps, if available diff --git a/docs/reference/interfaces/TranscriptionSegment.md b/docs/reference/interfaces/TranscriptionSegment.md index 4b1dbc807..5d5764aaf 100644 --- a/docs/reference/interfaces/TranscriptionSegment.md +++ b/docs/reference/interfaces/TranscriptionSegment.md @@ -5,7 +5,7 @@ title: TranscriptionSegment # Interface: TranscriptionSegment -Defined in: [packages/typescript/ai/src/types.ts:1370](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1370) +Defined in: [packages/typescript/ai/src/types.ts:1406](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1406) A single segment of transcribed audio with timing information. @@ -17,7 +17,7 @@ A single segment of transcribed audio with timing information. optional confidence: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1380) +Defined in: [packages/typescript/ai/src/types.ts:1416](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1416) Confidence score (0-1), if available @@ -29,7 +29,7 @@ Confidence score (0-1), if available end: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1376](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1376) +Defined in: [packages/typescript/ai/src/types.ts:1412](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1412) End time of the segment in seconds @@ -41,7 +41,7 @@ End time of the segment in seconds id: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1372](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1372) +Defined in: [packages/typescript/ai/src/types.ts:1408](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1408) Unique identifier for the segment @@ -53,7 +53,7 @@ Unique identifier for the segment optional speaker: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1382](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1382) +Defined in: [packages/typescript/ai/src/types.ts:1418](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1418) Speaker identifier, if diarization is enabled @@ -65,7 +65,7 @@ Speaker identifier, if diarization is enabled start: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1374](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1374) +Defined in: [packages/typescript/ai/src/types.ts:1410](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1410) Start time of the segment in seconds @@ -77,6 +77,6 @@ Start time of the segment in seconds text: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1378](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1378) +Defined in: [packages/typescript/ai/src/types.ts:1414](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1414) Transcribed text for this segment diff --git a/docs/reference/interfaces/TranscriptionWord.md b/docs/reference/interfaces/TranscriptionWord.md index 7dab967f9..1b035a377 100644 --- a/docs/reference/interfaces/TranscriptionWord.md +++ b/docs/reference/interfaces/TranscriptionWord.md @@ -5,7 +5,7 @@ title: TranscriptionWord # Interface: TranscriptionWord -Defined in: [packages/typescript/ai/src/types.ts:1388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1388) +Defined in: [packages/typescript/ai/src/types.ts:1424](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1424) A single word with timing information. @@ -17,7 +17,7 @@ A single word with timing information. end: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1394](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1394) +Defined in: [packages/typescript/ai/src/types.ts:1430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1430) End time in seconds @@ -29,7 +29,7 @@ End time in seconds start: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1392](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1392) +Defined in: [packages/typescript/ai/src/types.ts:1428](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1428) Start time in seconds @@ -41,6 +41,6 @@ Start time in seconds word: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1390](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1390) +Defined in: [packages/typescript/ai/src/types.ts:1426](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1426) The transcribed word diff --git a/docs/reference/interfaces/UIMessage.md b/docs/reference/interfaces/UIMessage.md index 20aec0dc0..a309de54d 100644 --- a/docs/reference/interfaces/UIMessage.md +++ b/docs/reference/interfaces/UIMessage.md @@ -5,7 +5,7 @@ title: UIMessage # Interface: UIMessage -Defined in: [packages/typescript/ai/src/types.ts:353](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L353) +Defined in: [packages/typescript/ai/src/types.ts:354](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L354) UIMessage - Domain-specific message format optimized for building chat UIs Contains parts that can be text, tool calls, or tool results @@ -18,7 +18,7 @@ Contains parts that can be text, tool calls, or tool results optional createdAt: Date; ``` -Defined in: [packages/typescript/ai/src/types.ts:357](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L357) +Defined in: [packages/typescript/ai/src/types.ts:358](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L358) *** @@ -28,7 +28,7 @@ Defined in: [packages/typescript/ai/src/types.ts:357](https://github.com/TanStac id: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:354](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L354) +Defined in: [packages/typescript/ai/src/types.ts:355](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L355) *** @@ -38,7 +38,7 @@ Defined in: [packages/typescript/ai/src/types.ts:354](https://github.com/TanStac parts: MessagePart[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:356](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L356) +Defined in: [packages/typescript/ai/src/types.ts:357](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L357) *** @@ -48,4 +48,4 @@ Defined in: [packages/typescript/ai/src/types.ts:356](https://github.com/TanStac role: "user" | "assistant" | "system"; ``` -Defined in: [packages/typescript/ai/src/types.ts:355](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L355) +Defined in: [packages/typescript/ai/src/types.ts:356](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L356) diff --git a/docs/reference/interfaces/VideoGenerationOptions.md b/docs/reference/interfaces/VideoGenerationOptions.md index d6c51cd62..88bcb72ee 100644 --- a/docs/reference/interfaces/VideoGenerationOptions.md +++ b/docs/reference/interfaces/VideoGenerationOptions.md @@ -5,7 +5,7 @@ title: VideoGenerationOptions # Interface: VideoGenerationOptions\ -Defined in: [packages/typescript/ai/src/types.ts:1243](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1243) +Defined in: [packages/typescript/ai/src/types.ts:1262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1262) **`Experimental`** @@ -32,7 +32,7 @@ These are the common options supported across providers. optional duration: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1254](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1254) +Defined in: [packages/typescript/ai/src/types.ts:1273](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1273) **`Experimental`** @@ -40,13 +40,28 @@ Video duration in seconds *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1280](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1280) + +**`Experimental`** + +Internal logger threaded from the generateVideo() entry point. Adapters must +call logger.request() before the SDK call and logger.errors() in catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1248](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1248) +Defined in: [packages/typescript/ai/src/types.ts:1267](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1267) **`Experimental`** @@ -60,7 +75,7 @@ The model to use for video generation optional modelOptions: TProviderOptions; ``` -Defined in: [packages/typescript/ai/src/types.ts:1256](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1256) +Defined in: [packages/typescript/ai/src/types.ts:1275](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1275) **`Experimental`** @@ -74,7 +89,7 @@ Model-specific options for video generation prompt: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1250](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1250) +Defined in: [packages/typescript/ai/src/types.ts:1269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1269) **`Experimental`** @@ -88,7 +103,7 @@ Text description of the desired video optional size: TSize; ``` -Defined in: [packages/typescript/ai/src/types.ts:1252](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1252) +Defined in: [packages/typescript/ai/src/types.ts:1271](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1271) **`Experimental`** diff --git a/docs/reference/interfaces/VideoJobResult.md b/docs/reference/interfaces/VideoJobResult.md index c414f4da8..09a9518f7 100644 --- a/docs/reference/interfaces/VideoJobResult.md +++ b/docs/reference/interfaces/VideoJobResult.md @@ -5,7 +5,7 @@ title: VideoJobResult # Interface: VideoJobResult -Defined in: [packages/typescript/ai/src/types.ts:1264](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1264) +Defined in: [packages/typescript/ai/src/types.ts:1288](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1288) **`Experimental`** @@ -21,7 +21,7 @@ Result of creating a video generation job. jobId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1266](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1266) +Defined in: [packages/typescript/ai/src/types.ts:1290](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1290) **`Experimental`** @@ -35,7 +35,7 @@ Unique job identifier for polling status model: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1268](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1268) +Defined in: [packages/typescript/ai/src/types.ts:1292](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1292) **`Experimental`** diff --git a/docs/reference/interfaces/VideoPart.md b/docs/reference/interfaces/VideoPart.md index 5ad10c831..e2829886e 100644 --- a/docs/reference/interfaces/VideoPart.md +++ b/docs/reference/interfaces/VideoPart.md @@ -5,7 +5,7 @@ title: VideoPart # Interface: VideoPart\ -Defined in: [packages/typescript/ai/src/types.ts:213](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L213) +Defined in: [packages/typescript/ai/src/types.ts:214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L214) Video content part for multimodal messages. @@ -25,7 +25,7 @@ Provider-specific metadata type optional metadata: TMetadata; ``` -Defined in: [packages/typescript/ai/src/types.ts:218](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L218) +Defined in: [packages/typescript/ai/src/types.ts:219](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L219) Provider-specific metadata (e.g., duration, resolution) @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., duration, resolution) source: ContentPartSource; ``` -Defined in: [packages/typescript/ai/src/types.ts:216](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L216) +Defined in: [packages/typescript/ai/src/types.ts:217](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L217) Source of the video content @@ -49,4 +49,4 @@ Source of the video content type: "video"; ``` -Defined in: [packages/typescript/ai/src/types.ts:214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L214) +Defined in: [packages/typescript/ai/src/types.ts:215](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L215) diff --git a/docs/reference/interfaces/VideoStatusResult.md b/docs/reference/interfaces/VideoStatusResult.md index 93733db14..522149991 100644 --- a/docs/reference/interfaces/VideoStatusResult.md +++ b/docs/reference/interfaces/VideoStatusResult.md @@ -5,7 +5,7 @@ title: VideoStatusResult # Interface: VideoStatusResult -Defined in: [packages/typescript/ai/src/types.ts:1276](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1276) +Defined in: [packages/typescript/ai/src/types.ts:1300](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1300) **`Experimental`** @@ -21,7 +21,7 @@ Status of a video generation job. optional error: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1284](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1284) +Defined in: [packages/typescript/ai/src/types.ts:1308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1308) **`Experimental`** @@ -35,7 +35,7 @@ Error message if status is 'failed' jobId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1278](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1278) +Defined in: [packages/typescript/ai/src/types.ts:1302](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1302) **`Experimental`** @@ -49,7 +49,7 @@ Job identifier optional progress: number; ``` -Defined in: [packages/typescript/ai/src/types.ts:1282](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1282) +Defined in: [packages/typescript/ai/src/types.ts:1306](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1306) **`Experimental`** @@ -63,7 +63,7 @@ Progress percentage (0-100), if available status: "pending" | "processing" | "completed" | "failed"; ``` -Defined in: [packages/typescript/ai/src/types.ts:1280](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1280) +Defined in: [packages/typescript/ai/src/types.ts:1304](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1304) **`Experimental`** diff --git a/docs/reference/interfaces/VideoUrlResult.md b/docs/reference/interfaces/VideoUrlResult.md index e299e9b45..c2fbca191 100644 --- a/docs/reference/interfaces/VideoUrlResult.md +++ b/docs/reference/interfaces/VideoUrlResult.md @@ -5,7 +5,7 @@ title: VideoUrlResult # Interface: VideoUrlResult -Defined in: [packages/typescript/ai/src/types.ts:1292](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1292) +Defined in: [packages/typescript/ai/src/types.ts:1316](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1316) **`Experimental`** @@ -21,7 +21,7 @@ Result containing the URL to a generated video. optional expiresAt: Date; ``` -Defined in: [packages/typescript/ai/src/types.ts:1298](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1298) +Defined in: [packages/typescript/ai/src/types.ts:1322](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1322) **`Experimental`** @@ -35,7 +35,7 @@ When the URL expires, if applicable jobId: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1294](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1294) +Defined in: [packages/typescript/ai/src/types.ts:1318](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1318) **`Experimental`** @@ -49,7 +49,7 @@ Job identifier url: string; ``` -Defined in: [packages/typescript/ai/src/types.ts:1296](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1296) +Defined in: [packages/typescript/ai/src/types.ts:1320](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1320) **`Experimental`** diff --git a/docs/reference/type-aliases/AGUIEvent.md b/docs/reference/type-aliases/AGUIEvent.md index 6c53bedaa..a6fd82eff 100644 --- a/docs/reference/type-aliases/AGUIEvent.md +++ b/docs/reference/type-aliases/AGUIEvent.md @@ -31,6 +31,6 @@ type AGUIEvent = | ReasoningEncryptedValueEvent; ``` -Defined in: [packages/typescript/ai/src/types.ts:1115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1115) +Defined in: [packages/typescript/ai/src/types.ts:1124](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1124) Union of all AG-UI events. diff --git a/docs/reference/type-aliases/AGUIEventType.md b/docs/reference/type-aliases/AGUIEventType.md index ec78ef587..032e2d387 100644 --- a/docs/reference/type-aliases/AGUIEventType.md +++ b/docs/reference/type-aliases/AGUIEventType.md @@ -9,7 +9,7 @@ title: AGUIEventType type AGUIEventType = `${EventType}`; ``` -Defined in: [packages/typescript/ai/src/types.ts:770](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L770) +Defined in: [packages/typescript/ai/src/types.ts:779](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L779) AG-UI Protocol event types. diff --git a/docs/reference/type-aliases/AgentLoopStrategy.md b/docs/reference/type-aliases/AgentLoopStrategy.md index 823b930b6..769e181aa 100644 --- a/docs/reference/type-aliases/AgentLoopStrategy.md +++ b/docs/reference/type-aliases/AgentLoopStrategy.md @@ -9,7 +9,7 @@ title: AgentLoopStrategy type AgentLoopStrategy = (state) => boolean; ``` -Defined in: [packages/typescript/ai/src/types.ts:651](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L651) +Defined in: [packages/typescript/ai/src/types.ts:652](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L652) Strategy function that determines whether the agent loop should continue diff --git a/docs/reference/type-aliases/AnyTextAdapter.md b/docs/reference/type-aliases/AnyTextAdapter.md index e1720be81..5420432b6 100644 --- a/docs/reference/type-aliases/AnyTextAdapter.md +++ b/docs/reference/type-aliases/AnyTextAdapter.md @@ -9,7 +9,7 @@ title: AnyTextAdapter type AnyTextAdapter = TextAdapter; ``` -Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L101) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:106](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L106) A TextAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/ConstrainedContent.md b/docs/reference/type-aliases/ConstrainedContent.md index e46882030..0d6427edd 100644 --- a/docs/reference/type-aliases/ConstrainedContent.md +++ b/docs/reference/type-aliases/ConstrainedContent.md @@ -12,7 +12,7 @@ type ConstrainedContent = | ContentPartForInputModalitiesTypes[]; ``` -Defined in: [packages/typescript/ai/src/types.ts:281](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L281) +Defined in: [packages/typescript/ai/src/types.ts:282](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L282) Type for message content constrained by supported modalities. When modalities is ['text', 'image'], only TextPart and ImagePart are allowed in the array. diff --git a/docs/reference/type-aliases/ConstrainedModelMessage.md b/docs/reference/type-aliases/ConstrainedModelMessage.md index 1c95fd418..ae9a6eec7 100644 --- a/docs/reference/type-aliases/ConstrainedModelMessage.md +++ b/docs/reference/type-aliases/ConstrainedModelMessage.md @@ -9,7 +9,7 @@ title: ConstrainedModelMessage type ConstrainedModelMessage = Omit & object; ``` -Defined in: [packages/typescript/ai/src/types.ts:369](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L369) +Defined in: [packages/typescript/ai/src/types.ts:370](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L370) A ModelMessage with content constrained to only allow content parts matching the specified input modalities. diff --git a/docs/reference/type-aliases/ContentPart.md b/docs/reference/type-aliases/ContentPart.md index 2678fd098..a4139b2b0 100644 --- a/docs/reference/type-aliases/ContentPart.md +++ b/docs/reference/type-aliases/ContentPart.md @@ -14,7 +14,7 @@ type ContentPart = | DocumentPart; ``` -Defined in: [packages/typescript/ai/src/types.ts:240](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L240) +Defined in: [packages/typescript/ai/src/types.ts:241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L241) Union type for all multimodal content parts. diff --git a/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md b/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md index 884f43c0d..7b707e3c7 100644 --- a/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md +++ b/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md @@ -11,7 +11,7 @@ type ContentPartForInputModalitiesTypes = Extract; ``` -Defined in: [packages/typescript/ai/src/types.ts:257](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L257) +Defined in: [packages/typescript/ai/src/types.ts:258](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L258) Helper type to filter ContentPart union to only include specific modalities. Used to constrain message content based on model capabilities. diff --git a/docs/reference/type-aliases/ContentPartSource.md b/docs/reference/type-aliases/ContentPartSource.md index c11bdee3b..d7b5b3bc3 100644 --- a/docs/reference/type-aliases/ContentPartSource.md +++ b/docs/reference/type-aliases/ContentPartSource.md @@ -11,7 +11,7 @@ type ContentPartSource = | ContentPartUrlSource; ``` -Defined in: [packages/typescript/ai/src/types.ts:183](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L183) +Defined in: [packages/typescript/ai/src/types.ts:184](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L184) Source specification for multimodal content. Discriminated union supporting both inline data (base64) and URL-based content. diff --git a/docs/reference/type-aliases/DebugOption.md b/docs/reference/type-aliases/DebugOption.md new file mode 100644 index 000000000..10ea542db --- /dev/null +++ b/docs/reference/type-aliases/DebugOption.md @@ -0,0 +1,14 @@ +--- +id: DebugOption +title: DebugOption +--- + +# Type Alias: DebugOption + +```ts +type DebugOption = boolean | DebugConfig; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L78) + +The shape accepted by the `debug` option on every `@tanstack/ai` activity. Pass `true` to enable all categories with the default console logger; `false` to silence everything including errors; an object for granular control. diff --git a/docs/reference/type-aliases/InferSchemaType.md b/docs/reference/type-aliases/InferSchemaType.md index d5a50de4f..7e64f3734 100644 --- a/docs/reference/type-aliases/InferSchemaType.md +++ b/docs/reference/type-aliases/InferSchemaType.md @@ -9,7 +9,7 @@ title: InferSchemaType type InferSchemaType = T extends StandardJSONSchemaV1 ? TInput : unknown; ``` -Defined in: [packages/typescript/ai/src/types.ts:110](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L110) +Defined in: [packages/typescript/ai/src/types.ts:111](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L111) Infer the TypeScript type from a schema. For Standard JSON Schema compliant schemas, extracts the input type. diff --git a/docs/reference/type-aliases/InputModalitiesTypes.md b/docs/reference/type-aliases/InputModalitiesTypes.md index 2c231dab5..aaa24e219 100644 --- a/docs/reference/type-aliases/InputModalitiesTypes.md +++ b/docs/reference/type-aliases/InputModalitiesTypes.md @@ -9,7 +9,7 @@ title: InputModalitiesTypes type InputModalitiesTypes = object; ``` -Defined in: [packages/typescript/ai/src/types.ts:360](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L360) +Defined in: [packages/typescript/ai/src/types.ts:361](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L361) ## Properties @@ -19,7 +19,7 @@ Defined in: [packages/typescript/ai/src/types.ts:360](https://github.com/TanStac inputModalities: ReadonlyArray; ``` -Defined in: [packages/typescript/ai/src/types.ts:361](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L361) +Defined in: [packages/typescript/ai/src/types.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L362) *** @@ -29,4 +29,4 @@ Defined in: [packages/typescript/ai/src/types.ts:361](https://github.com/TanStac messageMetadataByModality: DefaultMessageMetadataByModality; ``` -Defined in: [packages/typescript/ai/src/types.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L362) +Defined in: [packages/typescript/ai/src/types.ts:363](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L363) diff --git a/docs/reference/type-aliases/MessagePart.md b/docs/reference/type-aliases/MessagePart.md index f9f76d293..fc4f90228 100644 --- a/docs/reference/type-aliases/MessagePart.md +++ b/docs/reference/type-aliases/MessagePart.md @@ -17,4 +17,4 @@ type MessagePart = | ThinkingPart; ``` -Defined in: [packages/typescript/ai/src/types.ts:339](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L339) +Defined in: [packages/typescript/ai/src/types.ts:340](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L340) diff --git a/docs/reference/type-aliases/ModalitiesArrayToUnion.md b/docs/reference/type-aliases/ModalitiesArrayToUnion.md index 8bd30a11a..5f9d2ee58 100644 --- a/docs/reference/type-aliases/ModalitiesArrayToUnion.md +++ b/docs/reference/type-aliases/ModalitiesArrayToUnion.md @@ -9,7 +9,7 @@ title: ModalitiesArrayToUnion type ModalitiesArrayToUnion = T[number]; ``` -Defined in: [packages/typescript/ai/src/types.ts:274](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L274) +Defined in: [packages/typescript/ai/src/types.ts:275](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L275) Helper type to convert a readonly array of modalities to a union type. e.g., readonly ['text', 'image'] -> 'text' | 'image' diff --git a/docs/reference/type-aliases/Modality.md b/docs/reference/type-aliases/Modality.md index c240a2fb7..1a164036b 100644 --- a/docs/reference/type-aliases/Modality.md +++ b/docs/reference/type-aliases/Modality.md @@ -9,7 +9,7 @@ title: Modality type Modality = "text" | "image" | "audio" | "video" | "document"; ``` -Defined in: [packages/typescript/ai/src/types.ts:136](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L136) +Defined in: [packages/typescript/ai/src/types.ts:137](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L137) Supported input modality types for multimodal content. - 'text': Plain text content diff --git a/docs/reference/type-aliases/SchemaInput.md b/docs/reference/type-aliases/SchemaInput.md index 8cc81b120..c496352e4 100644 --- a/docs/reference/type-aliases/SchemaInput.md +++ b/docs/reference/type-aliases/SchemaInput.md @@ -11,7 +11,7 @@ type SchemaInput = | JSONSchema; ``` -Defined in: [packages/typescript/ai/src/types.ts:103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L103) +Defined in: [packages/typescript/ai/src/types.ts:104](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L104) Union type for schema input - can be any Standard JSON Schema compliant schema or a plain JSONSchema object. diff --git a/docs/reference/type-aliases/StreamChunk.md b/docs/reference/type-aliases/StreamChunk.md index d223e68e3..0fe7fe8d7 100644 --- a/docs/reference/type-aliases/StreamChunk.md +++ b/docs/reference/type-aliases/StreamChunk.md @@ -9,7 +9,7 @@ title: StreamChunk type StreamChunk = AGUIEvent; ``` -Defined in: [packages/typescript/ai/src/types.ts:1143](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1143) +Defined in: [packages/typescript/ai/src/types.ts:1152](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1152) Chunk returned by the SDK during streaming chat completions. Uses the AG-UI protocol event format. diff --git a/docs/reference/type-aliases/StreamChunkType.md b/docs/reference/type-aliases/StreamChunkType.md index 5cdc6bb1f..418daa220 100644 --- a/docs/reference/type-aliases/StreamChunkType.md +++ b/docs/reference/type-aliases/StreamChunkType.md @@ -9,7 +9,7 @@ title: StreamChunkType type StreamChunkType = AGUIEventType; ``` -Defined in: [packages/typescript/ai/src/types.ts:776](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L776) +Defined in: [packages/typescript/ai/src/types.ts:785](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L785) Stream chunk/event types (AG-UI protocol). diff --git a/docs/reference/type-aliases/ToolCallState.md b/docs/reference/type-aliases/ToolCallState.md index 34d82935d..a72ff5d68 100644 --- a/docs/reference/type-aliases/ToolCallState.md +++ b/docs/reference/type-aliases/ToolCallState.md @@ -14,6 +14,6 @@ type ToolCallState = | "approval-responded"; ``` -Defined in: [packages/typescript/ai/src/types.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L32) +Defined in: [packages/typescript/ai/src/types.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L33) Tool call states - track the lifecycle of a tool call diff --git a/docs/reference/type-aliases/ToolResultState.md b/docs/reference/type-aliases/ToolResultState.md index ce47f609b..0a76173d2 100644 --- a/docs/reference/type-aliases/ToolResultState.md +++ b/docs/reference/type-aliases/ToolResultState.md @@ -9,6 +9,6 @@ title: ToolResultState type ToolResultState = "streaming" | "complete" | "error"; ``` -Defined in: [packages/typescript/ai/src/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L42) +Defined in: [packages/typescript/ai/src/types.ts:43](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L43) Tool result states - track the lifecycle of a tool result diff --git a/examples/ts-react-chat/package.json b/examples/ts-react-chat/package.json index 3e1b9ca3b..60cfe6836 100644 --- a/examples/ts-react-chat/package.json +++ b/examples/ts-react-chat/package.json @@ -14,6 +14,7 @@ "@tanstack/ai-anthropic": "workspace:*", "@tanstack/ai-client": "workspace:*", "@tanstack/ai-elevenlabs": "workspace:*", + "@tanstack/ai-fal": "workspace:*", "@tanstack/ai-gemini": "workspace:*", "@tanstack/ai-grok": "workspace:*", "@tanstack/ai-groq": "workspace:*", diff --git a/examples/ts-react-chat/src/components/Header.tsx b/examples/ts-react-chat/src/components/Header.tsx index d1c432232..4cd9fc4d8 100644 --- a/examples/ts-react-chat/src/components/Header.tsx +++ b/examples/ts-react-chat/src/components/Header.tsx @@ -10,6 +10,7 @@ import { Image, Menu, Mic, + Music, Video, X, } from 'lucide-react' @@ -100,6 +101,19 @@ export default function Header() { Text-to-Speech + setIsOpen(false)} + className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-1" + activeProps={{ + className: + 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-1', + }} + > + + Audio Generation + + setIsOpen(false)} diff --git a/examples/ts-react-chat/src/lib/audio-providers.ts b/examples/ts-react-chat/src/lib/audio-providers.ts new file mode 100644 index 000000000..a3a27fe42 --- /dev/null +++ b/examples/ts-react-chat/src/lib/audio-providers.ts @@ -0,0 +1,228 @@ +/** + * Shared catalog of audio-related providers shown in the example pages. + * + * Each entry lists a display label plus the provider model we exercise so + * the UI can render consistent tabs/selectors across speech, transcription, + * and audio generation flows. + */ + +export type SpeechProviderId = 'openai' | 'gemini' | 'fal' + +export interface SpeechProviderConfig { + id: SpeechProviderId + label: string + model: string + /** Voices the UI will surface for this provider. */ + voices: ReadonlyArray<{ id: string; label: string }> + /** Placeholder shown in the text area. */ + placeholder: string +} + +export const SPEECH_PROVIDERS: ReadonlyArray = [ + { + id: 'openai', + label: 'OpenAI TTS', + model: 'tts-1', + voices: [ + { id: 'alloy', label: 'Alloy' }, + { id: 'echo', label: 'Echo' }, + { id: 'fable', label: 'Fable' }, + { id: 'onyx', label: 'Onyx' }, + { id: 'nova', label: 'Nova' }, + { id: 'shimmer', label: 'Shimmer' }, + ], + placeholder: 'Enter text to read aloud with OpenAI TTS…', + }, + { + id: 'gemini', + label: 'Gemini TTS', + model: 'gemini-2.5-flash-preview-tts', + voices: [ + { id: 'Kore', label: 'Kore' }, + { id: 'Puck', label: 'Puck' }, + { id: 'Zephyr', label: 'Zephyr' }, + ], + placeholder: 'Enter text for Gemini speech…', + }, + { + id: 'fal', + label: 'Fal (Kokoro)', + model: 'fal-ai/kokoro/american-english', + voices: [ + { id: 'af_heart', label: 'Heart' }, + { id: 'af_sky', label: 'Sky' }, + { id: 'am_adam', label: 'Adam' }, + ], + placeholder: 'Enter text to synthesize with Fal Kokoro…', + }, +] + +export type TranscriptionProviderId = 'openai' | 'fal' + +export interface TranscriptionProviderConfig { + id: TranscriptionProviderId + label: string + model: string + description: string +} + +export const TRANSCRIPTION_PROVIDERS: ReadonlyArray = + [ + { + id: 'openai', + label: 'OpenAI Whisper', + model: 'whisper-1', + description: 'OpenAI Whisper transcription with optional streaming.', + }, + { + id: 'fal', + label: 'Fal Whisper', + model: 'fal-ai/whisper', + description: 'Fal-hosted Whisper with word-level timestamps.', + }, + ] + +export type AudioProviderId = 'gemini-lyria' | 'fal-audio' | 'fal-sfx' + +export interface AudioProviderConfig { + id: AudioProviderId + label: string + /** Default model when the provider does not expose a chooser. */ + model: string + description: string + placeholder: string + /** Default generation length in seconds, when the provider accepts one. */ + defaultDuration?: number + /** Ready-made prompts the UI can offer as one-click suggestions. */ + samplePrompts: ReadonlyArray<{ label: string; prompt: string }> + /** + * Optional list of alternate models the UI can expose via a dropdown. + * By convention the entry matching {@link model} is listed first so it + * appears at the top of the selector, but nothing enforces that — the UI + * seeds the selection from {@link model} directly. + */ + models?: ReadonlyArray<{ id: string; label: string }> +} + +export const AUDIO_PROVIDERS: ReadonlyArray = [ + { + id: 'gemini-lyria', + label: 'Gemini Lyria', + model: 'lyria-3-clip-preview', + models: [ + { + id: 'lyria-3-clip-preview', + label: 'Lyria 3 Clip (30s MP3)', + }, + { + id: 'lyria-3-pro-preview', + label: 'Lyria 3 Pro (full-length MP3/WAV)', + }, + ], + description: 'Google Lyria 3 music generation.', + placeholder: 'Ambient piano with warm pads and soft strings', + samplePrompts: [ + { + label: 'Late-night jazz trio', + prompt: + 'A contemplative jazz trio with brushed drums, walking upright bass, and smoky piano chords.', + }, + { + label: 'Hero at dawn', + prompt: + 'An epic film score for a hero cresting a mountain at dawn: horns, choir, and taiko drums.', + }, + { + label: 'Haunted elevator', + prompt: + 'Cheerful 1950s elevator music, but subtly out of tune, like the elevator is haunted.', + }, + { + label: 'Polka funeral', + prompt: + 'A funeral dirge unexpectedly remixed as an upbeat accordion polka.', + }, + ], + }, + { + id: 'fal-audio', + label: 'Fal Audio', + model: 'fal-ai/elevenlabs/music', + models: [ + { id: 'fal-ai/elevenlabs/music', label: 'ElevenLabs Music' }, + { + id: 'fal-ai/stable-audio-25/text-to-audio', + label: 'Stable Audio 2.5', + }, + { + id: 'fal-ai/ace-step/prompt-to-audio', + label: 'ACE-Step (prompt-to-audio)', + }, + ], + description: 'Fal-hosted open music generation models.', + placeholder: 'A lo-fi hip-hop beat with vinyl crackle', + defaultDuration: 10, + samplePrompts: [ + { + label: 'Lo-fi study beat', + prompt: + 'A mellow lo-fi hip-hop beat with warm vinyl crackle, dusty Rhodes chords, and soft swing.', + }, + { + label: 'Ambient drone', + prompt: + 'A slow ambient drone with shimmering reverb, distant field recordings, and evolving pads.', + }, + { + label: 'Seagull Eurovision', + prompt: + 'A Eurovision-style power ballad performed entirely by a choir of disgruntled seagulls.', + }, + { + label: 'Hydrophobic pirate', + prompt: + 'The rousing theme song for a swashbuckling pirate who is terrified of water.', + }, + { + label: 'Death metal laundry', + prompt: + 'A death metal ballad about losing your favorite socks in the dryer, complete with guttural vocals.', + }, + ], + }, + { + id: 'fal-sfx', + label: 'Fal SFX', + model: 'fal-ai/mmaudio-v2/text-to-audio', + models: [ + { + id: 'fal-ai/mmaudio-v2/text-to-audio', + label: 'MMAudio v2 Text-to-Audio', + }, + ], + description: 'Fal-hosted text-to-SFX models for short sound effects.', + placeholder: 'Glass shattering on a tile floor', + defaultDuration: 5, + samplePrompts: [ + { + label: 'Rain on tin roof', + prompt: 'Steady rain pattering on a corrugated metal roof at night.', + }, + { + label: 'Marble hallway steps', + prompt: + 'Slow leather-soled footsteps echoing through an empty marble hallway.', + }, + { + label: 'Interrogated duck', + prompt: + 'A rubber duck being dramatically interrogated under a swinging lamp, squeaks only.', + }, + { + label: 'Cartoon banana slip', + prompt: + 'Classic cartoon banana slip: quick slide, comedic boing, and a distant crash.', + }, + ], + }, +] diff --git a/examples/ts-react-chat/src/lib/server-audio-adapters.ts b/examples/ts-react-chat/src/lib/server-audio-adapters.ts new file mode 100644 index 000000000..1248c5301 --- /dev/null +++ b/examples/ts-react-chat/src/lib/server-audio-adapters.ts @@ -0,0 +1,86 @@ +/** + * Server-side adapter factories for the audio example pages. + * + * Keeping these in one place lets the HTTP routes and the TanStack Start server + * functions share the same model choices without duplicating provider wiring. + */ + +import { openaiSpeech, openaiTranscription } from '@tanstack/ai-openai' +import { geminiAudio, geminiSpeech } from '@tanstack/ai-gemini' +import { falAudio, falSpeech, falTranscription } from '@tanstack/ai-fal' +import type { + AnyAudioAdapter, + AnyTranscriptionAdapter, + AnyTTSAdapter, +} from '@tanstack/ai' +import { + AUDIO_PROVIDERS, + SPEECH_PROVIDERS, + TRANSCRIPTION_PROVIDERS, + type AudioProviderId, + type SpeechProviderId, + type TranscriptionProviderId, +} from './audio-providers' + +function findConfig( + list: ReadonlyArray, + id: string, +): T { + const match = list.find((entry) => entry.id === id) + if (!match) throw new Error(`Unknown provider: ${id}`) + return match +} + +export function buildSpeechAdapter(provider: SpeechProviderId): AnyTTSAdapter { + const config = findConfig(SPEECH_PROVIDERS, provider) + switch (config.id) { + case 'openai': + return openaiSpeech(config.model as 'tts-1') + case 'gemini': + return geminiSpeech(config.model as 'gemini-2.5-flash-preview-tts') + case 'fal': + return falSpeech(config.model) + } +} + +export function buildTranscriptionAdapter( + provider: TranscriptionProviderId, +): AnyTranscriptionAdapter { + const config = findConfig(TRANSCRIPTION_PROVIDERS, provider) + switch (config.id) { + case 'openai': + return openaiTranscription(config.model as 'whisper-1') + case 'fal': + return falTranscription(config.model) + } +} + +export function buildAudioAdapter( + provider: AudioProviderId, + modelOverride?: string, +): AnyAudioAdapter { + const config = findConfig(AUDIO_PROVIDERS, provider) + const model = resolveModel(config, modelOverride) + switch (config.id) { + case 'gemini-lyria': + return geminiAudio( + model as 'lyria-3-clip-preview' | 'lyria-3-pro-preview', + ) + case 'fal-audio': + case 'fal-sfx': + return falAudio(model) + } +} + +function resolveModel( + config: (typeof AUDIO_PROVIDERS)[number], + modelOverride: string | undefined, +): string { + if (!modelOverride) return config.model + const allowed = config.models?.some((m) => m.id === modelOverride) + if (allowed) return modelOverride + console.warn( + `[audio] rejected model override "${modelOverride}" for provider "${config.id}"; falling back to "${config.model}"`, + ) + return config.model +} diff --git a/examples/ts-react-chat/src/lib/server-fns.ts b/examples/ts-react-chat/src/lib/server-fns.ts index 624de8e89..156db532e 100644 --- a/examples/ts-react-chat/src/lib/server-fns.ts +++ b/examples/ts-react-chat/src/lib/server-fns.ts @@ -1,6 +1,7 @@ import { createServerFn } from '@tanstack/react-start' import { z } from 'zod' import { + generateAudio, generateImage, generateSpeech, generateTranscription, @@ -9,13 +10,20 @@ import { summarize, toServerSentEventsResponse, } from '@tanstack/ai' +import { openaiImage, openaiSummarize, openaiVideo } from '@tanstack/ai-openai' import { - openaiImage, - openaiSpeech, - openaiTranscription, - openaiSummarize, - openaiVideo, -} from '@tanstack/ai-openai' + buildAudioAdapter, + buildSpeechAdapter, + buildTranscriptionAdapter, +} from './server-audio-adapters' + +const SPEECH_PROVIDER_SCHEMA = z.enum(['openai', 'gemini', 'fal']).optional() + +const TRANSCRIPTION_PROVIDER_SCHEMA = z.enum(['openai', 'fal']).optional() + +const AUDIO_PROVIDER_SCHEMA = z + .enum(['gemini-lyria', 'fal-audio', 'fal-sfx']) + .optional() // ============================================================================= // Direct server functions (non-streaming, return the result directly) @@ -44,11 +52,12 @@ export const generateSpeechFn = createServerFn({ method: 'POST' }) text: z.string(), voice: z.string().optional(), format: z.enum(['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm']).optional(), + provider: SPEECH_PROVIDER_SCHEMA, }), ) .handler(async ({ data }) => { return generateSpeech({ - adapter: openaiSpeech('tts-1'), + adapter: buildSpeechAdapter(data.provider ?? 'openai'), text: data.text, voice: data.voice, format: data.format, @@ -60,16 +69,34 @@ export const transcribeFn = createServerFn({ method: 'POST' }) z.object({ audio: z.string(), language: z.string().optional(), + provider: TRANSCRIPTION_PROVIDER_SCHEMA, }), ) .handler(async ({ data }) => { return generateTranscription({ - adapter: openaiTranscription('whisper-1'), + adapter: buildTranscriptionAdapter(data.provider ?? 'openai'), audio: data.audio, language: data.language, }) }) +export const generateAudioFn = createServerFn({ method: 'POST' }) + .inputValidator( + z.object({ + prompt: z.string(), + duration: z.number().optional(), + provider: AUDIO_PROVIDER_SCHEMA, + model: z.string().optional(), + }), + ) + .handler(async ({ data }) => { + return generateAudio({ + adapter: buildAudioAdapter(data.provider ?? 'gemini-lyria', data.model), + prompt: data.prompt, + duration: data.duration, + }) + }) + export const summarizeFn = createServerFn({ method: 'POST' }) .inputValidator( z.object({ @@ -164,12 +191,13 @@ export const generateSpeechStreamFn = createServerFn({ method: 'POST' }) text: z.string(), voice: z.string().optional(), format: z.enum(['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm']).optional(), + provider: SPEECH_PROVIDER_SCHEMA, }), ) .handler(({ data }) => { return toServerSentEventsResponse( generateSpeech({ - adapter: openaiSpeech('tts-1'), + adapter: buildSpeechAdapter(data.provider ?? 'openai'), text: data.text, voice: data.voice, format: data.format, @@ -183,12 +211,13 @@ export const transcribeStreamFn = createServerFn({ method: 'POST' }) z.object({ audio: z.string(), language: z.string().optional(), + provider: TRANSCRIPTION_PROVIDER_SCHEMA, }), ) .handler(({ data }) => { return toServerSentEventsResponse( generateTranscription({ - adapter: openaiTranscription('whisper-1'), + adapter: buildTranscriptionAdapter(data.provider ?? 'openai'), audio: data.audio, language: data.language, stream: true, diff --git a/examples/ts-react-chat/src/routeTree.gen.ts b/examples/ts-react-chat/src/routeTree.gen.ts index f0a2fab4b..f9b2ac825 100644 --- a/examples/ts-react-chat/src/routeTree.gen.ts +++ b/examples/ts-react-chat/src/routeTree.gen.ts @@ -18,6 +18,7 @@ import { Route as GenerationsSummarizeRouteImport } from './routes/generations.s import { Route as GenerationsStructuredOutputRouteImport } from './routes/generations.structured-output' import { Route as GenerationsSpeechRouteImport } from './routes/generations.speech' import { Route as GenerationsImageRouteImport } from './routes/generations.image' +import { Route as GenerationsAudioRouteImport } from './routes/generations.audio' import { Route as ApiTranscribeRouteImport } from './routes/api.transcribe' import { Route as ApiTanchatRouteImport } from './routes/api.tanchat' import { Route as ApiSummarizeRouteImport } from './routes/api.summarize' @@ -28,6 +29,7 @@ import { Route as ExampleGuitarsGuitarIdRouteImport } from './routes/example.gui import { Route as ApiGenerateVideoRouteImport } from './routes/api.generate.video' import { Route as ApiGenerateSpeechRouteImport } from './routes/api.generate.speech' import { Route as ApiGenerateImageRouteImport } from './routes/api.generate.image' +import { Route as ApiGenerateAudioRouteImport } from './routes/api.generate.audio' const RealtimeRoute = RealtimeRouteImport.update({ id: '/realtime', @@ -76,6 +78,11 @@ const GenerationsImageRoute = GenerationsImageRouteImport.update({ path: '/generations/image', getParentRoute: () => rootRouteImport, } as any) +const GenerationsAudioRoute = GenerationsAudioRouteImport.update({ + id: '/generations/audio', + path: '/generations/audio', + getParentRoute: () => rootRouteImport, +} as any) const ApiTranscribeRoute = ApiTranscribeRouteImport.update({ id: '/api/transcribe', path: '/api/transcribe', @@ -126,6 +133,11 @@ const ApiGenerateImageRoute = ApiGenerateImageRouteImport.update({ path: '/api/generate/image', getParentRoute: () => rootRouteImport, } as any) +const ApiGenerateAudioRoute = ApiGenerateAudioRouteImport.update({ + id: '/api/generate/audio', + path: '/api/generate/audio', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -136,12 +148,14 @@ export interface FileRoutesByFullPath { '/api/summarize': typeof ApiSummarizeRoute '/api/tanchat': typeof ApiTanchatRoute '/api/transcribe': typeof ApiTranscribeRoute + '/generations/audio': typeof GenerationsAudioRoute '/generations/image': typeof GenerationsImageRoute '/generations/speech': typeof GenerationsSpeechRoute '/generations/structured-output': typeof GenerationsStructuredOutputRoute '/generations/summarize': typeof GenerationsSummarizeRoute '/generations/transcription': typeof GenerationsTranscriptionRoute '/generations/video': typeof GenerationsVideoRoute + '/api/generate/audio': typeof ApiGenerateAudioRoute '/api/generate/image': typeof ApiGenerateImageRoute '/api/generate/speech': typeof ApiGenerateSpeechRoute '/api/generate/video': typeof ApiGenerateVideoRoute @@ -157,12 +171,14 @@ export interface FileRoutesByTo { '/api/summarize': typeof ApiSummarizeRoute '/api/tanchat': typeof ApiTanchatRoute '/api/transcribe': typeof ApiTranscribeRoute + '/generations/audio': typeof GenerationsAudioRoute '/generations/image': typeof GenerationsImageRoute '/generations/speech': typeof GenerationsSpeechRoute '/generations/structured-output': typeof GenerationsStructuredOutputRoute '/generations/summarize': typeof GenerationsSummarizeRoute '/generations/transcription': typeof GenerationsTranscriptionRoute '/generations/video': typeof GenerationsVideoRoute + '/api/generate/audio': typeof ApiGenerateAudioRoute '/api/generate/image': typeof ApiGenerateImageRoute '/api/generate/speech': typeof ApiGenerateSpeechRoute '/api/generate/video': typeof ApiGenerateVideoRoute @@ -179,12 +195,14 @@ export interface FileRoutesById { '/api/summarize': typeof ApiSummarizeRoute '/api/tanchat': typeof ApiTanchatRoute '/api/transcribe': typeof ApiTranscribeRoute + '/generations/audio': typeof GenerationsAudioRoute '/generations/image': typeof GenerationsImageRoute '/generations/speech': typeof GenerationsSpeechRoute '/generations/structured-output': typeof GenerationsStructuredOutputRoute '/generations/summarize': typeof GenerationsSummarizeRoute '/generations/transcription': typeof GenerationsTranscriptionRoute '/generations/video': typeof GenerationsVideoRoute + '/api/generate/audio': typeof ApiGenerateAudioRoute '/api/generate/image': typeof ApiGenerateImageRoute '/api/generate/speech': typeof ApiGenerateSpeechRoute '/api/generate/video': typeof ApiGenerateVideoRoute @@ -202,12 +220,14 @@ export interface FileRouteTypes { | '/api/summarize' | '/api/tanchat' | '/api/transcribe' + | '/generations/audio' | '/generations/image' | '/generations/speech' | '/generations/structured-output' | '/generations/summarize' | '/generations/transcription' | '/generations/video' + | '/api/generate/audio' | '/api/generate/image' | '/api/generate/speech' | '/api/generate/video' @@ -223,12 +243,14 @@ export interface FileRouteTypes { | '/api/summarize' | '/api/tanchat' | '/api/transcribe' + | '/generations/audio' | '/generations/image' | '/generations/speech' | '/generations/structured-output' | '/generations/summarize' | '/generations/transcription' | '/generations/video' + | '/api/generate/audio' | '/api/generate/image' | '/api/generate/speech' | '/api/generate/video' @@ -244,12 +266,14 @@ export interface FileRouteTypes { | '/api/summarize' | '/api/tanchat' | '/api/transcribe' + | '/generations/audio' | '/generations/image' | '/generations/speech' | '/generations/structured-output' | '/generations/summarize' | '/generations/transcription' | '/generations/video' + | '/api/generate/audio' | '/api/generate/image' | '/api/generate/speech' | '/api/generate/video' @@ -266,12 +290,14 @@ export interface RootRouteChildren { ApiSummarizeRoute: typeof ApiSummarizeRoute ApiTanchatRoute: typeof ApiTanchatRoute ApiTranscribeRoute: typeof ApiTranscribeRoute + GenerationsAudioRoute: typeof GenerationsAudioRoute GenerationsImageRoute: typeof GenerationsImageRoute GenerationsSpeechRoute: typeof GenerationsSpeechRoute GenerationsStructuredOutputRoute: typeof GenerationsStructuredOutputRoute GenerationsSummarizeRoute: typeof GenerationsSummarizeRoute GenerationsTranscriptionRoute: typeof GenerationsTranscriptionRoute GenerationsVideoRoute: typeof GenerationsVideoRoute + ApiGenerateAudioRoute: typeof ApiGenerateAudioRoute ApiGenerateImageRoute: typeof ApiGenerateImageRoute ApiGenerateSpeechRoute: typeof ApiGenerateSpeechRoute ApiGenerateVideoRoute: typeof ApiGenerateVideoRoute @@ -344,6 +370,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof GenerationsImageRouteImport parentRoute: typeof rootRouteImport } + '/generations/audio': { + id: '/generations/audio' + path: '/generations/audio' + fullPath: '/generations/audio' + preLoaderRoute: typeof GenerationsAudioRouteImport + parentRoute: typeof rootRouteImport + } '/api/transcribe': { id: '/api/transcribe' path: '/api/transcribe' @@ -414,6 +447,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof ApiGenerateImageRouteImport parentRoute: typeof rootRouteImport } + '/api/generate/audio': { + id: '/api/generate/audio' + path: '/api/generate/audio' + fullPath: '/api/generate/audio' + preLoaderRoute: typeof ApiGenerateAudioRouteImport + parentRoute: typeof rootRouteImport + } } } @@ -426,12 +466,14 @@ const rootRouteChildren: RootRouteChildren = { ApiSummarizeRoute: ApiSummarizeRoute, ApiTanchatRoute: ApiTanchatRoute, ApiTranscribeRoute: ApiTranscribeRoute, + GenerationsAudioRoute: GenerationsAudioRoute, GenerationsImageRoute: GenerationsImageRoute, GenerationsSpeechRoute: GenerationsSpeechRoute, GenerationsStructuredOutputRoute: GenerationsStructuredOutputRoute, GenerationsSummarizeRoute: GenerationsSummarizeRoute, GenerationsTranscriptionRoute: GenerationsTranscriptionRoute, GenerationsVideoRoute: GenerationsVideoRoute, + ApiGenerateAudioRoute: ApiGenerateAudioRoute, ApiGenerateImageRoute: ApiGenerateImageRoute, ApiGenerateSpeechRoute: ApiGenerateSpeechRoute, ApiGenerateVideoRoute: ApiGenerateVideoRoute, diff --git a/examples/ts-react-chat/src/routes/api.generate.audio.ts b/examples/ts-react-chat/src/routes/api.generate.audio.ts new file mode 100644 index 000000000..23282cc0e --- /dev/null +++ b/examples/ts-react-chat/src/routes/api.generate.audio.ts @@ -0,0 +1,78 @@ +import { createFileRoute } from '@tanstack/react-router' +import { generateAudio, toServerSentEventsResponse } from '@tanstack/ai' +import { z } from 'zod' +import { buildAudioAdapter } from '../lib/server-audio-adapters' + +const AUDIO_PROVIDER_SCHEMA = z + .enum(['gemini-lyria', 'fal-audio', 'fal-sfx']) + .optional() + +const AUDIO_BODY_SCHEMA = z.object({ + prompt: z.string().min(1), + duration: z.number().optional(), + provider: AUDIO_PROVIDER_SCHEMA, + model: z.string().optional(), +}) + +function jsonError(status: number, payload: Record) { + return new Response(JSON.stringify(payload), { + status, + headers: { 'content-type': 'application/json' }, + }) +} + +export const Route = createFileRoute('/api/generate/audio')({ + server: { + handlers: { + POST: async ({ request }) => { + let body: unknown + try { + body = await request.json() + } catch { + return jsonError(400, { + error: 'invalid_json', + message: 'Request body must be valid JSON', + }) + } + + const rawData = (body as { data?: unknown } | null)?.data + if (rawData == null) { + return jsonError(400, { + error: 'missing_data', + message: 'Request body must include a `data` field', + }) + } + + const parsed = AUDIO_BODY_SCHEMA.safeParse(rawData) + if (!parsed.success) { + return jsonError(400, { + error: 'validation_failed', + message: 'Request data failed validation', + details: z.treeifyError(parsed.error), + }) + } + + const { prompt, duration, provider, model } = parsed.data + + try { + const adapter = buildAudioAdapter(provider ?? 'gemini-lyria', model) + + const stream = generateAudio({ + adapter, + prompt, + duration, + stream: true, + }) + + return toServerSentEventsResponse(stream) + } catch (err) { + return jsonError(500, { + error: 'generation_failed', + message: + err instanceof Error ? err.message : 'Audio generation failed', + }) + } + }, + }, + }, +}) diff --git a/examples/ts-react-chat/src/routes/api.generate.speech.ts b/examples/ts-react-chat/src/routes/api.generate.speech.ts index 47ec75227..12a621d3b 100644 --- a/examples/ts-react-chat/src/routes/api.generate.speech.ts +++ b/examples/ts-react-chat/src/routes/api.generate.speech.ts @@ -1,23 +1,76 @@ import { createFileRoute } from '@tanstack/react-router' import { generateSpeech, toServerSentEventsResponse } from '@tanstack/ai' -import { openaiSpeech } from '@tanstack/ai-openai' +import { z } from 'zod' +import { buildSpeechAdapter } from '../lib/server-audio-adapters' + +const SPEECH_PROVIDER_SCHEMA = z.enum(['openai', 'gemini', 'fal']).optional() + +const SPEECH_BODY_SCHEMA = z.object({ + text: z.string().min(1), + voice: z.string().optional(), + format: z.enum(['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm']).optional(), + provider: SPEECH_PROVIDER_SCHEMA, +}) + +function jsonError(status: number, payload: Record) { + return new Response(JSON.stringify(payload), { + status, + headers: { 'content-type': 'application/json' }, + }) +} export const Route = createFileRoute('/api/generate/speech')({ server: { handlers: { POST: async ({ request }) => { - const body = await request.json() - const { text, voice, format, model } = body.data - - const stream = generateSpeech({ - adapter: openaiSpeech(model ?? 'tts-1'), - text, - voice, - format, - stream: true, - }) - - return toServerSentEventsResponse(stream) + let body: unknown + try { + body = await request.json() + } catch { + return jsonError(400, { + error: 'invalid_json', + message: 'Request body must be valid JSON', + }) + } + + const rawData = (body as { data?: unknown } | null)?.data + if (rawData == null) { + return jsonError(400, { + error: 'missing_data', + message: 'Request body must include a `data` field', + }) + } + + const parsed = SPEECH_BODY_SCHEMA.safeParse(rawData) + if (!parsed.success) { + return jsonError(400, { + error: 'validation_failed', + message: 'Request data failed validation', + details: z.treeifyError(parsed.error), + }) + } + + const { text, voice, format, provider } = parsed.data + + try { + const adapter = buildSpeechAdapter(provider ?? 'openai') + + const stream = generateSpeech({ + adapter, + text, + voice, + format, + stream: true, + }) + + return toServerSentEventsResponse(stream) + } catch (err) { + return jsonError(500, { + error: 'generation_failed', + message: + err instanceof Error ? err.message : 'Speech generation failed', + }) + } }, }, }, diff --git a/examples/ts-react-chat/src/routes/api.transcribe.ts b/examples/ts-react-chat/src/routes/api.transcribe.ts index 56f9c7aeb..37e76ea7f 100644 --- a/examples/ts-react-chat/src/routes/api.transcribe.ts +++ b/examples/ts-react-chat/src/routes/api.transcribe.ts @@ -1,22 +1,74 @@ import { createFileRoute } from '@tanstack/react-router' import { generateTranscription, toServerSentEventsResponse } from '@tanstack/ai' -import { openaiTranscription } from '@tanstack/ai-openai' +import { z } from 'zod' +import { buildTranscriptionAdapter } from '../lib/server-audio-adapters' + +const TRANSCRIPTION_PROVIDER_SCHEMA = z.enum(['openai', 'fal']).optional() + +const TRANSCRIBE_BODY_SCHEMA = z.object({ + audio: z.string().min(1), + language: z.string().optional(), + provider: TRANSCRIPTION_PROVIDER_SCHEMA, +}) + +function jsonError(status: number, payload: Record) { + return new Response(JSON.stringify(payload), { + status, + headers: { 'content-type': 'application/json' }, + }) +} export const Route = createFileRoute('/api/transcribe')({ server: { handlers: { POST: async ({ request }) => { - const body = await request.json() - const { audio, language, model } = body.data + let body: unknown + try { + body = await request.json() + } catch { + return jsonError(400, { + error: 'invalid_json', + message: 'Request body must be valid JSON', + }) + } + + const rawData = (body as { data?: unknown } | null)?.data + if (rawData == null) { + return jsonError(400, { + error: 'missing_data', + message: 'Request body must include a `data` field', + }) + } + + const parsed = TRANSCRIBE_BODY_SCHEMA.safeParse(rawData) + if (!parsed.success) { + return jsonError(400, { + error: 'validation_failed', + message: 'Request data failed validation', + details: z.treeifyError(parsed.error), + }) + } + + const { audio, language, provider } = parsed.data + + try { + const adapter = buildTranscriptionAdapter(provider ?? 'openai') - const stream = generateTranscription({ - adapter: openaiTranscription(model ?? 'whisper-1'), - audio, - language, - stream: true, - }) + const stream = generateTranscription({ + adapter, + audio, + language, + stream: true, + }) - return toServerSentEventsResponse(stream) + return toServerSentEventsResponse(stream) + } catch (err) { + return jsonError(500, { + error: 'transcription_failed', + message: + err instanceof Error ? err.message : 'Transcription failed', + }) + } }, }, }, diff --git a/examples/ts-react-chat/src/routes/generations.audio.tsx b/examples/ts-react-chat/src/routes/generations.audio.tsx new file mode 100644 index 000000000..757278e73 --- /dev/null +++ b/examples/ts-react-chat/src/routes/generations.audio.tsx @@ -0,0 +1,359 @@ +import { useEffect, useMemo, useRef, useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useGenerateAudio } from '@tanstack/ai-react' +import type { UseGenerateAudioReturn } from '@tanstack/ai-react' +import { fetchServerSentEvents } from '@tanstack/ai-client' +import type { AudioGenerationResult } from '@tanstack/ai' +import { generateAudioFn } from '../lib/server-fns' +import { + AUDIO_PROVIDERS, + type AudioProviderConfig, + type AudioProviderId, +} from '../lib/audio-providers' + +type Mode = 'hooks' | 'server-fn' + +interface AudioOutput { + url: string + contentType?: string + duration?: number + model: string +} + +/** + * Map an AudioGenerationResult to the UI-friendly shape. Returns `null` + * when the result has neither `url` nor `b64Json` — per the `onResult` + * contract, a `null` return tells the hook to keep the previous result + * and the real failure is surfaced via `onError` / the hook's error state. + */ +function toAudioOutput(raw: AudioGenerationResult): AudioOutput | null { + const { audio } = raw + if (audio.url) { + return { + url: audio.url, + contentType: audio.contentType, + duration: audio.duration, + model: raw.model, + } + } + if (audio.b64Json) { + const binary = atob(audio.b64Json) + const bytes = new Uint8Array(binary.length) + for (let i = 0; i < binary.length; i++) { + bytes[i] = binary.charCodeAt(i) + } + const blob = new Blob([bytes], { + type: audio.contentType ?? 'audio/mpeg', + }) + return { + url: URL.createObjectURL(blob), + contentType: audio.contentType, + duration: audio.duration, + model: raw.model, + } + } + // Don't throw — that bypasses the hook's error plumbing. Return null so + // the hook keeps the previous result unchanged; callers can rely on the + // `error` state (populated via `onError`) if they want to surface this. + return null +} + +function AudioGenerationForm({ + mode, + config, +}: { + mode: Mode + config: AudioProviderConfig +}) { + const [prompt, setPrompt] = useState('') + const [duration, setDuration] = useState( + config.defaultDuration, + ) + const [selectedModel, setSelectedModel] = useState(config.model) + + const hookOptions = useMemo(() => { + if (mode === 'hooks') { + return { + connection: fetchServerSentEvents('/api/generate/audio'), + body: { provider: config.id, model: selectedModel }, + onResult: toAudioOutput, + } + } + return { + fetcher: (input: { prompt: string; duration?: number }) => + generateAudioFn({ + data: { ...input, provider: config.id, model: selectedModel }, + }), + onResult: toAudioOutput, + } + }, [mode, config.id, selectedModel]) + + const hookReturn = useGenerateAudio(hookOptions) + + return ( + + ) +} + +function AudioGenerationUI({ + config, + prompt, + setPrompt, + duration, + setDuration, + selectedModel, + setSelectedModel, + generate, + result, + isLoading, + error, + reset, +}: UseGenerateAudioReturn & { + config: AudioProviderConfig + prompt: string + setPrompt: (v: string) => void + duration: number | undefined + setDuration: (v: number | undefined) => void + selectedModel: string + setSelectedModel: (v: string) => void +}) { + const handleGenerate = () => { + if (!prompt.trim()) return + generate({ prompt: prompt.trim(), duration }) + } + + // Track the last object URL we created so we can revoke it when the + // result changes, reset is invoked, or the component unmounts. + const lastBlobUrlRef = useRef(null) + useEffect(() => { + const current = result?.url + // Only track blob: URLs — remote URLs returned directly by providers + // are not ours to revoke. + if (current && current.startsWith('blob:')) { + if (lastBlobUrlRef.current && lastBlobUrlRef.current !== current) { + URL.revokeObjectURL(lastBlobUrlRef.current) + } + lastBlobUrlRef.current = current + } else if (!current && lastBlobUrlRef.current) { + URL.revokeObjectURL(lastBlobUrlRef.current) + lastBlobUrlRef.current = null + } + }, [result?.url]) + useEffect(() => { + return () => { + if (lastBlobUrlRef.current) { + URL.revokeObjectURL(lastBlobUrlRef.current) + lastBlobUrlRef.current = null + } + } + }, []) + + return ( +
+
+ {config.models && config.models.length > 1 ? ( +
+ + +
+ ) : ( +

+ Model: {config.model} +

+ )} +

{config.description}

+
+ +
+ +