[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CJABMNTSBV5TAK97A9FH5Q":3,"skill-same:01M7CJABMNTSBV5TAK97A9FH5Q":66},{"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":6,"updatedAt":45,"install":46,"resources":59},"01M7CJABMNTSBV5TAK97A9FH5Q","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.","rossboyd\u002Fquickque","rossboyd","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3195729?v=4","01M7CG99NTNRFV0TWTZX9JY9CQ","rbyd","01M7CG99PH4WEP5P45VTBNPDB0",0,"MIT","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\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","907b1d897cc6743f7f133f8ea2021e1331b0b020",".codex\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque","https:\u002F\u002Fgithub.com\u002Frossboyd","www.bigideasgroup.co.uk","2026-09-22 02:03:50",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add rossboyd\u002Fquickque --skill json-render",{"tool":52,"command":53},"bunx","bunx skills add rossboyd\u002Fquickque --skill json-render",{"tool":55,"command":56},"pnpm","pnpm dlx skills add rossboyd\u002Fquickque --skill json-render","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render\u002FSKILL.md",true,[60],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"agents\u002Fopenai.yaml","REFERENCE","参考文档",177,"https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002F.tmp\u002Fplugins\u002Fplugins\u002Fvercel\u002Fskills\u002Fjson-render\u002Fagents\u002Fopenai.yaml",[67,76,84,91,98,106],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":72,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7CJSS21K09H3ZQZMPFR4ZAG","skill-installer","Install Codex skills into $CODEX_HOME\u002Fskills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).","Apache-2.0","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fskill-installer\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fskill-installer\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":80,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CJSM1F4E7RBXCS3C18EFBY","skill-creator","Create or update a Codex skill with appropriately scoped instructions and any needed supporting resources.","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fskill-creator\u002Flicense.txt","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fskill-creator\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CJSGF2PJM504Q6TZCNT27C","review-agent","Perform a read-only, defect-first review of a specified code change and return every actionable finding. Use when another agent delegates review of uncommitted changes, a base-branch diff, a commit, or custom review instructions.","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Freview-agent\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7CJSBQTPFEQYZF4VWS7QZ3N","plugin-creator","Create and scaffold plugin directories for Codex with a required `.codex-plugin\u002Fplugin.json`, optional plugin folders\u002Ffiles, valid manifest defaults, and personal-marketplace entries by default. Use when Codex needs to create a new personal plugin, add optional plugin structure, generate or update marketplace entries for plugin ordering and availability metadata, or update an existing local plugin during development with the CLI-driven cachebuster and reinstall flow.","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fplugin-creator\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":102,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7CJS5BHJZKA16353PVZGC50","openai-docs","Use for Codex models\u002Fpricing, scheduled tasks, skills, settings, setup, troubleshooting, customization, automations, and self-knowledge—including 'you,' 'your,' 'this app,' or 'this coding agent' when they refer to Codex—and for OpenAI APIs\u002Fproducts and ChatGPT Work. Also use for model choice\u002Fmigration, prompting, SDKs, Responses, Realtime, agents, evals, and Chat\u002FWork\u002FCodex comparisons. Do not use for generic app\u002Fsoftware tasks that merely mention Codex.","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fopenai-docs\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fopenai-docs\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":19},"01M7CJRY1FC048P3RF4YQZ6J8B","imagegen","Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG\u002Fvector\u002Fcode-native assets, extending an established icon or logo system, or building the visual directly in HTML\u002FCSS\u002Fcanvas.","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fimagegen\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Frossboyd\u002Fquickque\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002F.system\u002Fimagegen\u002FSKILL.md",[],[]]