vercel · Vercel AI SDK Docs
AI SDK UI: Message Metadata
Explains how to attach and access custom metadata objects within AI SDK UI message objects to extend the data structure of chat messages.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
AI SDK UI: Message Metadata
Explains how to attach and access custom metadata objects within AI SDK UI message objects to extend the data structure of chat messages.
When To Use
Use when you need to attach additional properties or context to individual messages in a chat interface beyond the standard role and content fields.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/ai-sdk-ui-message-metadata-workflow-guide.md | A guide explaining how to attach and use custom metadata within AI SDK UI messages for tracking information like timestamps and token usage. | Questions about a guide explaining how to attach and use custom metadata within AI SDK UI messages for tracking information like time... |
examples/ai-sdk-ui-message-metadata-typescript.text | A TypeScript code example demonstrating how to define a Zod schema for UIMessage metadata and type it for use with the AI SDK UI. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to define a Zod schema for UIMessage metadata and type it for use with th... |
examples/ai-sdk-ui-message-metadata-typescript-2.text | A TypeScript code example demonstrating how to use custom metadata within AI SDK UI messages by converting them to model messages. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use custom metadata within AI SDK UI messages by converting them to mo... |
examples/ai-sdk-ui-message-metadata-react-usechat.text | A React client component demonstrating how to implement and access custom metadata within the useChat hook from the AI SDK UI. | Exact payloads, commands, or snippets shown in A React client component demonstrating how to implement and access custom metadata within the useChat hook from the A... |
What This Skill Covers
- Message metadata allows you to attach custom information to messages at the message level. This is useful for tracking timestamps, model information, token u...
- Main sections:
Overview,Getting Started,Defining Metadata Types,Sending Metadata from the Server,Accessing Metadata on the Client.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://ai-sdk.dev/docs/ai-sdk-ui/message-metadata