@assistant-ui/mcp-docs-server 0.1.31 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/waterfall.md +23 -25
- package/.docs/organized/code-examples/with-a2a.md +28 -28
- package/.docs/organized/code-examples/with-ag-ui.md +35 -30
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +16 -14
- package/.docs/organized/code-examples/with-artifacts.md +44 -38
- package/.docs/organized/code-examples/with-assistant-transport.md +68 -56
- package/.docs/organized/code-examples/with-browser-extension.md +357 -0
- package/.docs/organized/code-examples/with-chain-of-thought.md +425 -90
- package/.docs/organized/code-examples/with-cloud-standalone.md +30 -29
- package/.docs/organized/code-examples/with-cloud.md +16 -14
- package/.docs/organized/code-examples/with-custom-thread-list.md +19 -17
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +29 -26
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +20 -18
- package/.docs/organized/code-examples/with-expo.md +37 -31
- package/.docs/organized/code-examples/with-external-store.md +13 -11
- package/.docs/organized/code-examples/with-ffmpeg.md +327 -290
- package/.docs/organized/code-examples/with-generative-ui.md +1195 -194
- package/.docs/organized/code-examples/with-google-adk.md +13 -11
- package/.docs/organized/code-examples/with-heat-graph.md +16 -14
- package/.docs/organized/code-examples/with-image-generation.md +456 -0
- package/.docs/organized/code-examples/with-interactables.md +322 -244
- package/.docs/organized/code-examples/with-langchain.md +18 -16
- package/.docs/organized/code-examples/with-langgraph.md +95 -88
- package/.docs/organized/code-examples/with-livekit.md +30 -27
- package/.docs/organized/code-examples/with-mcp.md +754 -0
- package/.docs/organized/code-examples/with-opencode.md +70 -70
- package/.docs/organized/code-examples/with-react-hook-form.md +24 -22
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +20 -18
- package/.docs/organized/code-examples/with-resumable-stream.md +661 -0
- package/.docs/organized/code-examples/with-store.md +22 -20
- package/.docs/organized/code-examples/with-tanstack.md +18 -19
- package/.docs/organized/code-examples/with-tap-runtime.md +31 -28
- package/.docs/raw/docs/(docs)/architecture.mdx +43 -2
- package/.docs/raw/docs/(docs)/cli.mdx +2 -2
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +34 -26
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +32 -26
- package/.docs/raw/docs/(docs)/index.mdx +2 -2
- package/.docs/raw/docs/(docs)/installation.mdx +2 -2
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +26 -24
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +20 -12
- package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +44 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +41 -16
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +12 -23
- package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +37 -8
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +11 -9
- package/.docs/raw/docs/(reference)/api-reference/context-providers/scoped-providers.mdx +64 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +52 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +46 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +18 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +33 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +45 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +98 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +18 -13
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +31 -52
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +640 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +15 -28
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +64 -18
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +434 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +24 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +11 -12
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +109 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +58 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/registry.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +109 -132
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +78 -221
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +127 -242
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +39 -20
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +66 -87
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +50 -58
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +80 -48
- package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +67 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +323 -461
- package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +36 -43
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +29 -24
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +63 -245
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +202 -588
- package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +35 -22
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +57 -140
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +70 -161
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +84 -108
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +77 -96
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +173 -349
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +9 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +10 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +15 -70
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +18 -13
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +25 -28
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +11 -63
- package/.docs/raw/docs/(reference)/api-reference/runtimes/queue-state.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +11 -48
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +10 -47
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +18 -30
- package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +85 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +39 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +127 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +91 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/assistant-transport.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +62 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/utilities/index.mdx +19 -0
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +143 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +54 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/speech-dictation.mdx +36 -0
- package/.docs/raw/docs/cloud/ai-sdk.mdx +1 -3
- package/.docs/raw/docs/cloud/index.mdx +2 -2
- package/.docs/raw/docs/guides/attachments.mdx +4 -4
- package/.docs/raw/docs/guides/branching.mdx +1 -1
- package/.docs/raw/docs/guides/chain-of-thought.mdx +12 -14
- package/.docs/raw/docs/guides/context-api.mdx +6 -5
- package/.docs/raw/docs/guides/dictation.mdx +2 -2
- package/.docs/raw/docs/guides/editing.mdx +1 -1
- package/.docs/raw/docs/guides/image-generation.mdx +74 -0
- package/.docs/raw/docs/guides/index.mdx +5 -14
- package/.docs/raw/docs/guides/latex.mdx +2 -2
- package/.docs/raw/docs/guides/mentions.mdx +6 -6
- package/.docs/raw/docs/guides/message-timing.mdx +38 -5
- package/.docs/raw/docs/guides/quoting.mdx +1 -1
- package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +212 -0
- package/.docs/raw/docs/guides/resumable-stream-stores.mdx +152 -0
- package/.docs/raw/docs/guides/resumable-streams.mdx +210 -0
- package/.docs/raw/docs/guides/slash-commands.mdx +2 -2
- package/.docs/raw/docs/guides/speech.mdx +2 -2
- package/.docs/raw/docs/guides/suggestions.mdx +89 -5
- package/.docs/raw/docs/guides/voice.mdx +2 -2
- package/.docs/raw/docs/ink/adapters.mdx +37 -1
- package/.docs/raw/docs/ink/custom-backend.mdx +59 -8
- package/.docs/raw/docs/ink/hooks.mdx +98 -85
- package/.docs/raw/docs/ink/index.mdx +10 -11
- package/.docs/raw/docs/ink/migration.mdx +1 -1
- package/.docs/raw/docs/ink/primitives.mdx +350 -9
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +1 -1
- package/.docs/raw/docs/integrations/auth/clerk.mdx +1 -1
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +282 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +2 -2
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +9 -4
- package/.docs/raw/docs/integrations/index.mdx +17 -5
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +8 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +8 -4
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +17 -2
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +226 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +10 -16
- package/.docs/raw/docs/primitives/composer.mdx +53 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -2
- package/.docs/raw/docs/primitives/message.mdx +9 -10
- package/.docs/raw/docs/primitives/suggestion.mdx +9 -0
- package/.docs/raw/docs/react-native/hooks.mdx +57 -82
- package/.docs/raw/docs/react-native/index.mdx +4 -4
- package/.docs/raw/docs/react-native/migration.mdx +1 -1
- package/.docs/raw/docs/react-native/primitives.mdx +2 -2
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +7 -4
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +32 -1
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +7 -2
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +129 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +7 -1
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +27 -2
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -1
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +18 -7
- package/.docs/raw/docs/runtimes/custom/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +108 -38
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +64 -50
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +98 -86
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +1 -1
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -5
- package/.docs/raw/docs/tools/backend.mdx +136 -0
- package/.docs/raw/docs/tools/defining-tools.mdx +413 -0
- package/.docs/raw/docs/tools/dynamic-tools.mdx +110 -0
- package/.docs/raw/docs/tools/generative-ui.mdx +214 -0
- package/.docs/raw/docs/tools/index.mdx +76 -0
- package/.docs/raw/docs/{guides → tools}/interactables.mdx +3 -3
- package/.docs/raw/docs/tools/mcp-apps.mdx +231 -0
- package/.docs/raw/docs/{integrations/tools → tools}/mcp.mdx +77 -50
- package/.docs/raw/docs/{guides → tools}/multi-agent.mdx +19 -21
- package/.docs/raw/docs/tools/tool-ui.mdx +967 -0
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +337 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +11 -1
- package/.docs/raw/docs/ui/directive-text.mdx +3 -3
- package/.docs/raw/docs/ui/mcp-config.mdx +102 -0
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +84 -50
- package/.docs/raw/docs/ui/reasoning.mdx +4 -5
- package/.docs/raw/docs/ui/sources.mdx +17 -0
- package/.docs/raw/docs/ui/streamdown.mdx +34 -2
- package/.docs/raw/docs/ui/thread-list.mdx +2 -2
- package/.docs/raw/docs/ui/thread.mdx +2 -2
- package/.docs/raw/docs/ui/tool-group.mdx +5 -6
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -1
- package/README.md +14 -72
- package/dist/constants.d.ts +12 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +13 -9
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -24
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts +4 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js +109 -121
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts +4 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.js +45 -42
- package/dist/prepare-docs/copy-raw.js.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -2
- package/dist/prepare-docs/prepare.js +17 -17
- package/dist/prepare-docs/prepare.js.map +1 -1
- package/dist/stdio.d.ts +1 -3
- package/dist/stdio.js +6 -3
- package/dist/stdio.js.map +1 -1
- package/dist/tools/docs.d.ts +20 -15
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +140 -161
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +20 -15
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +74 -86
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/tests/test-setup.d.ts +5 -2
- package/dist/tools/tests/test-setup.d.ts.map +1 -1
- package/dist/tools/tests/test-setup.js +21 -28
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/utils/logger.d.ts +8 -5
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +17 -17
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/mcp-format.d.ts +8 -5
- package/dist/utils/mcp-format.d.ts.map +1 -1
- package/dist/utils/mcp-format.js +9 -9
- package/dist/utils/mcp-format.js.map +1 -1
- package/dist/utils/mdx.d.ts +8 -6
- package/dist/utils/mdx.d.ts.map +1 -1
- package/dist/utils/mdx.js +22 -22
- package/dist/utils/mdx.js.map +1 -1
- package/dist/utils/paths.d.ts +9 -6
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +66 -76
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/security.d.ts +4 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js +19 -40
- package/dist/utils/security.js.map +1 -1
- package/package.json +5 -5
- package/.docs/organized/code-examples/with-parent-id-grouping.md +0 -596
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -151
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -230
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +0 -41
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -40
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +0 -260
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -103
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -254
- package/.docs/raw/docs/guides/tool-ui.mdx +0 -858
- package/.docs/raw/docs/guides/tools.mdx +0 -675
- package/dist/prepare-docs/prepare.d.ts.map +0 -1
- package/dist/stdio.d.ts.map +0 -1
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/deprecation-policy.mdx +0 -0
- /package/.docs/raw/docs/{(reference) → migrations}/react-compatibility.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/react-langgraph-v0-7.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-11.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-12.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-14.mdx +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cloudflare Agents Integration
|
|
3
|
+
description: Wire Cloudflare's stateful agent framework into a React chat UI with assistant-ui via the standard AI SDK runtime. WebSocket transport, server-side persistence, tool calling, all preserved.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { CloudflareIcon } from "@/components/icons/cloudflare";
|
|
7
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
8
|
+
|
|
9
|
+
[Cloudflare Agents](https://developers.cloudflare.com/agents/) is Cloudflare's framework for stateful AI agents that run on Durable Objects at the edge. Each agent owns its own SQLite-backed message history, exposes a WebSocket channel for low-latency streaming, and can call tools (server-side or client-side).
|
|
10
|
+
|
|
11
|
+
<Callout type="info">
|
|
12
|
+
This is an integration guide, not a runtime adapter. assistant-ui does not ship a `@assistant-ui/react-cloudflare-agents` package. `@cloudflare/ai-chat`'s `useAgentChat` returns a structural extension of the AI SDK's `useChat`, so the existing [AI SDK runtime](/docs/runtimes/ai-sdk/v6) consumes it directly.
|
|
13
|
+
</Callout>
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
|
|
17
|
+
Cloudflare Agents handles the server half: a Durable Object subclasses `AIChatAgent` from `@cloudflare/ai-chat`, owns the message history, and streams responses back over a WebSocket. `@cloudflare/ai-chat/react`'s `useAgentChat` hook wraps that WebSocket and exposes the same `messages`, `sendMessage`, `regenerate`, `status`, `stop`, `setMessages`, `addToolOutput` surface that the AI SDK's `useChat` does, plus a few Cloudflare-specific extras (`clearHistory`, `isServerStreaming`, `isToolContinuation`).
|
|
18
|
+
|
|
19
|
+
assistant-ui handles the client half. `useAISDKRuntime` from [`@assistant-ui/react-ai-sdk`](/docs/runtimes/ai-sdk/v6) reads exactly those AI SDK methods off whatever you pass in, so feeding it `useAgentChat`'s return value yields a fully-featured runtime: streaming, tool calling, edit, reload, history import and export, attachments, suggestions.
|
|
20
|
+
|
|
21
|
+
Shared adapters (attachments, speech, feedback, history) work the same way as described in [adapters](/docs/runtimes/concepts/adapters). Multi-thread support needs a [custom thread list](/docs/runtimes/concepts/threads) wired around `useAISDKRuntime`; [AssistantCloud](/docs/cloud) integrates via `useChatRuntime` (which constructs its own `useChat` internally) and is not compatible with the `useAgentChat` wiring shown here.
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
- A Cloudflare account with Workers enabled and `wrangler` installed.
|
|
26
|
+
- A frontend project (Next.js or any other AI-SDK-compatible React app).
|
|
27
|
+
- Model API keys (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.) configured as Worker secrets.
|
|
28
|
+
|
|
29
|
+
## Setup
|
|
30
|
+
|
|
31
|
+
The setup has two halves. Steps 1 to 4 happen in the **Worker** project (Cloudflare side); steps 5 to 7 happen in a **separate assistant-ui frontend**. You'll have two dev processes running by the end: `wrangler dev` for the Worker, and your frontend's dev server.
|
|
32
|
+
|
|
33
|
+
<Steps>
|
|
34
|
+
|
|
35
|
+
<Step>
|
|
36
|
+
|
|
37
|
+
### Scaffold the Worker project
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm create cloudflare@latest my-agent -- --type=hello-world --ts
|
|
41
|
+
cd my-agent
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Add the Cloudflare Agents packages and the AI SDK:
|
|
45
|
+
|
|
46
|
+
<InstallCommand npm={["agents@0.12.4", "@cloudflare/ai-chat@0.7.0", "ai@latest", "@ai-sdk/openai@latest"]} />
|
|
47
|
+
|
|
48
|
+
The two Cloudflare packages above are pinned to exact versions because `agents` and `@cloudflare/ai-chat` are pre-1.0 and ship breaking changes between minor releases. See [version stability](#version-stability) below before bumping them.
|
|
49
|
+
|
|
50
|
+
</Step>
|
|
51
|
+
|
|
52
|
+
<Step>
|
|
53
|
+
|
|
54
|
+
### Define the agent
|
|
55
|
+
|
|
56
|
+
`AIChatAgent` already implements message persistence, streaming protocol, and WebSocket plumbing. Override `onChatMessage` to plug in your model and tools.
|
|
57
|
+
|
|
58
|
+
```ts title="src/chat.ts"
|
|
59
|
+
import { AIChatAgent } from "@cloudflare/ai-chat";
|
|
60
|
+
import { openai } from "@ai-sdk/openai";
|
|
61
|
+
import { streamText, convertToModelMessages } from "ai";
|
|
62
|
+
|
|
63
|
+
export type Env = {
|
|
64
|
+
OPENAI_API_KEY: string;
|
|
65
|
+
Chat: DurableObjectNamespace<Chat>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export class Chat extends AIChatAgent<Env> {
|
|
69
|
+
async onChatMessage(onFinish: Parameters<typeof streamText>[0]["onFinish"]) {
|
|
70
|
+
return streamText({
|
|
71
|
+
model: openai("gpt-5.4-nano"),
|
|
72
|
+
messages: await convertToModelMessages(this.messages),
|
|
73
|
+
onFinish,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`Env` is exported alongside `Chat` so the Worker entry point can reuse the same type. The `Chat: DurableObjectNamespace<Chat>` field mirrors the binding declared in `wrangler.jsonc` (next step) and is what `routeAgentRequest` looks up to resolve the agent. `DurableObjectNamespace` is a global from `@cloudflare/workers-types`, which the `npm create cloudflare` scaffold sets up by default.
|
|
80
|
+
|
|
81
|
+
`this.messages` is the persisted history for this Durable Object instance. Each unique agent `name` you connect with from the client (step 7) gets its own instance and its own message log.
|
|
82
|
+
|
|
83
|
+
</Step>
|
|
84
|
+
|
|
85
|
+
<Step>
|
|
86
|
+
|
|
87
|
+
### Register the Durable Object and route requests
|
|
88
|
+
|
|
89
|
+
```ts title="src/index.ts"
|
|
90
|
+
import { routeAgentRequest } from "agents";
|
|
91
|
+
import { Chat, type Env } from "./chat";
|
|
92
|
+
|
|
93
|
+
export { Chat };
|
|
94
|
+
|
|
95
|
+
const cors = (request: Request) => ({
|
|
96
|
+
"Access-Control-Allow-Origin": request.headers.get("Origin") ?? "*",
|
|
97
|
+
"Access-Control-Allow-Headers": "Content-Type, Upgrade",
|
|
98
|
+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export default {
|
|
102
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
103
|
+
if (request.method === "OPTIONS") {
|
|
104
|
+
return new Response(null, { headers: cors(request) });
|
|
105
|
+
}
|
|
106
|
+
const upstream =
|
|
107
|
+
(await routeAgentRequest(request, env)) ??
|
|
108
|
+
new Response("Not found", { status: 404 });
|
|
109
|
+
const res = new Response(upstream.body, upstream);
|
|
110
|
+
for (const [k, v] of Object.entries(cors(request))) res.headers.set(k, v);
|
|
111
|
+
return res;
|
|
112
|
+
},
|
|
113
|
+
} satisfies ExportedHandler<Env>;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`routeAgentRequest` handles WebSocket upgrades, agent lookup by URL path, and the `/get-messages` HTTP endpoint that the frontend uses for history rehydration. The `cors` helper reflects the request origin so the frontend can talk to the Worker across ports during local development. WebSocket upgrades bypass CORS in the browser, but the `/get-messages` HTTP fetch and any custom routes need these headers. For production, replace the wildcard fallback with an explicit allowlist.
|
|
117
|
+
|
|
118
|
+
Wire the Durable Object binding in `wrangler.jsonc`:
|
|
119
|
+
|
|
120
|
+
```jsonc title="wrangler.jsonc"
|
|
121
|
+
{
|
|
122
|
+
"name": "my-agent",
|
|
123
|
+
"main": "src/index.ts",
|
|
124
|
+
"compatibility_date": "2026-01-01",
|
|
125
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
126
|
+
"durable_objects": {
|
|
127
|
+
"bindings": [{ "name": "Chat", "class_name": "Chat" }]
|
|
128
|
+
},
|
|
129
|
+
"migrations": [
|
|
130
|
+
{ "tag": "v1", "new_sqlite_classes": ["Chat"] }
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The binding `name` and `class_name` must match the exported class. `new_sqlite_classes` is required so the Durable Object can use SQLite for message storage.
|
|
136
|
+
|
|
137
|
+
</Step>
|
|
138
|
+
|
|
139
|
+
<Step>
|
|
140
|
+
|
|
141
|
+
### Run the Worker locally
|
|
142
|
+
|
|
143
|
+
Local `wrangler dev` reads environment variables from a `.dev.vars` file in the project root (not from the remote secret store):
|
|
144
|
+
|
|
145
|
+
```sh title=".dev.vars"
|
|
146
|
+
OPENAI_API_KEY=sk-...
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
wrangler dev
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
For production, upload the same key as a deployed Worker secret before `wrangler deploy`:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
wrangler secret put OPENAI_API_KEY
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The Worker boots on `http://localhost:8787`. Leave it running.
|
|
160
|
+
|
|
161
|
+
</Step>
|
|
162
|
+
|
|
163
|
+
<Step>
|
|
164
|
+
|
|
165
|
+
### Initialize the assistant-ui frontend
|
|
166
|
+
|
|
167
|
+
In a different directory:
|
|
168
|
+
|
|
169
|
+
```sh title="New project"
|
|
170
|
+
npx assistant-ui@latest create
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```sh title="Existing project"
|
|
174
|
+
npx assistant-ui@latest init
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This creates a default chat page and a local API route at `app/api/chat/route.ts`. You won't use the local route, since the agent runs on the Worker; delete it once the next step is wired.
|
|
178
|
+
|
|
179
|
+
</Step>
|
|
180
|
+
|
|
181
|
+
<Step>
|
|
182
|
+
|
|
183
|
+
### Install the Cloudflare client packages
|
|
184
|
+
|
|
185
|
+
In the frontend project:
|
|
186
|
+
|
|
187
|
+
<InstallCommand npm={["agents@0.12.4", "@cloudflare/ai-chat@0.7.0"]} />
|
|
188
|
+
|
|
189
|
+
</Step>
|
|
190
|
+
|
|
191
|
+
<Step>
|
|
192
|
+
|
|
193
|
+
### Wire the runtime
|
|
194
|
+
|
|
195
|
+
```tsx title="app/assistant.tsx"
|
|
196
|
+
"use client";
|
|
197
|
+
|
|
198
|
+
import { useAgent } from "agents/react";
|
|
199
|
+
import { useAgentChat } from "@cloudflare/ai-chat/react";
|
|
200
|
+
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
201
|
+
import { useAISDKRuntime } from "@assistant-ui/react-ai-sdk";
|
|
202
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
203
|
+
|
|
204
|
+
export const Assistant = () => {
|
|
205
|
+
const agent = useAgent({
|
|
206
|
+
agent: "Chat",
|
|
207
|
+
name: "default",
|
|
208
|
+
host: process.env.NEXT_PUBLIC_AGENT_HOST!,
|
|
209
|
+
});
|
|
210
|
+
const chat = useAgentChat({ agent });
|
|
211
|
+
const runtime = useAISDKRuntime(chat);
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
215
|
+
<Thread />
|
|
216
|
+
</AssistantRuntimeProvider>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Set the Worker URL in your frontend environment:
|
|
222
|
+
|
|
223
|
+
```sh title=".env.local"
|
|
224
|
+
NEXT_PUBLIC_AGENT_HOST=http://localhost:8787
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`NEXT_PUBLIC_*` exposes the value to the browser. In production, point this at your deployed Worker (e.g. `https://my-agent.example.workers.dev`).
|
|
228
|
+
|
|
229
|
+
`name: "default"` is the Durable Object instance key. Pass a per-user value (a user ID, session ID, or chat ID) to give each user their own persisted history. Switching `name` from the client opens a new WebSocket connection to a different Durable Object instance.
|
|
230
|
+
|
|
231
|
+
</Step>
|
|
232
|
+
|
|
233
|
+
</Steps>
|
|
234
|
+
|
|
235
|
+
## Notes
|
|
236
|
+
|
|
237
|
+
### Type compatibility with `useChat`
|
|
238
|
+
|
|
239
|
+
`useAgentChat`'s return type is `Omit<ReturnType<typeof useChat>, "addToolOutput"> & { ... }`. The `addToolOutput` option shape differs slightly between the two: `useChat` accepts `{ state, tool, toolCallId, ... }`; `useAgentChat` accepts `{ state, toolCallId, toolName?, ... }`. At runtime the call paths converge through `useAISDKRuntime` without issue (verified against `@cloudflare/ai-chat@0.7.0`). If the TypeScript compiler flags the call, cast at the call site: `useAISDKRuntime(chat as Parameters<typeof useAISDKRuntime>[0])`, or `chat as unknown as Parameters<typeof useAISDKRuntime>[0]` if TypeScript still refuses the direct cast. (`satisfies` does not help here; it validates assignability without changing the inferred type, so it surfaces the same error.)
|
|
240
|
+
|
|
241
|
+
### Cloudflare-specific extras
|
|
242
|
+
|
|
243
|
+
`useAgentChat` exposes three values that `useChat` does not:
|
|
244
|
+
|
|
245
|
+
- `clearHistory()` sends a `cf_agent_chat_clear` frame and wipes the Durable Object's SQLite store. Bind it to a "Clear chat" button if you need server-side history reset; `setMessages([])` alone only clears the client view.
|
|
246
|
+
- `isServerStreaming` is `true` while the server is pushing tokens, independent of client-initiated request state. Use it for a universal streaming indicator.
|
|
247
|
+
- `isToolContinuation` distinguishes "server auto-continuing after a tool result" from "user just sent a new message". Useful for typing-indicator gating.
|
|
248
|
+
|
|
249
|
+
Destructure these alongside `chat` and pass them into your UI directly; they don't need to flow through the runtime.
|
|
250
|
+
|
|
251
|
+
### `setMessages` round-trips through the Durable Object
|
|
252
|
+
|
|
253
|
+
`useAgentChat` overrides `setMessages` to broadcast the new list over the WebSocket so the Durable Object's SQLite history stays in sync. This means assistant-ui's `onImport`, `onEdit`, `onReload`, and pending-tool cancellation paths all persist server-side automatically. The tradeoff is one extra WebSocket round-trip per mutation, which can race if the connection is lagging; assume eventual consistency, not transactional.
|
|
254
|
+
|
|
255
|
+
### Authenticate the Worker before going to production
|
|
256
|
+
|
|
257
|
+
`routeAgentRequest` accepts any client that knows the agent class and `name`. If you derive `name` from a user ID (as recommended for per-user history), any client that knows or guesses another user's ID can connect to that Durable Object and read its full message log. Before deploying:
|
|
258
|
+
|
|
259
|
+
- Gate the fetch handler with a header or cookie check (e.g. a JWT issued by your auth backend), and only call `routeAgentRequest` after the request is authenticated.
|
|
260
|
+
- Pass the same credential from the frontend via `useAgent`'s `headers` or `query` options so the WebSocket upgrade carries it.
|
|
261
|
+
- Tighten the CORS `Access-Control-Allow-Origin` to an explicit allowlist; the wildcard in the example above is for local development only.
|
|
262
|
+
|
|
263
|
+
### Version stability
|
|
264
|
+
|
|
265
|
+
`agents` and `@cloudflare/ai-chat` are pre-1.0 and ship breaking changes between minor versions. Pin both to exact versions in `package.json` and read the Cloudflare changelog before bumping. The `useAgentChat` return shape has been additive since 0.3.0, so the integration above should keep working across patch releases.
|
|
266
|
+
|
|
267
|
+
## Related
|
|
268
|
+
|
|
269
|
+
<Cards>
|
|
270
|
+
<Card
|
|
271
|
+
icon={<CloudflareIcon width={20} height={20} />}
|
|
272
|
+
title="Cloudflare Agents docs"
|
|
273
|
+
description="Cloudflare's official guide: Durable Object lifecycle, WebSocket protocol, tool patterns, multi-agent routing."
|
|
274
|
+
href="https://developers.cloudflare.com/agents/"
|
|
275
|
+
/>
|
|
276
|
+
<Card
|
|
277
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
278
|
+
title="AI SDK runtime"
|
|
279
|
+
description="The runtime that handles the client side of this integration."
|
|
280
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
281
|
+
/>
|
|
282
|
+
</Cards>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description: Wire
|
|
2
|
+
title: Mastra Integration
|
|
3
|
+
description: Wire the Mastra TypeScript agent framework into a React chat UI with assistant-ui — full streaming, tool calling, multi-agent support, and thread management.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import { MastraIcon } from "@/components/icons/mastra";
|
|
@@ -50,7 +50,7 @@ export const chefAgent = new Agent({
|
|
|
50
50
|
instructions:
|
|
51
51
|
"You are Michel, a practical and experienced home chef. " +
|
|
52
52
|
"You help people cook with whatever ingredients they have available.",
|
|
53
|
-
model: "openai/gpt-
|
|
53
|
+
model: "openai/gpt-5.4-nano",
|
|
54
54
|
});
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: LLM
|
|
3
|
-
description: Route
|
|
2
|
+
title: LLM Gateway Integrations
|
|
3
|
+
description: Route AI chat traffic through OpenAI-compatible LLM gateways (OpenRouter, LiteLLM, Portkey, etc.) for cost, fallback, and BYOK in assistant-ui apps.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { HeliconeIcon } from "@/components/icons/helicone";
|
|
7
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
8
|
+
|
|
6
9
|
LLM gateways sit between your route handler and the upstream provider. They give you a single endpoint that fronts many providers, plus features like multi-provider fallback, prompt caching, and BYOK (bring-your-own-key) flows. Most are OpenAI API-compatible, so the integration is a `baseURL` swap on `createOpenAI` from `@ai-sdk/openai`.
|
|
7
10
|
|
|
8
11
|
For pure observability (proxy that logs every call) see [Helicone](/docs/integrations/observability/helicone). The gateways here overlap in spirit but are positioned around routing rather than logging.
|
|
@@ -45,7 +48,7 @@ The rest of this page is what to put in `baseURL`, `headers`, and `model(...)` f
|
|
|
45
48
|
|
|
46
49
|
## OpenRouter
|
|
47
50
|
|
|
48
|
-
[OpenRouter](https://openrouter.ai/) aggregates 100+ models behind one OpenAI-compatible endpoint. The model ID is `provider/model` (e.g., `anthropic/claude-sonnet-4`, `openai/gpt-5.4-mini`, `meta-llama/llama-3.3-70b-instruct`).
|
|
51
|
+
[OpenRouter](https://openrouter.ai/) aggregates 100+ models behind one OpenAI-compatible endpoint. The model ID is `provider/model` (e.g., `anthropic/claude-sonnet-4.6`, `openai/gpt-5.4-mini`, `meta-llama/llama-3.3-70b-instruct`).
|
|
49
52
|
|
|
50
53
|
```sh title=".env.local"
|
|
51
54
|
OPENROUTER_API_KEY=sk-or-...
|
|
@@ -69,7 +72,7 @@ const openrouter = createOpenAI({
|
|
|
69
72
|
export async function POST(req: Request) {
|
|
70
73
|
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
71
74
|
const result = streamText({
|
|
72
|
-
model: openrouter("anthropic/claude-sonnet-4"),
|
|
75
|
+
model: openrouter("anthropic/claude-sonnet-4.6"),
|
|
73
76
|
messages: await convertToModelMessages(messages),
|
|
74
77
|
});
|
|
75
78
|
return result.toUIMessageStreamResponse();
|
|
@@ -145,11 +148,13 @@ When to pick: self-host requirement, BYOK metering for end-users, or unified bil
|
|
|
145
148
|
|
|
146
149
|
<Cards>
|
|
147
150
|
<Card
|
|
151
|
+
icon={<HeliconeIcon width={20} height={20} />}
|
|
148
152
|
title="Helicone"
|
|
149
153
|
description="The observability-first proxy. Same shape, different goal."
|
|
150
154
|
href="/docs/integrations/observability/helicone"
|
|
151
155
|
/>
|
|
152
156
|
<Card
|
|
157
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
153
158
|
title="AI SDK runtime"
|
|
154
159
|
description="The runtime that ferries gateway responses to the chat UI."
|
|
155
160
|
href="/docs/runtimes/ai-sdk/v6"
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Integrations
|
|
3
|
-
description:
|
|
3
|
+
description: Adapters for Vercel AI SDK, LangChain, LangGraph, Mastra, plus auth, persistence, observability, and tool services — drop into a React chat UI built with assistant-ui.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { CloudflareIcon } from "@/components/icons/cloudflare";
|
|
7
|
+
import { HeliconeIcon } from "@/components/icons/helicone";
|
|
6
8
|
import { MastraIcon } from "@/components/icons/mastra";
|
|
7
|
-
import {
|
|
9
|
+
import { LangfuseIcon } from "@/components/icons/langfuse";
|
|
8
10
|
import { LangChainIcon } from "@/components/icons/langchain";
|
|
11
|
+
import { McpIcon } from "@/components/icons/mcp";
|
|
12
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
9
13
|
|
|
10
14
|
Integrations are wiring guides for using third-party services with assistant-ui, plus canonical recipes for the adapter slots (persistence, attachments). They are distinct from [runtimes](/docs/runtimes/pick-a-runtime), which are the React adapter packages (`@assistant-ui/react-ai-sdk`, `@assistant-ui/react-langgraph`, etc.) that connect the UI to a backend. An integration assumes you already have a working runtime and adds something on top.
|
|
11
15
|
|
|
@@ -39,6 +43,12 @@ Framework integrations that pair with assistant-ui at the API-route layer.
|
|
|
39
43
|
href="/docs/integrations/frameworks/ai-sdk"
|
|
40
44
|
/>
|
|
41
45
|
<PlatformOnly platforms={["react"]}>
|
|
46
|
+
<Card
|
|
47
|
+
icon={<CloudflareIcon width={20} height={20} />}
|
|
48
|
+
title="Cloudflare Agents"
|
|
49
|
+
description="Stateful Durable Object agents. Wired through the AI SDK runtime with WebSocket streaming."
|
|
50
|
+
href="/docs/integrations/frameworks/cloudflare-agents/overview"
|
|
51
|
+
/>
|
|
42
52
|
<Card
|
|
43
53
|
icon={<MastraIcon width={20} height={20} />}
|
|
44
54
|
title="Mastra"
|
|
@@ -50,13 +60,14 @@ Framework integrations that pair with assistant-ui at the API-route layer.
|
|
|
50
60
|
|
|
51
61
|
## Tools
|
|
52
62
|
|
|
53
|
-
|
|
63
|
+
Tool catalogs and protocols have their own [Tools](/docs/tools) section.
|
|
54
64
|
|
|
55
65
|
<Cards>
|
|
56
66
|
<Card
|
|
67
|
+
icon={<McpIcon width={20} height={20} />}
|
|
57
68
|
title="Model Context Protocol (MCP)"
|
|
58
69
|
description="Connect any MCP server as a tool catalog through the AI SDK MCP client."
|
|
59
|
-
href="/docs/
|
|
70
|
+
href="/docs/tools/mcp"
|
|
60
71
|
/>
|
|
61
72
|
</Cards>
|
|
62
73
|
|
|
@@ -78,12 +89,13 @@ Log, monitor, trace, and evaluate LLM calls. These pair with any runtime.
|
|
|
78
89
|
|
|
79
90
|
<Cards>
|
|
80
91
|
<Card
|
|
92
|
+
icon={<HeliconeIcon width={20} height={20} />}
|
|
81
93
|
title="Helicone"
|
|
82
94
|
description="Observability proxy. Drop-in baseURL swap that logs cost, latency, and prompts."
|
|
83
95
|
href="/docs/integrations/observability/helicone"
|
|
84
96
|
/>
|
|
85
97
|
<Card
|
|
86
|
-
icon={<
|
|
98
|
+
icon={<LangfuseIcon width={20} height={20} />}
|
|
87
99
|
title="Langfuse"
|
|
88
100
|
description="OpenTelemetry-based tracing and evals. Open source, self-hostable."
|
|
89
101
|
href="/docs/integrations/observability/langfuse"
|
|
@@ -3,6 +3,10 @@ title: Langfuse
|
|
|
3
3
|
description: Trace AI SDK calls into Langfuse via OpenTelemetry for tracing, evals, and prompt management.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { HeliconeIcon } from "@/components/icons/helicone";
|
|
7
|
+
import { LangChainIcon } from "@/components/icons/langchain";
|
|
8
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
9
|
+
|
|
6
10
|
[Langfuse](https://langfuse.com/) is an open-source LLM observability platform. It gives you a hierarchical trace per request (planner → tool calls → final LLM step), prompt-level analytics, datasets, and LLM-as-judge evals. Self-hostable, OpenTelemetry-native.
|
|
7
11
|
|
|
8
12
|
Pick Langfuse when you want to see the agent's full call tree inside a single turn. It's complementary to [Helicone](/docs/integrations/observability/helicone), which proxies and logs individual provider calls; many teams run both, with Helicone capturing the request log and Langfuse capturing the trace.
|
|
@@ -99,7 +103,7 @@ export async function POST(req: Request) {
|
|
|
99
103
|
{ traceName: "chat-completion", userId, sessionId },
|
|
100
104
|
async () =>
|
|
101
105
|
streamText({
|
|
102
|
-
model: openai("gpt-
|
|
106
|
+
model: openai("gpt-5.4-nano"),
|
|
103
107
|
messages: await convertToModelMessages(messages),
|
|
104
108
|
experimental_telemetry: { isEnabled: true },
|
|
105
109
|
}),
|
|
@@ -139,16 +143,19 @@ If nothing appears, check the server logs for OTel errors and confirm `LANGFUSE_
|
|
|
139
143
|
|
|
140
144
|
<Cards>
|
|
141
145
|
<Card
|
|
146
|
+
icon={<LangChainIcon width={20} height={20} className="text-[#7FC8FF]" />}
|
|
142
147
|
title="LangSmith"
|
|
143
148
|
description="LangChain ecosystem alternative, uses wrapAISDK instead of OpenTelemetry."
|
|
144
149
|
href="/docs/integrations/observability/langsmith"
|
|
145
150
|
/>
|
|
146
151
|
<Card
|
|
152
|
+
icon={<HeliconeIcon width={20} height={20} />}
|
|
147
153
|
title="Helicone"
|
|
148
154
|
description="Proxy-based request logging with cost, latency, and prompt diffs per call."
|
|
149
155
|
href="/docs/integrations/observability/helicone"
|
|
150
156
|
/>
|
|
151
157
|
<Card
|
|
158
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
152
159
|
title="AI SDK runtime"
|
|
153
160
|
description="The runtime that emits the telemetry Langfuse consumes."
|
|
154
161
|
href="/docs/runtimes/ai-sdk/v6"
|
|
@@ -3,7 +3,9 @@ title: LangSmith
|
|
|
3
3
|
description: Trace AI SDK calls into LangSmith with the wrapAISDK helper.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { LangfuseIcon } from "@/components/icons/langfuse";
|
|
7
|
+
import { LangGraphIcon } from "@/components/icons/langgraph";
|
|
8
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
7
9
|
|
|
8
10
|
[LangSmith](https://www.langchain.com/langsmith) is LangChain's observability and eval platform. If you are already in the LangChain or LangGraph ecosystem, LangSmith is the natural pairing: traces, datasets, prompt versioning, and LLM-as-judge evals share state with the rest of the LangChain stack.
|
|
9
11
|
|
|
@@ -60,7 +62,7 @@ export async function POST(req: Request) {
|
|
|
60
62
|
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
61
63
|
|
|
62
64
|
const result = streamText({
|
|
63
|
-
model: openai("gpt-
|
|
65
|
+
model: openai("gpt-5.4-nano"),
|
|
64
66
|
messages: await ai.convertToModelMessages(messages),
|
|
65
67
|
});
|
|
66
68
|
|
|
@@ -81,7 +83,7 @@ Pass a `langsmith` provider option to tag traces with user, session, or run iden
|
|
|
81
83
|
import { createLangSmithProviderOptions } from "langsmith/experimental/vercel";
|
|
82
84
|
|
|
83
85
|
const result = streamText({
|
|
84
|
-
model: openai("gpt-
|
|
86
|
+
model: openai("gpt-5.4-nano"),
|
|
85
87
|
messages: await ai.convertToModelMessages(messages),
|
|
86
88
|
providerOptions: {
|
|
87
89
|
langsmith: createLangSmithProviderOptions({
|
|
@@ -128,17 +130,19 @@ Send a message. The trace should appear in your LangSmith project within seconds
|
|
|
128
130
|
|
|
129
131
|
<Cards>
|
|
130
132
|
<Card
|
|
131
|
-
icon={<
|
|
133
|
+
icon={<LangGraphIcon width={20} height={20} className="text-[#1C3C3C] dark:text-[#5b9595]" />}
|
|
132
134
|
title="LangGraph runtime"
|
|
133
135
|
description="If your backend is LangGraph, tracing flows through LangGraph Cloud automatically."
|
|
134
136
|
href="/docs/runtimes/langgraph"
|
|
135
137
|
/>
|
|
136
138
|
<Card
|
|
139
|
+
icon={<LangfuseIcon width={20} height={20} />}
|
|
137
140
|
title="Langfuse"
|
|
138
141
|
description="OpenTelemetry-based alternative; OSS and self-hostable."
|
|
139
142
|
href="/docs/integrations/observability/langfuse"
|
|
140
143
|
/>
|
|
141
144
|
<Card
|
|
145
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
142
146
|
title="AI SDK runtime"
|
|
143
147
|
description="The runtime that ferries traces from the route to the chat UI."
|
|
144
148
|
href="/docs/runtimes/ai-sdk/v6"
|
|
@@ -65,7 +65,22 @@ export const messages = pgTable(
|
|
|
65
65
|
);
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
The four message columns (`id`, `parent_id`, `format`, `content`) are the contract `withFormat` writes against. `format`
|
|
68
|
+
The four message columns (`id`, `parent_id`, `format`, `content`) are the contract `withFormat` writes against. `format` records which adapter encoded the row so multiple runtimes can coexist on one table; `useChatRuntime` sets it from `fmt.format`.
|
|
69
|
+
|
|
70
|
+
<Callout type="warn">
|
|
71
|
+
`content` is not arbitrary JSON. It must be the payload the active format adapter produced via `fmt.encode(item)`, and it is read back through `fmt.decode`; the route handlers below are a pass-through that never inspects it. For `useChatRuntime` (AI SDK v6) a valid stored row looks like:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"id": "msg_abc",
|
|
76
|
+
"parent_id": null,
|
|
77
|
+
"format": "ai-sdk/v6",
|
|
78
|
+
"content": { "role": "user", "parts": [{ "type": "text", "text": "hello" }] }
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A row that satisfies the column types but carries a different shape (e.g. `{ "foo": "bar" }`) is accepted on write, then fails history reload. Seed test data through the adapter, not by hand-crafting `content`.
|
|
83
|
+
</Callout>
|
|
69
84
|
|
|
70
85
|
## Setup
|
|
71
86
|
|
|
@@ -678,7 +693,7 @@ Send a message in a fresh thread. Check the database:
|
|
|
678
693
|
|
|
679
694
|
- The `threads` table has a new row with the current `userId`.
|
|
680
695
|
- The `messages` table has at least two rows (user + assistant) for that thread.
|
|
681
|
-
- `format`
|
|
696
|
+
- `format` matches what `fmt.format` wrote (`"ai-sdk/v6"` for AI SDK v6) and `content` is the encoded `UIMessage` (a `role` plus `parts`), not a placeholder blob.
|
|
682
697
|
- Reload the page; the thread list and the messages survive.
|
|
683
698
|
|
|
684
699
|
</Step>
|