Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 12 additions & 31 deletions docs/adapters/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ const stream = chat({
import { chat } from "@tanstack/ai";
import { createAnthropicChat } from "@tanstack/ai-anthropic";

const adapter = createAnthropicChat(process.env.ANTHROPIC_API_KEY!, {
const adapter = createAnthropicChat("claude-sonnet-4-5", process.env.ANTHROPIC_API_KEY!, {
// ... your config options
});

const stream = chat({
adapter: adapter("claude-sonnet-4-5"),
adapter,
messages: [{ role: "user", content: "Hello!" }],
});
```

## Configuration

```typescript
import { createAnthropicChat, type AnthropicChatConfig } from "@tanstack/ai-anthropic";
import { createAnthropicChat, type AnthropicTextConfig } from "@tanstack/ai-anthropic";

const config: Omit<AnthropicChatConfig, 'apiKey'> = {
const config: Omit<AnthropicTextConfig, "apiKey"> = {
baseURL: "https://api.anthropic.com", // Optional, for custom endpoints
};

const adapter = createAnthropicChat(process.env.ANTHROPIC_API_KEY!, config);
const adapter = createAnthropicChat("claude-sonnet-4-5", process.env.ANTHROPIC_API_KEY!, config);
```


Expand Down Expand Up @@ -194,39 +194,20 @@ ANTHROPIC_API_KEY=sk-ant-...

## API Reference

### `anthropicText(config?)`
Every factory pair follows the same shape: the short factory (`anthropicText`, `anthropicSummarize`) reads `ANTHROPIC_API_KEY` from the environment, while `createAnthropicChat` / `createAnthropicSummarize` take an explicit API key. Both take `model` as the first argument.

Creates an Anthropic chat adapter using environment variables.
### `anthropicText(model, config?)` / `createAnthropicChat(model, apiKey, config?)`

**Returns:** An Anthropic chat adapter instance.

### `createAnthropicChat(apiKey, config?)`

Creates an Anthropic chat adapter with an explicit API key.
Creates an Anthropic chat adapter.

**Parameters:**

- `apiKey` - Your Anthropic API key
- `config.baseURL?` - Custom base URL (optional)

**Returns:** An Anthropic chat adapter instance.

### `anthropicSummarize(config?)`

Creates an Anthropic summarization adapter using environment variables.

**Returns:** An Anthropic summarize adapter instance.

### `createAnthropicSummarize(apiKey, config?)`

Creates an Anthropic summarization adapter with an explicit API key.

**Parameters:**
- `model` - Claude model id (e.g. `"claude-sonnet-4-5"`, `"claude-opus-4-6"`)
- `config?.baseURL` - Custom base URL (optional)

- `apiKey` - Your Anthropic API key
- `config.baseURL?` - Custom base URL (optional)
### `anthropicSummarize(model, config?)` / `createAnthropicSummarize(model, apiKey, config?)`

**Returns:** An Anthropic summarize adapter instance.
Creates an Anthropic summarization adapter.

## Limitations

Expand Down
90 changes: 82 additions & 8 deletions docs/adapters/elevenlabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ keywords:
- adapter
---

The ElevenLabs adapter provides realtime conversational voice AI for TanStack AI. Unlike text-focused adapters, the ElevenLabs adapter is **voice-focused** -- it integrates with TanStack AI's realtime system to enable voice-to-voice conversations. It does not support `chat()`, `embedding()`, or `summarize()`.
The ElevenLabs adapter is **voice-focused**. It exposes four capabilities:

ElevenLabs uses an **agent-based architecture** where you configure your conversational AI agent in the [ElevenLabs dashboard](https://elevenlabs.io/) (voice, personality, knowledge base, tools) and then connect to it at runtime. The adapter wraps the `@11labs/client` SDK for seamless integration with `useRealtimeChat` and `RealtimeClient`.
- **Realtime voice agents** (`elevenlabsRealtime` / `elevenlabsRealtimeToken`) — full-duplex voice-to-voice conversations powered by ElevenLabs Conversational AI agents.
- **Text-to-speech** (`elevenlabsSpeech`) — one-shot speech generation via `generateSpeech()`.
- **Music & sound effects** (`elevenlabsAudio`) — one-shot audio generation via `generateAudio()`.
- **Transcription** (`elevenlabsTranscription`) — speech-to-text via `generateTranscription()`.

It does not support text `chat()` or `summarize()` — use OpenAI, Anthropic, or Gemini for those.

The realtime adapter uses an **agent-based architecture** where you configure your conversational AI agent in the [ElevenLabs dashboard](https://elevenlabs.io/) (voice, personality, knowledge base, tools) and then connect to it at runtime. The adapter wraps the `@11labs/client` SDK for seamless integration with `useRealtimeChat` and `RealtimeClient`.

## Installation

Expand Down Expand Up @@ -252,6 +259,61 @@ ELEVENLABS_AGENT_ID=your-agent-id

Get your API key from the [ElevenLabs dashboard](https://elevenlabs.io/). Create and configure agents in the **Conversational AI** section of the dashboard.

## Text-to-Speech

For one-shot speech generation (not realtime), use `elevenlabsSpeech` with `generateSpeech()`:

```typescript
import { generateSpeech } from "@tanstack/ai";
import { elevenlabsSpeech } from "@tanstack/ai-elevenlabs";

const result = await generateSpeech({
adapter: elevenlabsSpeech("eleven_v3"),
text: "Hello from ElevenLabs!",
voice: "Rachel",
format: "mp3",
});

console.log(result.audio); // Base64-encoded audio
```

## Music & Sound Effects

`elevenlabsAudio` covers both music generation and sound effects depending on the model:

```typescript
import { generateAudio } from "@tanstack/ai";
import { elevenlabsAudio } from "@tanstack/ai-elevenlabs";

// Music generation
const music = await generateAudio({
adapter: elevenlabsAudio("music_v1"),
prompt: "An upbeat synthwave track for a product launch",
});

// Sound effects
const sfx = await generateAudio({
adapter: elevenlabsAudio("sound_effects_v1"),
prompt: "A glass shattering on concrete",
});
```

## Transcription

Transcribe audio with `elevenlabsTranscription`:

```typescript
import { generateTranscription } from "@tanstack/ai";
import { elevenlabsTranscription } from "@tanstack/ai-elevenlabs";

const result = await generateTranscription({
adapter: elevenlabsTranscription("scribe_v1"),
audio: audioFile,
});

console.log(result.text);
```

## API Reference

### `elevenlabsRealtimeToken(options)`
Expand Down Expand Up @@ -279,14 +341,26 @@ Creates an ElevenLabs realtime client adapter for use with `useRealtimeChat` or

**Returns:** A `RealtimeAdapter` for use with `useRealtimeChat()` or `RealtimeClient`.

### `elevenlabsSpeech(model, config?)` / `createElevenLabsSpeech(model, apiKey, config?)`

Creates an ElevenLabs text-to-speech adapter for use with `generateSpeech()`.

### `elevenlabsAudio(model, config?)` / `createElevenLabsAudio(model, apiKey, config?)`

Creates an ElevenLabs audio adapter that covers both music generation and sound effects (selected via the model id) for use with `generateAudio()`.

### `elevenlabsTranscription(model, config?)` / `createElevenLabsTranscription(model, apiKey, config?)`

Creates an ElevenLabs transcription adapter for use with `generateTranscription()`.

## Limitations

- **No text chat support** -- Use OpenAI, Anthropic, Gemini, or another text adapter for `chat()`
- **No embeddings or summarization** -- Use a text adapter for `embedding()` or `summarize()`
- **No image input** -- ElevenLabs realtime does not support sending images during a conversation
- **No runtime session updates** -- Session configuration is fixed at connection time
- **No time-domain audio data** -- Frequency data and volume levels are available, but waveform data is not
- **Agent required** -- You must create and configure an agent in the ElevenLabs dashboard before using this adapter
- **No text chat support** -- Use OpenAI, Anthropic, Gemini, or another text adapter for `chat()`.
- **No summarization** -- Use a text adapter for `summarize()`.
- **No image input** (realtime) -- ElevenLabs realtime does not support sending images during a conversation.
- **No runtime session updates** (realtime) -- Session configuration is fixed at connection time.
- **No time-domain audio data** (realtime) -- Frequency data and volume levels are available, but waveform data is not.
- **Agent required** (realtime) -- You must create and configure an agent in the ElevenLabs dashboard before using the realtime adapter.

## Next Steps

Expand Down
8 changes: 0 additions & 8 deletions docs/adapters/fal.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,6 @@ Creates a fal.ai image adapter using the `FAL_KEY` environment variable or an ex

**Returns:** A `FalImageAdapter` instance for use with `generateImage()`.

### `createFalImage(model, config?)`

Alias for `falImage()`.

### `falVideo(model, config?)`

Creates a fal.ai video adapter using the `FAL_KEY` environment variable or an explicit config.
Expand All @@ -421,10 +417,6 @@ Creates a fal.ai video adapter using the `FAL_KEY` environment variable or an ex

**Returns:** A `FalVideoAdapter` instance for use with `generateVideo()` and `getVideoJobStatus()`.

### `createFalVideo(model, config?)`

Alias for `falVideo()`.

### `falSpeech(model, config?)`

Creates a fal.ai text-to-speech adapter.
Expand Down
73 changes: 18 additions & 55 deletions docs/adapters/gemini.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ const stream = chat({
import { chat } from "@tanstack/ai";
import { createGeminiChat } from "@tanstack/ai-gemini";

const adapter = createGeminiChat(process.env.GEMINI_API_KEY!, {
const adapter = createGeminiChat("gemini-2.5-pro", process.env.GEMINI_API_KEY!, {
// ... your config options
});

const stream = chat({
adapter: adapter("gemini-2.5-pro"),
adapter,
messages: [{ role: "user", content: "Hello!" }],
});
```

## Configuration

```typescript
import { createGeminiChat, type GeminiChatConfig } from "@tanstack/ai-gemini";
import { createGeminiChat, type GeminiTextConfig } from "@tanstack/ai-gemini";

const config: Omit<GeminiChatConfig, 'apiKey'> = {
const config: Omit<GeminiTextConfig, "apiKey"> = {
baseURL: "https://generativelanguage.googleapis.com/v1beta", // Optional
};

const adapter = createGeminiChat(process.env.GEMINI_API_KEY!, config);
const adapter = createGeminiChat("gemini-2.5-pro", process.env.GEMINI_API_KEY!, config);
```


Expand Down Expand Up @@ -324,69 +324,32 @@ These models use the dedicated `generateImages` API.

## API Reference

### `geminiText(config?)`
Every factory pair follows the same shape: the short factory (`geminiText`, `geminiImage`, …) reads `GEMINI_API_KEY` (or `GOOGLE_API_KEY`) from the environment, while the `create*` variant takes an explicit API key. Both take `model` as the first argument.

Creates a Gemini text/chat adapter using environment variables.
### `geminiText(model, config?)` / `createGeminiChat(model, apiKey, config?)`

**Returns:** A Gemini text adapter instance.

### `createGeminiText(apiKey, config?)`

Creates a Gemini text/chat adapter with an explicit API key.
Creates a Gemini text/chat adapter.

**Parameters:**

- `apiKey` - Your Gemini API key
- `config.baseURL?` - Custom base URL (optional)

**Returns:** A Gemini text adapter instance.

### `geminiSummarize(config?)`

Creates a Gemini summarization adapter using environment variables.

**Returns:** A Gemini summarize adapter instance.

### `createGeminiSummarize(apiKey, config?)`

Creates a Gemini summarization adapter with an explicit API key.

**Returns:** A Gemini summarize adapter instance.

### `geminiImage(model, config?)`

Creates a Gemini image adapter using environment variables. Automatically routes to the correct API based on model name — `gemini-*` models use `generateContent`, `imagen-*` models use `generateImages`.

**Parameters:**

- `model` - The model name (e.g., `"gemini-3.1-flash-image-preview"` or `"imagen-4.0-generate-001"`)
- `config.baseURL?` - Custom base URL (optional)

**Returns:** A Gemini image adapter instance.

### `createGeminiImage(model, apiKey, config?)`

Creates a Gemini image adapter with an explicit API key.

**Parameters:**
- `model` - Gemini chat model id (e.g. `"gemini-2.5-pro"`)
- `config?.baseURL` - Custom base URL (optional)

- `model` - The model name
- `apiKey` - Your Google API key
- `config.baseURL?` - Custom base URL (optional)
### `geminiSummarize(model, config?)` / `createGeminiSummarize(model, apiKey, config?)`

**Returns:** A Gemini image adapter instance.
Creates a Gemini summarization adapter.

### `geminiTTS(config?)`
### `geminiImage(model, config?)` / `createGeminiImage(model, apiKey, config?)`

Creates a Gemini TTS adapter using environment variables.
Creates a Gemini image adapter. Automatically routes to the correct API based on the model name — `gemini-*` models use `generateContent`, `imagen-*` models use `generateImages`.

**Returns:** A Gemini TTS adapter instance.
### `geminiSpeech(model, config?)` / `createGeminiSpeech(model, apiKey, config?)`

### `createGeminiTTS(apiKey, config?)`
Creates a Gemini text-to-speech adapter. _Experimental._

Creates a Gemini TTS adapter with an explicit API key.
### `geminiAudio(model, config?)` / `createGeminiAudio(model, apiKey, config?)`

**Returns:** A Gemini TTS adapter instance.
Creates a Gemini Lyria music generation adapter. _Experimental._

## Next Steps

Expand Down
Loading
Loading