meetsmore/use-ai
Overview
This skill provides a concise reference for the Vercel AI SDK, a TypeScript toolkit for building AI-powered frontends and server integrations. It covers text and structured generation, streaming, tool definitions, agents, hooks for React/Vue/Svelte, and provider integrations. Use it to implement production-ready chat UIs, tool-calling flows, and agent workflows with streaming support.
How this skill works
The SDK exposes core functions like generateText/streamText and generateObject/streamObject for synchronous and streaming generation. It enables defining tools with Zod schemas and executing them inside model runs, and it supplies a ToolLoopAgent for orchestrating multi-step agent workflows. UI hooks such as useChat, useCompletion, and useObject connect frontend components to streaming model responses and transport layers.
When to use it
- Building chat interfaces with streaming responses (useChat).
- Generating free-form text or structured JSON from models (generateText/generateObject).
- Defining callable tools with typed inputs and executing them from LLMs.
- Implementing agents that loop over tools and decisions (ToolLoopAgent).
- Integrating with external providers (OpenAI, Anthropic, Google, Mistral).
Best practices
- Use Zod schemas for tool input/output to validate and type structured data.
- Prefer streaming APIs (streamText/streamObject) for responsive UIs and progressive rendering.
- Isolate provider configuration so you can swap models without changing app logic.
- Limit agent step counts and use stopWhen/prepareStep controls to avoid runaway loops.
- Convert UI messages to model messages with provided helpers for consistent prompts.
Example use cases
- React chat widget that streams model replies with useChat and a custom transport.
- Server route that converts UI messages and streams model output to the client.
- Tool-enabled assistant that calls a weather or search tool via typed Zod inputs.
- Agent that performs multi-step research and calculations using ToolLoopAgent with stopWhen.
- Streaming JSON generator for forms or data ingestion using generateObject/streamObject.
FAQ
Use useChat for multi-turn chat with streaming and state management. Use useCompletion for one-off text completions.
How do I validate tool inputs and outputs?
Define inputSchema and output types with Zod when creating tool() to enforce validation and provide clear typing.