npx skills add ...
npx skills add openai/plugins --skill json-render
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.
npx skills add openai/plugins --skill json-render
You are an expert in rendering AI SDK v6 chat responses — UIMessage parts, tool call results, streaming states, and structured data display in React applications.
When 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.
In v6, messages use the UIMessage type with a parts array:
The simplest approach is to use AI Elements, which handles all part types automatically:
⤳ skill: ai-elements — Full component library for AI interfaces
If you need custom rendering without AI Elements, follow this pattern:
Instead of dumping raw JSON, render structured tool output as human-readable cards:
The server route must use the correct v6 response format:
Cause: Rendering message.content instead of iterating message.parts.
Fix: Always iterate message.parts and handle each type:
Cause: Using JSON.stringify(output) as the display.
Fix: Create structured card components for known tool output shapes.
Cause: Not converting UI messages to model messages on the server.
Fix: Use await convertToModelMessages(messages) — it's async in v6.
Cause: Using toDataStreamResponse() instead of toUIMessageStreamResponse().
Fix: Use toUIMessageStreamResponse() when the client uses useChat with DefaultChatTransport.
Cause: Using the v5 useChat({ api: '/api/chat' }) pattern.
Fix: Use DefaultChatTransport:
Use validateUIMessages to validate incoming messages before processing: