@assistant-ui/mcp-docs-server 0.1.29 → 0.1.31
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 +15 -7
- package/.docs/organized/code-examples/with-a2a.md +9 -21
- package/.docs/organized/code-examples/with-ag-ui.md +11 -8
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +10 -10
- package/.docs/organized/code-examples/with-artifacts.md +12 -10
- package/.docs/organized/code-examples/with-assistant-transport.md +11 -12
- package/.docs/organized/code-examples/with-chain-of-thought.md +83 -54
- package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
- package/.docs/organized/code-examples/with-cloud.md +9 -10
- package/.docs/organized/code-examples/with-custom-thread-list.md +61 -16
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -12
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +13 -13
- package/.docs/organized/code-examples/with-expo.md +25 -21
- package/.docs/organized/code-examples/with-external-store.md +8 -8
- package/.docs/organized/code-examples/with-ffmpeg.md +17 -12
- package/.docs/organized/code-examples/with-generative-ui.md +9 -9
- package/.docs/organized/code-examples/with-google-adk.md +8 -8
- package/.docs/organized/code-examples/with-heat-graph.md +5 -5
- package/.docs/organized/code-examples/with-interactables.md +10 -25
- package/.docs/organized/code-examples/with-langchain.md +437 -0
- package/.docs/organized/code-examples/with-langgraph.md +16 -16
- package/.docs/organized/code-examples/with-livekit.md +18 -13
- package/.docs/organized/code-examples/with-opencode.md +105 -62
- package/.docs/organized/code-examples/with-parent-id-grouping.md +10 -10
- package/.docs/organized/code-examples/with-react-hook-form.md +220 -148
- package/.docs/organized/code-examples/with-react-ink.md +2 -2
- package/.docs/organized/code-examples/with-react-router.md +12 -12
- package/.docs/organized/code-examples/with-store.md +8 -5
- package/.docs/organized/code-examples/with-tanstack.md +10 -10
- package/.docs/organized/code-examples/with-tap-runtime.md +10 -6
- package/.docs/raw/docs/(docs)/cli.mdx +2 -1
- package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
- package/.docs/raw/docs/(docs)/index.mdx +1 -0
- package/.docs/raw/docs/(docs)/installation.mdx +1 -0
- package/.docs/raw/docs/(docs)/rtl.mdx +80 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +149 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +9 -0
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +231 -3
- package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
- package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
- package/.docs/raw/docs/guides/branching.mdx +76 -0
- package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
- package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
- package/.docs/raw/docs/guides/editing.mdx +102 -0
- package/.docs/raw/docs/guides/index.mdx +103 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
- package/.docs/raw/docs/guides/mentions.mdx +520 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
- package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
- package/.docs/raw/docs/guides/slash-commands.mdx +361 -0
- package/.docs/raw/docs/guides/speech.mdx +156 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
- package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
- package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
- package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
- package/.docs/raw/docs/ink/index.mdx +1 -3
- package/.docs/raw/docs/ink/migration.mdx +1 -3
- package/.docs/raw/docs/ink/primitives.mdx +37 -1
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
- package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
- package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
- package/.docs/raw/docs/integrations/index.mdx +173 -0
- package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
- package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/primitives/attachment.mdx +1 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
- package/.docs/raw/docs/primitives/composer.mdx +96 -63
- package/.docs/raw/docs/primitives/error.mdx +1 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -1
- package/.docs/raw/docs/primitives/message.mdx +68 -5
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
- package/.docs/raw/docs/primitives/thread.mdx +16 -13
- package/.docs/raw/docs/react-native/index.mdx +1 -3
- package/.docs/raw/docs/react-native/migration.mdx +1 -3
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
- package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
- package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +365 -101
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
- package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
- package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
- package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
- package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
- package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
- package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
- package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +74 -198
- package/.docs/raw/docs/ui/accordion.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
- package/.docs/raw/docs/ui/attachment.mdx +1 -0
- package/.docs/raw/docs/ui/badge.mdx +1 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +200 -0
- package/.docs/raw/docs/ui/context-display.mdx +1 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
- package/.docs/raw/docs/ui/directive-text.mdx +114 -0
- package/.docs/raw/docs/ui/file.mdx +1 -0
- package/.docs/raw/docs/ui/image.mdx +1 -0
- package/.docs/raw/docs/ui/markdown.mdx +2 -14
- package/.docs/raw/docs/ui/mermaid.mdx +1 -0
- package/.docs/raw/docs/ui/message-timing.mdx +3 -2
- package/.docs/raw/docs/ui/model-selector.mdx +1 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
- package/.docs/raw/docs/ui/quote.mdx +1 -0
- package/.docs/raw/docs/ui/reasoning.mdx +69 -32
- package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
- package/.docs/raw/docs/ui/select.mdx +1 -0
- package/.docs/raw/docs/ui/sources.mdx +1 -0
- package/.docs/raw/docs/ui/streamdown.mdx +1 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
- package/.docs/raw/docs/ui/tabs.mdx +1 -0
- package/.docs/raw/docs/ui/thread-list.mdx +17 -0
- package/.docs/raw/docs/ui/thread.mdx +56 -1
- package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
- package/.docs/raw/docs/ui/tool-group.mdx +39 -11
- package/.docs/raw/docs/ui/voice.mdx +1 -0
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
- package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/package.json +4 -4
- package/src/tools/tests/path-traversal.test.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
- package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
- package/.docs/raw/docs/(docs)/guides/mentions.mdx +0 -406
- package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +0 -275
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
- package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -268
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
- package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -607
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
- package/.docs/raw/docs/ui/mention.mdx +0 -168
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Integrations
|
|
3
|
+
description: Third-party services and adapter recipes that plug into a working assistant-ui app.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { MastraIcon } from "@/components/icons/mastra";
|
|
7
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
8
|
+
import { LangChainIcon } from "@/components/icons/langchain";
|
|
9
|
+
|
|
10
|
+
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
|
+
|
|
12
|
+
## Where integrations slot in
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
client ──► your API route ──► LLM provider
|
|
16
|
+
│ ▲
|
|
17
|
+
│ │
|
|
18
|
+
agent │ │ observability
|
|
19
|
+
frameworks │ │ proxies
|
|
20
|
+
(e.g. │ │ (e.g. Helicone,
|
|
21
|
+
Mastra) │ │ Langfuse)
|
|
22
|
+
▼ │
|
|
23
|
+
run on the server, │
|
|
24
|
+
then forward calls ──────┘
|
|
25
|
+
to the provider
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Integrations live on the server. **Agent frameworks** like Mastra take over the API route. **Gateways** swap the upstream provider URL. **Observability** logs or traces every call. **Auth** gates the route and scopes per-user data. **Persistence** and **attachments** are adapter recipes for storing chat data outside the default in-memory path.
|
|
29
|
+
|
|
30
|
+
## Frameworks
|
|
31
|
+
|
|
32
|
+
Framework integrations that pair with assistant-ui at the API-route layer.
|
|
33
|
+
|
|
34
|
+
<Cards>
|
|
35
|
+
<Card
|
|
36
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
37
|
+
title="Vercel AI SDK"
|
|
38
|
+
description="The canonical first-party adapter. Full setup lives under runtimes; this entry is the architectural pointer."
|
|
39
|
+
href="/docs/integrations/frameworks/ai-sdk"
|
|
40
|
+
/>
|
|
41
|
+
<PlatformOnly platforms={["react"]}>
|
|
42
|
+
<Card
|
|
43
|
+
icon={<MastraIcon width={20} height={20} />}
|
|
44
|
+
title="Mastra"
|
|
45
|
+
description="TypeScript agent framework. Routed through the AI SDK runtime, full-stack or separate server."
|
|
46
|
+
href="/docs/integrations/frameworks/mastra/overview"
|
|
47
|
+
/>
|
|
48
|
+
</PlatformOnly>
|
|
49
|
+
</Cards>
|
|
50
|
+
|
|
51
|
+
## Tools
|
|
52
|
+
|
|
53
|
+
Pluggable tool catalogs and protocols.
|
|
54
|
+
|
|
55
|
+
<Cards>
|
|
56
|
+
<Card
|
|
57
|
+
title="Model Context Protocol (MCP)"
|
|
58
|
+
description="Connect any MCP server as a tool catalog through the AI SDK MCP client."
|
|
59
|
+
href="/docs/integrations/tools/mcp"
|
|
60
|
+
/>
|
|
61
|
+
</Cards>
|
|
62
|
+
|
|
63
|
+
## Gateways
|
|
64
|
+
|
|
65
|
+
OpenAI-compatible proxies that add catalog routing, fallback, BYOK, or self-hosting.
|
|
66
|
+
|
|
67
|
+
<Cards>
|
|
68
|
+
<Card
|
|
69
|
+
title="LLM gateways"
|
|
70
|
+
description="OpenRouter, Portkey, LiteLLM Proxy. Swap baseURL, route across providers."
|
|
71
|
+
href="/docs/integrations/gateways"
|
|
72
|
+
/>
|
|
73
|
+
</Cards>
|
|
74
|
+
|
|
75
|
+
## Observability
|
|
76
|
+
|
|
77
|
+
Log, monitor, trace, and evaluate LLM calls. These pair with any runtime.
|
|
78
|
+
|
|
79
|
+
<Cards>
|
|
80
|
+
<Card
|
|
81
|
+
title="Helicone"
|
|
82
|
+
description="Observability proxy. Drop-in baseURL swap that logs cost, latency, and prompts."
|
|
83
|
+
href="/docs/integrations/observability/helicone"
|
|
84
|
+
/>
|
|
85
|
+
<Card
|
|
86
|
+
icon={<LangChainIcon width={20} height={20} className="text-[#7FC8FF]" />}
|
|
87
|
+
title="Langfuse"
|
|
88
|
+
description="OpenTelemetry-based tracing and evals. Open source, self-hostable."
|
|
89
|
+
href="/docs/integrations/observability/langfuse"
|
|
90
|
+
/>
|
|
91
|
+
<Card
|
|
92
|
+
icon={<LangChainIcon width={20} height={20} className="text-[#7FC8FF]" />}
|
|
93
|
+
title="LangSmith"
|
|
94
|
+
description="LangChain ecosystem tracing via wrapAISDK. Datasets and evals included."
|
|
95
|
+
href="/docs/integrations/observability/langsmith"
|
|
96
|
+
/>
|
|
97
|
+
</Cards>
|
|
98
|
+
|
|
99
|
+
<PlatformOnly platforms={["react"]}>
|
|
100
|
+
|
|
101
|
+
## Auth
|
|
102
|
+
|
|
103
|
+
Gate the chat route and scope thread data to the signed-in user. These pages are the **non-cloud** path; pair with [custom thread persistence](/docs/integrations/persistence/custom-adapter) when you own the database.
|
|
104
|
+
|
|
105
|
+
<Cards>
|
|
106
|
+
<Card
|
|
107
|
+
title="Clerk"
|
|
108
|
+
description="Hosted auth with a Next.js middleware. auth() returns userId; Clerk Orgs map to multi-tenant chat."
|
|
109
|
+
href="/docs/integrations/auth/clerk"
|
|
110
|
+
/>
|
|
111
|
+
<Card
|
|
112
|
+
title="better-auth"
|
|
113
|
+
description="TypeScript-first, owns the user table and session. session.user.id is populated by default."
|
|
114
|
+
href="/docs/integrations/auth/better-auth"
|
|
115
|
+
/>
|
|
116
|
+
<Card
|
|
117
|
+
title="Auth.js (next-auth)"
|
|
118
|
+
description="The OSS Next.js standard. Requires jwt/session callbacks to populate session.user.id."
|
|
119
|
+
href="/docs/integrations/auth/next-auth"
|
|
120
|
+
/>
|
|
121
|
+
</Cards>
|
|
122
|
+
|
|
123
|
+
For AssistantCloud users, [cloud authorization](/docs/cloud/authorization) handles the JWT exchange for Clerk, Auth0, Supabase, and Firebase without DB code.
|
|
124
|
+
|
|
125
|
+
</PlatformOnly>
|
|
126
|
+
|
|
127
|
+
## Persistence
|
|
128
|
+
|
|
129
|
+
Store threads and messages outside AssistantCloud.
|
|
130
|
+
|
|
131
|
+
<Cards>
|
|
132
|
+
<Card
|
|
133
|
+
title="Custom thread persistence"
|
|
134
|
+
description="Worked example: Postgres + Drizzle, RemoteThreadListAdapter, ThreadHistoryAdapter with withFormat."
|
|
135
|
+
href="/docs/integrations/persistence/custom-adapter"
|
|
136
|
+
/>
|
|
137
|
+
</Cards>
|
|
138
|
+
|
|
139
|
+
## Attachments
|
|
140
|
+
|
|
141
|
+
Upload chat attachments to object storage instead of inlining as data URLs.
|
|
142
|
+
|
|
143
|
+
<Cards>
|
|
144
|
+
<Card
|
|
145
|
+
title="Custom attachment uploads"
|
|
146
|
+
description="Production AttachmentAdapter with presigned URLs. Tabs for S3/R2, Vercel Blob, Uploadthing."
|
|
147
|
+
href="/docs/integrations/attachments/custom-adapter"
|
|
148
|
+
/>
|
|
149
|
+
</Cards>
|
|
150
|
+
|
|
151
|
+
## Don't see your service?
|
|
152
|
+
|
|
153
|
+
assistant-ui doesn't ship a guide for every tool, but most fit one of two patterns:
|
|
154
|
+
|
|
155
|
+
- **Routes through your AI SDK handler** (agent frameworks, observability proxies, gateways): adapt the [Mastra full-stack](/docs/integrations/frameworks/mastra/full-stack) or [Helicone proxy](/docs/integrations/observability/helicone) pattern using the service's own SDK.
|
|
156
|
+
- **Replaces the runtime entirely** (custom backends): see [custom backend](/docs/runtimes/custom).
|
|
157
|
+
|
|
158
|
+
If you build something useful, [open an issue](https://github.com/assistant-ui/assistant-ui/issues) or post in [Discord](https://discord.gg/S9dwgCNEFs); the docs are open to contributions.
|
|
159
|
+
|
|
160
|
+
## Related
|
|
161
|
+
|
|
162
|
+
<Cards>
|
|
163
|
+
<Card
|
|
164
|
+
title="Pick a runtime"
|
|
165
|
+
description="Choose the React adapter that matches your backend before adding integrations."
|
|
166
|
+
href="/docs/runtimes/pick-a-runtime"
|
|
167
|
+
/>
|
|
168
|
+
<Card
|
|
169
|
+
title="Runtime concepts"
|
|
170
|
+
description="Architecture, adapters, threads, and stability across all runtimes."
|
|
171
|
+
href="/docs/runtimes/concepts/architecture"
|
|
172
|
+
/>
|
|
173
|
+
</Cards>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Helicone
|
|
3
|
+
description: Log and monitor LLM calls by routing them through the Helicone proxy.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
7
|
+
|
|
8
|
+
[Helicone](https://www.helicone.ai/) is an LLM observability proxy. Point your provider client at Helicone's URL, add an auth header, and every request and response is recorded with cost, latency, and prompt-level diffs.
|
|
9
|
+
|
|
10
|
+
Helicone is independent of which assistant-ui runtime you use. It slots in at the LLM-client layer (OpenAI SDK, AI SDK provider, or any HTTP-based provider client) on the server, not at the assistant-ui client runtime layer. So it pairs with any backend: AI SDK, LangGraph, Mastra, custom.
|
|
11
|
+
|
|
12
|
+
## How it works
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
your server ──► Helicone proxy ──► OpenAI / Anthropic / etc.
|
|
16
|
+
│
|
|
17
|
+
└─ logs request, response, tokens, cost
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Calls pass through Helicone's edge before reaching the upstream provider. The proxy is transparent: response shape and streaming behavior are unchanged, you just gain a dashboard of every call.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
<Steps>
|
|
25
|
+
<Step>
|
|
26
|
+
|
|
27
|
+
### Get a Helicone API key
|
|
28
|
+
|
|
29
|
+
Sign up at [helicone.ai](https://www.helicone.ai/) and copy the key from the dashboard. Add it to your environment alongside the provider key:
|
|
30
|
+
|
|
31
|
+
```sh title=".env.local"
|
|
32
|
+
HELICONE_API_KEY=sk-helicone-...
|
|
33
|
+
OPENAI_API_KEY=sk-...
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
</Step>
|
|
37
|
+
<Step>
|
|
38
|
+
|
|
39
|
+
### Point the provider client at the proxy
|
|
40
|
+
|
|
41
|
+
Swap the provider's `baseURL` for Helicone's proxy URL and add the `Helicone-Auth` header.
|
|
42
|
+
|
|
43
|
+
<Tabs items={["AI SDK", "OpenAI SDK"]}>
|
|
44
|
+
<Tab value="AI SDK">
|
|
45
|
+
|
|
46
|
+
```ts title="app/api/chat/route.ts"
|
|
47
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
48
|
+
import { streamText, convertToModelMessages } from "ai";
|
|
49
|
+
import type { UIMessage } from "ai";
|
|
50
|
+
|
|
51
|
+
const openai = createOpenAI({
|
|
52
|
+
baseURL: "https://oai.helicone.ai/v1",
|
|
53
|
+
headers: {
|
|
54
|
+
"Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export async function POST(req: Request) {
|
|
59
|
+
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
60
|
+
const result = streamText({
|
|
61
|
+
model: openai("gpt-5.4-mini"),
|
|
62
|
+
messages: await convertToModelMessages(messages),
|
|
63
|
+
});
|
|
64
|
+
return result.toUIMessageStreamResponse();
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
</Tab>
|
|
69
|
+
<Tab value="OpenAI SDK">
|
|
70
|
+
|
|
71
|
+
```ts title="app/api/chat/route.ts"
|
|
72
|
+
import OpenAI from "openai";
|
|
73
|
+
|
|
74
|
+
const openai = new OpenAI({
|
|
75
|
+
baseURL: "https://oai.helicone.ai/v1",
|
|
76
|
+
defaultHeaders: {
|
|
77
|
+
"Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export async function POST(req: Request) {
|
|
82
|
+
const { messages } = await req.json();
|
|
83
|
+
const stream = await openai.chat.completions.create({
|
|
84
|
+
model: "gpt-5.4-mini",
|
|
85
|
+
messages,
|
|
86
|
+
stream: true,
|
|
87
|
+
});
|
|
88
|
+
return new Response(stream.toReadableStream());
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If you're calling the OpenAI SDK directly, you'll also need to adapt the response into a stream `useChatRuntime` understands. The AI SDK tab above handles this for you.
|
|
93
|
+
|
|
94
|
+
</Tab>
|
|
95
|
+
</Tabs>
|
|
96
|
+
|
|
97
|
+
</Step>
|
|
98
|
+
<Step>
|
|
99
|
+
|
|
100
|
+
### Verify in the dashboard
|
|
101
|
+
|
|
102
|
+
Send a message through your assistant. The call should appear in the Helicone dashboard within a few seconds, with token counts, latency, and the full prompt and completion text.
|
|
103
|
+
|
|
104
|
+
If nothing appears, check the request in your network tab. The host should be `oai.helicone.ai`, not `api.openai.com`; the request should carry `Helicone-Auth` (added explicitly above) and `Authorization` (added automatically by the OpenAI client from `OPENAI_API_KEY`).
|
|
105
|
+
|
|
106
|
+
</Step>
|
|
107
|
+
</Steps>
|
|
108
|
+
|
|
109
|
+
## Notes
|
|
110
|
+
|
|
111
|
+
- **Server-side only.** Never set the Helicone key in client code; the proxy receives your provider key and must run server-side.
|
|
112
|
+
- **Other providers.** For Anthropic, Gemini, and others, swap the base URL: see Helicone's [provider docs](https://docs.helicone.ai/getting-started/integration-method/gateway).
|
|
113
|
+
- **Custom metadata.** Add `Helicone-User-Id`, `Helicone-Property-*`, or session headers per request to filter and aggregate in the dashboard. The headers are in the [request headers reference](https://docs.helicone.ai/helicone-headers/header-directory).
|
|
114
|
+
- **Streaming, tools, attachments** all keep working unchanged because Helicone wraps the underlying provider transparently.
|
|
115
|
+
|
|
116
|
+
## Related
|
|
117
|
+
|
|
118
|
+
<Cards>
|
|
119
|
+
<Card
|
|
120
|
+
title="Pick a runtime"
|
|
121
|
+
description="Choose a backend integration; Helicone pairs with any of them."
|
|
122
|
+
href="/docs/runtimes/pick-a-runtime"
|
|
123
|
+
/>
|
|
124
|
+
<Card
|
|
125
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
126
|
+
title="AI SDK runtime"
|
|
127
|
+
description="The most common pairing: AI SDK route handler proxied through Helicone."
|
|
128
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
129
|
+
/>
|
|
130
|
+
</Cards>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Langfuse
|
|
3
|
+
description: Trace AI SDK calls into Langfuse via OpenTelemetry for tracing, evals, and prompt management.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
[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
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
## How it works
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
your route ──► AI SDK streamText (with experimental_telemetry)
|
|
14
|
+
│
|
|
15
|
+
▼
|
|
16
|
+
OpenTelemetry SDK ──► LangfuseSpanProcessor ──► Langfuse
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Langfuse subscribes to OpenTelemetry spans the AI SDK already emits when telemetry is enabled. No proxy, no wrapping; the SDK ships spans and Langfuse renders them.
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
<Steps>
|
|
24
|
+
<Step>
|
|
25
|
+
|
|
26
|
+
### Get Langfuse credentials
|
|
27
|
+
|
|
28
|
+
Sign up at [langfuse.com](https://langfuse.com/) (or self-host) and create a project. Copy the public and secret keys from project settings.
|
|
29
|
+
|
|
30
|
+
```sh title=".env.local"
|
|
31
|
+
LANGFUSE_PUBLIC_KEY=pk-lf-...
|
|
32
|
+
LANGFUSE_SECRET_KEY=sk-lf-...
|
|
33
|
+
LANGFUSE_BASE_URL=https://cloud.langfuse.com
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The base URL is region-specific: `https://cloud.langfuse.com` (EU), `https://us.cloud.langfuse.com`, or your self-hosted URL.
|
|
37
|
+
|
|
38
|
+
</Step>
|
|
39
|
+
<Step>
|
|
40
|
+
|
|
41
|
+
### Install the OTel and Langfuse packages
|
|
42
|
+
|
|
43
|
+
<InstallCommand npm={["@langfuse/tracing", "@langfuse/otel", "@opentelemetry/sdk-node"]} />
|
|
44
|
+
|
|
45
|
+
`@langfuse/tracing` provides the helpers that label traces with user, session, and trace name. `@langfuse/otel` provides the span processor. `@opentelemetry/sdk-node` is the OTel SDK.
|
|
46
|
+
|
|
47
|
+
</Step>
|
|
48
|
+
<Step>
|
|
49
|
+
|
|
50
|
+
### Initialize OpenTelemetry once at startup
|
|
51
|
+
|
|
52
|
+
Create an instrumentation file that boots the OTel SDK and registers the Langfuse span processor. In Next.js this goes in `instrumentation.ts` so it runs once per server process. Export the processor at module scope so other code can call `forceFlush()` on it.
|
|
53
|
+
|
|
54
|
+
```ts title="instrumentation.ts"
|
|
55
|
+
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
56
|
+
import { LangfuseSpanProcessor } from "@langfuse/otel";
|
|
57
|
+
|
|
58
|
+
export const langfuseSpanProcessor = new LangfuseSpanProcessor();
|
|
59
|
+
|
|
60
|
+
export async function register() {
|
|
61
|
+
if (process.env.NEXT_RUNTIME !== "nodejs") return;
|
|
62
|
+
|
|
63
|
+
const sdk = new NodeSDK({
|
|
64
|
+
spanProcessors: [langfuseSpanProcessor],
|
|
65
|
+
});
|
|
66
|
+
sdk.start();
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`NEXT_RUNTIME !== "nodejs"` skips the edge runtime, where OTel doesn't run. On Next.js 14 or earlier, also set `experimental.instrumentationHook = true` in `next.config.mjs`:
|
|
71
|
+
|
|
72
|
+
```js title="next.config.mjs"
|
|
73
|
+
const nextConfig = {
|
|
74
|
+
experimental: { instrumentationHook: true },
|
|
75
|
+
};
|
|
76
|
+
export default nextConfig;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
</Step>
|
|
80
|
+
<Step>
|
|
81
|
+
|
|
82
|
+
### Wrap AI SDK calls with `propagateAttributes`
|
|
83
|
+
|
|
84
|
+
Enable telemetry with `experimental_telemetry: { isEnabled: true }`, and wrap each call in `propagateAttributes` from `@langfuse/tracing` to set the trace name and group traces by user / session.
|
|
85
|
+
|
|
86
|
+
```ts title="app/api/chat/route.ts"
|
|
87
|
+
import { openai } from "@ai-sdk/openai";
|
|
88
|
+
import { streamText, convertToModelMessages } from "ai";
|
|
89
|
+
import type { UIMessage } from "ai";
|
|
90
|
+
import { propagateAttributes } from "@langfuse/tracing";
|
|
91
|
+
|
|
92
|
+
export async function POST(req: Request) {
|
|
93
|
+
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
94
|
+
|
|
95
|
+
const userId = "<resolve from your session>";
|
|
96
|
+
const sessionId = "<resolve from your thread state>";
|
|
97
|
+
|
|
98
|
+
const result = await propagateAttributes(
|
|
99
|
+
{ traceName: "chat-completion", userId, sessionId },
|
|
100
|
+
async () =>
|
|
101
|
+
streamText({
|
|
102
|
+
model: openai("gpt-4o"),
|
|
103
|
+
messages: await convertToModelMessages(messages),
|
|
104
|
+
experimental_telemetry: { isEnabled: true },
|
|
105
|
+
}),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return result.toUIMessageStreamResponse();
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`traceName` becomes the trace label in the Langfuse dashboard. `userId` and `sessionId` are the canonical Langfuse filter dimensions; pass real values from your auth and thread state, not literal strings.
|
|
113
|
+
|
|
114
|
+
</Step>
|
|
115
|
+
<Step>
|
|
116
|
+
|
|
117
|
+
### Run and verify
|
|
118
|
+
|
|
119
|
+
Send a message through your assistant. Within a few seconds, a trace should appear in your Langfuse dashboard with:
|
|
120
|
+
|
|
121
|
+
- The trace name set by `traceName`.
|
|
122
|
+
- A child span per LLM call and per tool call.
|
|
123
|
+
- Full prompt, completion, and token usage on each span.
|
|
124
|
+
- The metadata you passed (user, session, custom keys) as filters.
|
|
125
|
+
|
|
126
|
+
If nothing appears, check the server logs for OTel errors and confirm `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY` are loaded in the runtime that handles the request.
|
|
127
|
+
|
|
128
|
+
</Step>
|
|
129
|
+
</Steps>
|
|
130
|
+
|
|
131
|
+
## Notes
|
|
132
|
+
|
|
133
|
+
- **Serverless flush.** On serverless platforms the function exits before OTel flushes its buffer, dropping traces. Import the processor exported in the previous step and call `await langfuseSpanProcessor.forceFlush()` before responding, or use the runtime's `waitUntil` API. Langfuse's docs cover the deployment-specific patterns.
|
|
134
|
+
- **Self-hosting.** Point `LANGFUSE_BASE_URL` at your self-hosted instance. The integration is otherwise identical.
|
|
135
|
+
- **Sampling.** For high-traffic apps, configure OTel sampling on `NodeSDK` to keep cost predictable. Langfuse can also sample at the project level.
|
|
136
|
+
- **Pairing with Helicone.** They are complementary: Helicone proxies and logs every request; Langfuse traces the agent. Many teams use both.
|
|
137
|
+
|
|
138
|
+
## Related
|
|
139
|
+
|
|
140
|
+
<Cards>
|
|
141
|
+
<Card
|
|
142
|
+
title="LangSmith"
|
|
143
|
+
description="LangChain ecosystem alternative, uses wrapAISDK instead of OpenTelemetry."
|
|
144
|
+
href="/docs/integrations/observability/langsmith"
|
|
145
|
+
/>
|
|
146
|
+
<Card
|
|
147
|
+
title="Helicone"
|
|
148
|
+
description="Proxy-based request logging with cost, latency, and prompt diffs per call."
|
|
149
|
+
href="/docs/integrations/observability/helicone"
|
|
150
|
+
/>
|
|
151
|
+
<Card
|
|
152
|
+
title="AI SDK runtime"
|
|
153
|
+
description="The runtime that emits the telemetry Langfuse consumes."
|
|
154
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
155
|
+
/>
|
|
156
|
+
</Cards>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: LangSmith
|
|
3
|
+
description: Trace AI SDK calls into LangSmith with the wrapAISDK helper.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { LangChainIcon } from "@/components/icons/langchain";
|
|
7
|
+
|
|
8
|
+
[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
|
+
|
|
10
|
+
This page covers the **AI SDK** path. If you use [`@assistant-ui/react-langgraph`](/docs/runtimes/langgraph), tracing flows through LangGraph Cloud automatically; you only need this guide when your route handler talks to AI SDK directly.
|
|
11
|
+
|
|
12
|
+
## How it works
|
|
13
|
+
|
|
14
|
+
LangSmith provides a wrapper around the `ai` namespace. You call `wrapAISDK(ai)`, get back the same exports (`generateText`, `streamText`, `generateObject`, `streamObject`), and use those in place of the originals. Every call is then traced.
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
your route ──► wrapped streamText ──► LangSmith client ──► LangSmith
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
<Steps>
|
|
23
|
+
<Step>
|
|
24
|
+
|
|
25
|
+
### Get LangSmith credentials
|
|
26
|
+
|
|
27
|
+
Sign up at [smith.langchain.com](https://smith.langchain.com/) and copy an API key from settings.
|
|
28
|
+
|
|
29
|
+
```sh title=".env.local"
|
|
30
|
+
LANGSMITH_TRACING=true
|
|
31
|
+
LANGSMITH_API_KEY=lsv2_pt_...
|
|
32
|
+
LANGSMITH_PROJECT=assistant-ui
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`LANGSMITH_PROJECT` controls which project receives traces; the default project applies if you omit it. See LangSmith's [environment variable reference](https://docs.langchain.com/langsmith/how_to_environment_variables) for the full list.
|
|
36
|
+
|
|
37
|
+
</Step>
|
|
38
|
+
<Step>
|
|
39
|
+
|
|
40
|
+
### Install the LangSmith SDK
|
|
41
|
+
|
|
42
|
+
<InstallCommand npm={["langsmith"]} />
|
|
43
|
+
|
|
44
|
+
</Step>
|
|
45
|
+
<Step>
|
|
46
|
+
|
|
47
|
+
### Wrap the AI SDK
|
|
48
|
+
|
|
49
|
+
`wrapAISDK` re-exports `generateText`, `streamText`, `generateObject`, and `streamObject` with tracing enabled. Use the wrapped versions in your route.
|
|
50
|
+
|
|
51
|
+
```ts title="app/api/chat/route.ts"
|
|
52
|
+
import * as ai from "ai";
|
|
53
|
+
import { wrapAISDK } from "langsmith/experimental/vercel";
|
|
54
|
+
import { openai } from "@ai-sdk/openai";
|
|
55
|
+
import type { UIMessage } from "ai";
|
|
56
|
+
|
|
57
|
+
const { streamText } = wrapAISDK(ai);
|
|
58
|
+
|
|
59
|
+
export async function POST(req: Request) {
|
|
60
|
+
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
61
|
+
|
|
62
|
+
const result = streamText({
|
|
63
|
+
model: openai("gpt-4o"),
|
|
64
|
+
messages: await ai.convertToModelMessages(messages),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return result.toUIMessageStreamResponse();
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`convertToModelMessages` is not part of the wrapper, so import it from `ai` directly.
|
|
72
|
+
|
|
73
|
+
</Step>
|
|
74
|
+
<Step>
|
|
75
|
+
|
|
76
|
+
### Add metadata for grouping (optional)
|
|
77
|
+
|
|
78
|
+
Pass a `langsmith` provider option to tag traces with user, session, or run identifiers. Use `createLangSmithProviderOptions` to build the value:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { createLangSmithProviderOptions } from "langsmith/experimental/vercel";
|
|
82
|
+
|
|
83
|
+
const result = streamText({
|
|
84
|
+
model: openai("gpt-4o"),
|
|
85
|
+
messages: await ai.convertToModelMessages(messages),
|
|
86
|
+
providerOptions: {
|
|
87
|
+
langsmith: createLangSmithProviderOptions({
|
|
88
|
+
name: "chat-completion",
|
|
89
|
+
metadata: { userId, threadId },
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`name` becomes the run name in LangSmith. Traces filter by the metadata fields you pass; resolve `userId` and `threadId` from your auth and thread state, don't ship literal strings.
|
|
96
|
+
|
|
97
|
+
</Step>
|
|
98
|
+
<Step>
|
|
99
|
+
|
|
100
|
+
### Run and verify
|
|
101
|
+
|
|
102
|
+
Send a message. The trace should appear in your LangSmith project within seconds. Confirm:
|
|
103
|
+
|
|
104
|
+
- A new run named according to `name` (or the default `streamText`).
|
|
105
|
+
- Inputs (messages), outputs (completion), token usage, and latency are populated.
|
|
106
|
+
- Metadata fields appear as filters.
|
|
107
|
+
|
|
108
|
+
</Step>
|
|
109
|
+
</Steps>
|
|
110
|
+
|
|
111
|
+
## Notes
|
|
112
|
+
|
|
113
|
+
- **Serverless flush.** Serverless functions exit before LangSmith flushes batched traces. Before returning, force the flush with the `Client` from `langsmith`:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { Client } from "langsmith";
|
|
117
|
+
const client = new Client();
|
|
118
|
+
// ...inside your route handler, after streamText:
|
|
119
|
+
await client.awaitPendingTraceBatches();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Without this you will lose traces on Vercel, AWS Lambda, and similar platforms.
|
|
123
|
+
- **`experimental_telemetry` vs `wrapAISDK`.** The AI SDK has a generic `experimental_telemetry` flag that emits OpenTelemetry spans (used by [Langfuse](/docs/integrations/observability/langfuse)). `wrapAISDK` is LangSmith's own path; you do not need to set `experimental_telemetry` when using it.
|
|
124
|
+
- **LangGraph users.** If your backend is LangGraph Cloud, prefer the LangGraph runtime; tracing is built in. Use `wrapAISDK` only when calling AI SDK directly outside of LangGraph.
|
|
125
|
+
- **Version requirements.** LangSmith documents AI SDK v5 as the minimum and `langsmith >= 0.3.63`. The wrapper continues to work against v6 in practice; if you hit an incompatibility, check LangSmith's release notes.
|
|
126
|
+
|
|
127
|
+
## Related
|
|
128
|
+
|
|
129
|
+
<Cards>
|
|
130
|
+
<Card
|
|
131
|
+
icon={<LangChainIcon width={20} height={20} className="text-[#7FC8FF]" />}
|
|
132
|
+
title="LangGraph runtime"
|
|
133
|
+
description="If your backend is LangGraph, tracing flows through LangGraph Cloud automatically."
|
|
134
|
+
href="/docs/runtimes/langgraph"
|
|
135
|
+
/>
|
|
136
|
+
<Card
|
|
137
|
+
title="Langfuse"
|
|
138
|
+
description="OpenTelemetry-based alternative; OSS and self-hostable."
|
|
139
|
+
href="/docs/integrations/observability/langfuse"
|
|
140
|
+
/>
|
|
141
|
+
<Card
|
|
142
|
+
title="AI SDK runtime"
|
|
143
|
+
description="The runtime that ferries traces from the route to the chat UI."
|
|
144
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
145
|
+
/>
|
|
146
|
+
</Cards>
|