ai-sdk
Skill này làm gì
Skill hướng dẫn AI dùng AI SDK đúng cách bằng cách kiểm tra tài liệu của phiên bản dự án đã cài. Dành cho lập trình viên xây dựng chatbot AI, agent hoặc tính năng văn bản bằng TypeScript.
Khi nào nên dùng
- ✓Khi bạn xây dựng chatbot, agent hoặc tính năng tạo văn bản bằng AI SDK.
- ✓Khi bạn muốn thêm truyền phát, gọi công cụ hoặc đầu ra có cấu trúc vào ứng dụng AI.
- ✓Khi bạn có câu hỏi về các hàm của AI SDK như generateText hoặc streamText.
Liên kết skill
https://github.com/trycompai/crm/blob/release/.agents/skills/ai-sdk/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể giúp tôi thêm phản hồi chat truyền phát vào ứng dụng bằng AI SDK không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI đọc tài liệu AI SDK đi kèm phiên bản đã cài và viết mã khớp với tài liệu đó, thay vì dựa vào trí nhớ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
What the AI SDK Is
The AI SDK by Vercel (the ai package on npm) is a TypeScript toolkit for building AI applications. It provides a unified API across model providers for text generation, structured output, tool calling, agents, embeddings, and framework UI integrations.
- Repository: https://github.com/vercel/ai
- Documentation: https://ai-sdk.dev/docs
Critical: Do Not Trust Your Own Memory
Whatever you remember about the AI SDK is likely outdated. The SDK changes frequently across versions - APIs are renamed, removed, and added. Your training data almost certainly contains obsolete APIs, deprecated patterns, and model IDs that no longer exist. UI hooks like useChat are among the most frequently changed APIs, so be especially careful with client code.
Never write AI SDK code from memory. Always verify every API, option, and pattern against the documentation and source code for the version that is actually installed in the project.
Use the Bundled, Version-Matched Docs
The ai package ships its full documentation and source code inside node_modules. These always match the installed version, so trust them over anything you remember.
- Ensure
aiis installed. Ifnode_modules/ai/does not exist, install only theaipackage using the project's package manager (e.g.pnpm add ai). Install provider packages (e.g.@ai-sdk/openai) and framework packages (e.g.@ai-sdk/react) later, when the task requires them. - Read and grep the bundled docs at
node_modules/ai/docs/and the source atnode_modules/ai/src/. - Provider and framework packages bundle their own docs at
node_modules/@ai-sdk/<name>/docs/. - If something isn't in the bundled docs, search https://ai-sdk.dev/docs. You can append
.mdto any docs page URL to get its markdown, and search viahttps://ai-sdk.dev/api/search-docs?q=your_query. - If you cannot find support for an answer in the docs or source, say so explicitly — do not guess.
AI Gateway: The Fastest Way to Start
The Vercel AI Gateway is the fastest way to get started with the AI SDK. It provides access to models from OpenAI, Anthropic, Google, and other providers through a single API, without installing provider packages or managing multiple API keys.
To set it up:
- Authenticate with OIDC (for Vercel deployments) or get an AI Gateway API key.
- Provide it to your app via the
AI_GATEWAY_API_KEYenvironment variable. - Reference models with
provider/modelstrings.
For exact setup, authentication, and usage, read the bundled guide and the AI Gateway docs.
Choosing a Model
Never use model IDs from memory — models are released and retired frequently. Fetch the current list before writing code that references a model. Do not truncate the list (e.g. with head) so you can find the newest models:
# All available models
curl -s https://ai-gateway.vercel.sh/v1/models | jq -r '.data[].id'
# Filter by provider (e.g. anthropic, openai, google)
curl -s https://ai-gateway.vercel.sh/v1/models | jq -r '[.data[] | select(.id | startswith("anthropic/")) | .id] | reverse | .[]'
When multiple versions of a model exist, prefer the one with the highest version number.
Building and Consuming Agents
Use the SDK's built-in agent abstraction (such as ToolLoopAgent) rather than hand-rolling tool-calling loops. For end-to-end type safety, infer the UI message type from your agent definition when consuming it on the client (e.g. with useChat). Consuming an agent is framework-specific: check package.json to detect the stack, then follow the matching quickstart.
Look up the current agent, tool, and type-safety APIs in the bundled docs (node_modules/ai/docs/, especially the agents section) or at https://ai-sdk.dev/docs.
DevTools
AI SDK DevTools captures your AI SDK calls - requests, responses, tool calls, token usage, and multi-step runs - so you can inspect exactly what your agents do. Use it while developing to debug generations. It is a separate package and is intended for local development only.
For setup instructions, read the bundled DevTools documentation.
Keep the SDK Current
Outdated installs are the most common source of errors. Compare the installed version against the latest:
- Installed: the
versionfield innode_modules/ai/package.json. - Latest: run
npm view ai version.
If the installed version is a major version (or more) behind the latest, tell the user they are on an old release, and recomm
Câu hỏi thường gặp
Vì sao skill kiểm tra phiên bản đã cài?
AI SDK thay đổi thường xuyên, nên skill yêu cầu xác minh mọi API với tài liệu của phiên bản trong dự án.
Nó hỗ trợ những nhà cung cấp AI nào?
Nó hỗ trợ các nhà cung cấp như OpenAI, Anthropic và Google, cùng với truyền phát và embedding.
Skill có tự cài gói không?
Có. Nó cài gói ai nếu dự án chưa có, và chỉ cài gói nhà cung cấp khi cần.
Chi tiết
Mô tả gốc của tác giả
Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useCh
repo: trycompai/crm
Độ phổ biến
- Sao GitHub
- 12k
- Vị trí xếp hạng
- #11507
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
ai-elements
12kGiúp agent của bạn xây dựng giao diện chat AI với các thành phần có sẵn cho hội thoại, tin nhắn, hiển thị công cụ và ô nhập prompt.
better-accessibility
12kGiúp agent của bạn làm giao diện dùng được bằng bàn phím và trình đọc màn hình, bao gồm focus, nhãn, ARIA và biểu mẫu.
better-auth-best-practices
12kGiúp agent của bạn thiết lập Better Auth cho đăng nhập, phiên làm việc, OAuth và plugin trong ứng dụng TypeScript, theo các bước tài liệu.
better-colors
12kGiúp agent của bạn chuyển đổi, chọn và kiểm tra màu cho giao diện web, gồm bảng màu OKLCH, độ tương phản và chế độ tối.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.