[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E8EEE2W9P07WBWWBFNPKE8":3,"skill-same:01M7E8EEE2W9P07WBWWBFNPKE8":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":39,"commitSha":40,"skillDirectory":41,"forksCount":14,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":44,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M7E8EEE2W9P07WBWWBFNPKE8","json-render",null,"AI chat response rendering guidance — handling UIMessage parts, tool call displays, streaming states, and structured data presentation. Use when building custom chat UIs, rendering tool results, or troubleshooting AI response display issues.","wxdwu\u002Fnew-api","wxdwu","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F80968397?v=4","01M7E6AEMB59N90BKXD77EC83D","Xudong Wu","01M7E6AEMY2BXCDVZ9MJJHFQ4C",0,"AGPL-3.0","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: json-render\ndescription: AI chat response rendering guidance — handling UIMessage parts, tool call displays, streaming states, and structured data presentation. Use when building custom chat UIs, rendering tool results, or troubleshooting AI response display issues.\nmetadata:\n  priority: 4\n  docs:\n    - \"https:\u002F\u002Fnextjs.org\u002Fdocs\u002Fapp\u002Fapi-reference\u002Ffile-conventions\u002Froute\"\n  sitemap: \"https:\u002F\u002Fnextjs.org\u002Fsitemap.xml\"\n  pathPatterns:\n    - 'components\u002Fchat\u002F**'\n    - 'components\u002Fchat-*.tsx'\n    - 'components\u002Fchat-*.ts'\n    - 'src\u002Fcomponents\u002Fchat\u002F**'\n    - 'src\u002Fcomponents\u002Fchat-*.tsx'\n    - 'src\u002Fcomponents\u002Fchat-*.ts'\n    - 'components\u002Fmessage*.tsx'\n    - 'src\u002Fcomponents\u002Fmessage*.tsx'\n  bashPatterns: []\n---\n\n# AI Chat Response Rendering\n\nYou are an expert in rendering AI SDK v6 chat responses — UIMessage parts, tool call results, streaming states, and structured data display in React applications.\n\n## The Problem\n\nWhen building chat interfaces with AI SDK v6, the raw message format includes multiple part types (text, tool calls, reasoning, images). Without proper rendering, responses appear as raw JSON or malformed output.\n\n## AI SDK v6 Message Format\n\nIn v6, messages use the `UIMessage` type with a `parts` array:\n\n```ts\ninterface UIMessage {\n  id: string\n  role: 'user' | 'assistant'\n  parts: UIMessagePart[]\n}\n\n\u002F\u002F Part types:\n\u002F\u002F - { type: 'text', text: string }\n\u002F\u002F - { type: 'tool-\u003CtoolName>', toolCallId: string, state: string, input?: unknown, output?: unknown }\n\u002F\u002F     state values: 'partial-call' | 'call' | 'output-available' | 'approval-requested' | 'approval-responded' | 'output-denied'\n\u002F\u002F - { type: 'reasoning', text: string }\n\u002F\u002F - { type: 'step-start' }  \u002F\u002F internal, skip in rendering\n```\n\n## Recommended: Use AI Elements\n\nThe simplest approach is to use AI Elements, which handles all part types automatically:\n\n```tsx\nimport { Message } from '@\u002Fcomponents\u002Fai-elements\u002Fmessage'\nimport { Conversation } from '@\u002Fcomponents\u002Fai-elements\u002Fconversation'\n\n{messages.map((message) => (\n  \u003CMessage key={message.id} message={message} \u002F>\n))}\n```\n\n⤳ skill: ai-elements — Full component library for AI interfaces\n\n## Manual Rendering Pattern\n\nIf you need custom rendering without AI Elements, follow this pattern:\n\n```tsx\n'use client'\nimport { useChat } from '@ai-sdk\u002Freact'\nimport { DefaultChatTransport } from 'ai'\n\nexport function Chat() {\n  const { messages, sendMessage, status } = useChat({\n    transport: new DefaultChatTransport({ api: '\u002Fapi\u002Fchat' }),\n  })\n\n  const isLoading = status === 'streaming' || status === 'submitted'\n\n  return (\n    \u003Cdiv>\n      {messages.map((message) => (\n        \u003Cdiv key={message.id}>\n          {message.parts?.map((part, i) => {\n            \u002F\u002F 1. Text parts — render as formatted text\n            if (part.type === 'text' && part.text.trim()) {\n              return (\n                \u003Cdiv key={i} className={\n                  message.role === 'user'\n                    ? 'bg-primary text-primary-foreground rounded-lg px-3 py-2'\n                    : 'bg-muted rounded-lg px-3 py-2'\n                }>\n                  {part.text}\n                \u003C\u002Fdiv>\n              )\n            }\n\n            \u002F\u002F 2. Tool parts — type is \"tool-\u003CtoolName>\"\n            if (part.type.startsWith('tool-')) {\n              const toolPart = part as {\n                type: string\n                toolCallId: string\n                state: string\n                input?: unknown\n                output?: unknown\n              }\n              const toolName = toolPart.type.replace('tool-', '')\n\n              if (toolPart.state === 'output-available' && toolPart.output) {\n                return \u003CToolResultCard key={i} name={toolName} output={toolPart.output} \u002F>\n              }\n\n              if (toolPart.state === 'output-denied') {\n                return (\n                  \u003Cdiv key={i} className=\"text-sm text-muted-foreground\">\n                    {toolName} was denied\n                  \u003C\u002Fdiv>\n                )\n              }\n\n              if (toolPart.state === 'approval-requested') {\n                return (\n                  \u003Cdiv key={i} className=\"text-sm text-yellow-500\">\n                    {toolName} requires approval\n                  \u003C\u002Fdiv>\n                )\n              }\n\n              return (\n                \u003Cdiv key={i} className=\"text-sm text-muted-foreground animate-pulse\">\n                  Running {toolName}...\n                \u003C\u002Fdiv>\n              )\n            }\n\n            \u002F\u002F 3. Reasoning parts\n            if (part.type === 'reasoning') {\n              return (\n                \u003Cdetails key={i} className=\"text-xs text-muted-foreground\">\n                  \u003Csummary>Thinking...\u003C\u002Fsummary>\n                  \u003Cp className=\"whitespace-pre-wrap\">{(part as { text: string }).text}\u003C\u002Fp>\n                \u003C\u002Fdetails>\n              )\n            }\n\n            \u002F\u002F 4. Skip unknown types (step-start, etc.)\n            return null\n          })}\n        \u003C\u002Fdiv>\n      ))}\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n## Rendering Tool Results as Cards\n\nInstead of dumping raw JSON, render structured tool output as human-readable cards:\n\n```tsx\nfunction ToolResultCard({ name, output }: { name: string; output: unknown }) {\n  const data = output as Record\u003Cstring, unknown>\n\n  \u002F\u002F Pattern: Check for known result shapes and render accordingly\n  if (data?.success && data?.issue) {\n    const issue = data.issue as { identifier?: string; title?: string }\n    return (\n      \u003Cdiv className=\"rounded border border-border bg-card p-2 text-sm\">\n        \u003Cspan className=\"font-medium text-green-400\">\n          {name === 'createIssue' ? 'Created' : 'Updated'} {issue.identifier}\n        \u003C\u002Fspan>\n        \u003Cp className=\"text-muted-foreground\">{issue.title}\u003C\u002Fp>\n      \u003C\u002Fdiv>\n    )\n  }\n\n  if (data?.items && Array.isArray(data.items)) {\n    return (\n      \u003Cdiv className=\"rounded border border-border bg-card p-2 text-sm\">\n        \u003Cp className=\"font-medium\">{data.items.length} results\u003C\u002Fp>\n        {data.items.slice(0, 5).map((item: Record\u003Cstring, unknown>, i: number) => (\n          \u003Cp key={i} className=\"text-muted-foreground\">{String(item.name || item.title || item.id)}\u003C\u002Fp>\n        ))}\n      \u003C\u002Fdiv>\n    )\n  }\n\n  if (data?.error) {\n    return (\n      \u003Cdiv className=\"rounded border border-destructive\u002F30 bg-destructive\u002F10 p-2 text-sm text-destructive\">\n        {String(data.error)}\n      \u003C\u002Fdiv>\n    )\n  }\n\n  \u002F\u002F Fallback: simple completion message (not raw JSON)\n  return (\n    \u003Cdiv className=\"rounded border border-border bg-card p-2 text-xs text-muted-foreground\">\n      {name} completed\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n## Server-Side Requirements\n\nThe server route must use the correct v6 response format:\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { streamText, convertToModelMessages, gateway } from 'ai'\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json()\n\n  \u002F\u002F IMPORTANT: convertToModelMessages is async in v6\n  const modelMessages = await convertToModelMessages(messages)\n\n  const result = streamText({\n    model: gateway('anthropic\u002Fclaude-sonnet-4.6'),\n    messages: modelMessages,\n  })\n\n  \u002F\u002F Use toUIMessageStreamResponse for chat UIs (not toDataStreamResponse)\n  return result.toUIMessageStreamResponse()\n}\n```\n\n## Client-Side Requirements\n\n```tsx\nimport { useChat } from '@ai-sdk\u002Freact'\nimport { DefaultChatTransport } from 'ai'\n\nconst { messages, sendMessage, status } = useChat({\n  \u002F\u002F v6 uses transport instead of api\n  transport: new DefaultChatTransport({ api: '\u002Fapi\u002Fchat' }),\n})\n\n\u002F\u002F v6 uses sendMessage instead of handleSubmit\nsendMessage({ text: inputValue })\n\n\u002F\u002F Status values: 'ready' | 'submitted' | 'streaming'\nconst isLoading = status === 'streaming' || status === 'submitted'\n```\n\n## Common Mistakes\n\n### 1. Raw JSON in chat responses\n\n**Cause**: Rendering `message.content` instead of iterating `message.parts`.\n\n**Fix**: Always iterate `message.parts` and handle each type:\n\n```tsx\n\u002F\u002F WRONG — shows raw JSON\n\u003Cdiv>{message.content}\u003C\u002Fdiv>\n\n\u002F\u002F RIGHT — renders each part type\n{message.parts?.map((part, i) => {\n  if (part.type === 'text') return \u003Cspan key={i}>{part.text}\u003C\u002Fspan>\n  \u002F\u002F ... handle other types\n})}\n```\n\n### 2. Tool results showing as JSON blobs\n\n**Cause**: Using `JSON.stringify(output)` as the display.\n\n**Fix**: Create structured card components for known tool output shapes.\n\n### 3. \"Invalid prompt: messages do not contain...\" error\n\n**Cause**: Not converting UI messages to model messages on the server.\n\n**Fix**: Use `await convertToModelMessages(messages)` — it's async in v6.\n\n### 4. Messages not appearing \u002F empty responses\n\n**Cause**: Using `toDataStreamResponse()` instead of `toUIMessageStreamResponse()`.\n\n**Fix**: Use `toUIMessageStreamResponse()` when the client uses `useChat` with `DefaultChatTransport`.\n\n### 5. useChat not working with v6\n\n**Cause**: Using the v5 `useChat({ api: '\u002Fapi\u002Fchat' })` pattern.\n\n**Fix**: Use `DefaultChatTransport`:\n\n```tsx\n\u002F\u002F v5 (old)\nconst { messages, handleSubmit, input } = useChat({ api: '\u002Fapi\u002Fchat' })\n\n\u002F\u002F v6 (current)\nconst { messages, sendMessage, status } = useChat({\n  transport: new DefaultChatTransport({ api: '\u002Fapi\u002Fchat' }),\n})\n```\n\n## Decision Tree\n\n```\nBuilding a chat UI with AI SDK v6?\n  └─ Want pre-built components?\n       └─ Yes → Use AI Elements (⤳ skill: ai-elements)\n       └─ No → Manual rendering with parts iteration\n            └─ Tool results look like JSON?\n                 └─ Create ToolResultCard components for each tool's output shape\n            └─ Text not rendering?\n                 └─ Check part.type === 'text' and use part.text\n            └─ Server errors?\n                 └─ Check: await convertToModelMessages(), toUIMessageStreamResponse()\n```\n\n## Server-Side Message Validation\n\nUse `validateUIMessages` to validate incoming messages before processing:\n\n```ts\nimport { validateUIMessages, convertToModelMessages, streamText, gateway } from 'ai'\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json()\n  const validatedMessages = validateUIMessages(messages)\n  const modelMessages = await convertToModelMessages(validatedMessages)\n  \u002F\u002F ...\n}\n```\n\n## Official Documentation\n\n- [AI SDK UI](https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui)\n- [useChat Reference](https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fchatbot)\n- [UIMessage Types](https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Freference\u002Fai-sdk-core\u002Fui-message)\n- [AI Elements](https:\u002F\u002Fai-sdk.dev\u002Felements)\n","# AI Chat Response Rendering\n\nYou are an expert in rendering AI SDK v6 chat responses — UIMessage parts, tool call results, streaming states, and structured data display in React applications.\n\n## The Problem\n\nWhen building chat interfaces with AI SDK v6, the raw message format includes multiple part types (text, tool calls, reasoning, images). Without proper rendering, responses appear as raw JSON or malformed output.\n\n## AI SDK v6 Message Format\n\nIn v6, messages use the `UIMessage` type with a `parts` array:\n\n```ts\ninterface UIMessage {\n  id: string\n  role: 'user' | 'assistant'\n  parts: UIMessagePart[]\n}\n\n\u002F\u002F Part types:\n\u002F\u002F - { type: 'text', text: string }\n\u002F\u002F - { type: 'tool-\u003CtoolName>', toolCallId: string, state: string, input?: unknown, output?: unknown }\n\u002F\u002F     state values: 'partial-call' | 'call' | 'output-available' | 'approval-requested' | 'approval-responded' | 'output-denied'\n\u002F\u002F - { type: 'reasoning', text: string }\n\u002F\u002F - { type: 'step-start' }  \u002F\u002F internal, skip in rendering\n```\n\n## Recommended: Use AI Elements\n\nThe simplest approach is to use AI Elements, which handles all part types automatically:\n\n```tsx\nimport { Message } from '@\u002Fcomponents\u002Fai-elements\u002Fmessage'\nimport { Conversation } from '@\u002Fcomponents\u002Fai-elements\u002Fconversation'\n\n{messages.map((message) => (\n  \u003CMessage key={message.id} message={message} \u002F>\n))}\n```\n\n⤳ skill: ai-elements — Full component library for AI interfaces\n\n## Manual Rendering Pattern\n\nIf you need custom rendering without AI Elements, follow this pattern:\n\n```tsx\n'use client'\nimport { useChat } from '@ai-sdk\u002Freact'\nimport { DefaultChatTransport } from 'ai'\n\nexport function Chat() {\n  const { messages, sendMessage, status } = useChat({\n    transport: new DefaultChatTransport({ api: '\u002Fapi\u002Fchat' }),\n  })\n\n  const isLoading = status === 'streaming' || status === 'submitted'\n\n  return (\n    \u003Cdiv>\n      {messages.map((message) => (\n        \u003Cdiv key={message.id}>\n          {message.parts?.map((part, i) => {\n            \u002F\u002F 1. Text parts — render as formatted text\n            if (part.type === 'text' && part.text.trim()) {\n              return (\n                \u003Cdiv key={i} className={\n                  message.role === 'user'\n                    ? 'bg-primary text-primary-foreground rounded-lg px-3 py-2'\n                    : 'bg-muted rounded-lg px-3 py-2'\n                }>\n                  {part.text}\n                \u003C\u002Fdiv>\n              )\n            }\n\n            \u002F\u002F 2. Tool parts — type is \"tool-\u003CtoolName>\"\n            if (part.type.startsWith('tool-')) {\n              const toolPart = part as {\n                type: string\n                toolCallId: string\n                state: string\n                input?: unknown\n                output?: unknown\n              }\n              const toolName = toolPart.type.replace('tool-', '')\n\n              if (toolPart.state === 'output-available' && toolPart.output) {\n                return \u003CToolResultCard key={i} name={toolName} output={toolPart.output} \u002F>\n              }\n\n              if (toolPart.state === 'output-denied') {\n                return (\n                  \u003Cdiv key={i} className=\"text-sm text-muted-foreground\">\n                    {toolName} was denied\n                  \u003C\u002Fdiv>\n                )\n              }\n\n              if (toolPart.state === 'approval-requested') {\n                return (\n                  \u003Cdiv key={i} className=\"text-sm text-yellow-500\">\n                    {toolName} requires approval\n                  \u003C\u002Fdiv>\n                )\n              }\n\n              return (\n                \u003Cdiv key={i} className=\"text-sm text-muted-foreground animate-pulse\">\n                  Running {toolName}...\n                \u003C\u002Fdiv>\n              )\n            }\n\n            \u002F\u002F 3. Reasoning parts\n            if (part.type === 'reasoning') {\n              return (\n                \u003Cdetails key={i} className=\"text-xs text-muted-foreground\">\n                  \u003Csummary>Thinking...\u003C\u002Fsummary>\n                  \u003Cp className=\"whitespace-pre-wrap\">{(part as { text: string }).text}\u003C\u002Fp>\n                \u003C\u002Fdetails>\n              )\n            }\n\n            \u002F\u002F 4. Skip unknown types (step-start, etc.)\n            return null\n          })}\n        \u003C\u002Fdiv>\n      ))}\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n## Rendering Tool Results as Cards\n\nInstead of dumping raw JSON, render structured tool output as human-readable cards:\n\n```tsx\nfunction ToolResultCard({ name, output }: { name: string; output: unknown }) {\n  const data = output as Record\u003Cstring, unknown>\n\n  \u002F\u002F Pattern: Check for known result shapes and render accordingly\n  if (data?.success && data?.issue) {\n    const issue = data.issue as { identifier?: string; title?: string }\n    return (\n      \u003Cdiv className=\"rounded border border-border bg-card p-2 text-sm\">\n        \u003Cspan className=\"font-medium text-green-400\">\n          {name === 'createIssue' ? 'Created' : 'Updated'} {issue.identifier}\n        \u003C\u002Fspan>\n        \u003Cp className=\"text-muted-foreground\">{issue.title}\u003C\u002Fp>\n      \u003C\u002Fdiv>\n    )\n  }\n\n  if (data?.items && Array.isArray(data.items)) {\n    return (\n      \u003Cdiv className=\"rounded border border-border bg-card p-2 text-sm\">\n        \u003Cp className=\"font-medium\">{data.items.length} results\u003C\u002Fp>\n        {data.items.slice(0, 5).map((item: Record\u003Cstring, unknown>, i: number) => (\n          \u003Cp key={i} className=\"text-muted-foreground\">{String(item.name || item.title || item.id)}\u003C\u002Fp>\n        ))}\n      \u003C\u002Fdiv>\n    )\n  }\n\n  if (data?.error) {\n    return (\n      \u003Cdiv className=\"rounded border border-destructive\u002F30 bg-destructive\u002F10 p-2 text-sm text-destructive\">\n        {String(data.error)}\n      \u003C\u002Fdiv>\n    )\n  }\n\n  \u002F\u002F Fallback: simple completion message (not raw JSON)\n  return (\n    \u003Cdiv className=\"rounded border border-border bg-card p-2 text-xs text-muted-foreground\">\n      {name} completed\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n## Server-Side Requirements\n\nThe server route must use the correct v6 response format:\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { streamText, convertToModelMessages, gateway } from 'ai'\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json()\n\n  \u002F\u002F IMPORTANT: convertToModelMessages is async in v6\n  const modelMessages = await convertToModelMessages(messages)\n\n  const result = streamText({\n    model: gateway('anthropic\u002Fclaude-sonnet-4.6'),\n    messages: modelMessages,\n  })\n\n  \u002F\u002F Use toUIMessageStreamResponse for chat UIs (not toDataStreamResponse)\n  return result.toUIMessageStreamResponse()\n}\n```\n\n## Client-Side Requirements\n\n```tsx\nimport { useChat } from '@ai-sdk\u002Freact'\nimport { DefaultChatTransport } from 'ai'\n\nconst { messages, sendMessage, status } = useChat({\n  \u002F\u002F v6 uses transport instead of api\n  transport: new DefaultChatTransport({ api: '\u002Fapi\u002Fchat' }),\n})\n\n\u002F\u002F v6 uses sendMessage instead of handleSubmit\nsendMessage({ text: inputValue })\n\n\u002F\u002F Status values: 'ready' | 'submitted' | 'streaming'\nconst isLoading = status === 'streaming' || status === 'submitted'\n```\n\n## Common Mistakes\n\n### 1. Raw JSON in chat responses\n\n**Cause**: Rendering `message.content` instead of iterating `message.parts`.\n\n**Fix**: Always iterate `message.parts` and handle each type:\n\n```tsx\n\u002F\u002F WRONG — shows raw JSON\n\u003Cdiv>{message.content}\u003C\u002Fdiv>\n\n\u002F\u002F RIGHT — renders each part type\n{message.parts?.map((part, i) => {\n  if (part.type === 'text') return \u003Cspan key={i}>{part.text}\u003C\u002Fspan>\n  \u002F\u002F ... handle other types\n})}\n```\n\n### 2. Tool results showing as JSON blobs\n\n**Cause**: Using `JSON.stringify(output)` as the display.\n\n**Fix**: Create structured card components for known tool output shapes.\n\n### 3. \"Invalid prompt: messages do not contain...\" error\n\n**Cause**: Not converting UI messages to model messages on the server.\n\n**Fix**: Use `await convertToModelMessages(messages)` — it's async in v6.\n\n### 4. Messages not appearing \u002F empty responses\n\n**Cause**: Using `toDataStreamResponse()` instead of `toUIMessageStreamResponse()`.\n\n**Fix**: Use `toUIMessageStreamResponse()` when the client uses `useChat` with `DefaultChatTransport`.\n\n### 5. useChat not working with v6\n\n**Cause**: Using the v5 `useChat({ api: '\u002Fapi\u002Fchat' })` pattern.\n\n**Fix**: Use `DefaultChatTransport`:\n\n```tsx\n\u002F\u002F v5 (old)\nconst { messages, handleSubmit, input } = useChat({ api: '\u002Fapi\u002Fchat' })\n\n\u002F\u002F v6 (current)\nconst { messages, sendMessage, status } = useChat({\n  transport: new DefaultChatTransport({ api: '\u002Fapi\u002Fchat' }),\n})\n```\n\n## Decision Tree\n\n```\nBuilding a chat UI with AI SDK v6?\n  └─ Want pre-built components?\n       └─ Yes → Use AI Elements (⤳ skill: ai-elements)\n       └─ No → Manual rendering with parts iteration\n            └─ Tool results look like JSON?\n                 └─ Create ToolResultCard components for each tool's output shape\n            └─ Text not rendering?\n                 └─ Check part.type === 'text' and use part.text\n            └─ Server errors?\n                 └─ Check: await convertToModelMessages(), toUIMessageStreamResponse()\n```\n\n## Server-Side Message Validation\n\nUse `validateUIMessages` to validate incoming messages before processing:\n\n```ts\nimport { validateUIMessages, convertToModelMessages, streamText, gateway } from 'ai'\n\nexport async function POST(req: Request) {\n  const { messages } = await req.json()\n  const validatedMessages = validateUIMessages(messages)\n  const modelMessages = await convertToModelMessages(validatedMessages)\n  \u002F\u002F ...\n}\n```\n\n## Official Documentation\n\n- [AI SDK UI](https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui)\n- [useChat Reference](https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Fai-sdk-ui\u002Fchatbot)\n- [UIMessage Types](https:\u002F\u002Fai-sdk.dev\u002Fdocs\u002Freference\u002Fai-sdk-core\u002Fui-message)\n- [AI Elements](https:\u002F\u002Fai-sdk.dev\u002Felements)\n",{"name":5,"metadata":24,"description":7},{"docs":25,"sitemap":27,"priority":28,"bashPatterns":29,"pathPatterns":30},[26],"https:\u002F\u002Fnextjs.org\u002Fdocs\u002Fapp\u002Fapi-reference\u002Ffile-conventions\u002Froute","https:\u002F\u002Fnextjs.org\u002Fsitemap.xml",4,[],[31,32,33,34,35,36,37,38],"components\u002Fchat\u002F**","components\u002Fchat-*.tsx","components\u002Fchat-*.ts","src\u002Fcomponents\u002Fchat\u002F**","src\u002Fcomponents\u002Fchat-*.tsx","src\u002Fcomponents\u002Fchat-*.ts","components\u002Fmessage*.tsx","src\u002Fcomponents\u002Fmessage*.tsx","main","dde9a06ab10bce3fe52058c783826590231f7df3","plugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api","https:\u002F\u002Fgithub.com\u002Fwxdwu","24120128@bjtu.edu.cn","I am Xudong Wu，a student in beijing jiaotong University, \"I am eager to learn on GitHub and contribute my part to this community.","2026-10-05 17:26:50",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add wxdwu\u002Fnew-api --skill json-render",{"tool":53,"command":54},"bunx","bunx skills add wxdwu\u002Fnew-api --skill json-render",{"tool":56,"command":57},"pnpm","pnpm dlx skills add wxdwu\u002Fnew-api --skill json-render","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render\u002FSKILL.md",true,[61],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"agents\u002Fopenai.yaml","REFERENCE","参考文档",177,"https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render\u002Fagents\u002Fopenai.yaml",[68,75,82,89,96,103],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7E8SVA2N0JA09RW1XJYXCWX","Zotero","Use Zotero Desktop from Codex to enable\u002Fprobe the local API, search a local Zotero library, list items\u002Fcollections\u002Ftags, export BibTeX, insert citation keys into LaTeX or Markdown drafts, read indexed full text when requested, and import BibTeX\u002FRIS records into Zotero through the connector server. Use when the user mentions Zotero, citations, references.bib, BibTeX export, local Zotero API, localhost:23119, or adding citations from a Zotero library.","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fzotero\u002Fskills\u002Fzotero\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E8ST1FJAD5PWTW2FN1NSK0","zoom-apps-sdk","Use when using Apps SDK.","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7E8SRW074NNNCZRCZA5T3Z1","setup-zoom-websockets","Use when building Zoom WebSockets.","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M7E8SPCFMD3YVPRX2MW8X3RA","setup-zoom-webhooks","Use when building Zoom webhooks.","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fzoom\u002Fskills\u002Fwebhooks\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M7E8SMCH4RPCX8YSBNGWQCMP","zoom-virtual-agent-web","Zoom Virtual Agent SDK for web embeds. Use for campaign or entry ID chat launch, event-driven controls, user context updates, and CSP-safe deployment.","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fzoom\u002Fskills\u002Fvirtual-agent\u002Fweb\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7E8SJCAY323E36Z8SAP8H4M","zoom-virtual-agent-ios","Zoom Virtual Agent iOS integration via WKWebView. Use for Swift\u002FObjective-C script injection, message handlers, support_handoff relay, and URL routing policies.","https:\u002F\u002Fgithub.com\u002Fwxdwu\u002Fnew-api\u002Fblob\u002Fmain\u002Fplugins\u002F.tmp\u002Fplugins\u002Fplugins\u002Fzoom\u002Fskills\u002Fvirtual-agent\u002Fios\u002FSKILL.md",[],[]]