任务决策
AI SDK:在原生能力与应用层可替换性之间取舍
选择直接使用供应商 SDK,还是通过应用级 SDK 统一流式输出、结构化结果与工具调用。
Recommendation
单一供应商且依赖原生能力时使用官方 SDK;需要 TypeScript 应用层抽象时评估 AI SDK。
选择标准
按真实约束逐项判断,不要只比较功能列表。
Runtime and UI needs
Separate basic server API access from shared streaming, frontend state, provider registry, framework, and generative UI requirements.4
Production ownership
Keep credentials, authorization, message conversion, tool execution, validation, retry, telemetry, evaluation, policy, and migration explicit.1
适用路线
这些条件会改变默认答案;请在作出承诺前逐项验证。
OpenAI official SDK
Choose OpenAI official SDK
Choose the official OpenAI SDK when OpenAI is deliberate and current OpenAI API fidelity matters more than provider portability.
Verify: Verify the exact API, model, tools, state, storage, retention, runtime, lifecycle, limits, and current pricing.1
Anthropic official SDK
Choose Anthropic official SDK
Choose Anthropic's official SDK when native Messages, streaming, tool-use, and Claude-specific semantics are deliberate.
Verify: The application still owns client tools, credentials, validation, state, failure handling, beta-feature risk, data terms, limits, and cost.2
Google official SDK
Choose Google official SDK
Choose the current Google Gen AI SDK when Gemini-native capabilities or a Google delivery path are material.
Verify: Use the current @google/genai family, distinguish Gemini Developer API from other Google routes, and verify package, auth, API lifecycle, region, policy, limits, and pricing.3
TypeScript provider abstraction
Choose TypeScript provider abstraction
Choose AI SDK when a common provider surface, provider registry, streaming, or generative UI primitives remove meaningful TypeScript application work.
Verify: Portability is partial; verify adapter coverage, provider-defined tools and options, escape hatches, runtime support, telemetry, and abstraction migration.4
边界: AI SDKs own provider-native versus provider-normalizing code integration and tool abstractions. LLM APIs own model selection, AI Agents own model-directed workflow control, and AI Gateways own centralized request-path policy.
关键差异
把真正会改变决策的边界单独比较。
- Fidelity
- Native SDKs expose provider behavior directly; an application abstraction may normalize or trail new capabilities.12
- Portability
- A common interface reduces some switching work but does not equalize prompts, tools, policies, state, outputs, or operations.14
官方资源
官方文档与继续决策的正式路径。
来源
支撑页面关键主张的资料。
- 1OpenAI SDK official documentation
OpenAI · Accessed Official
- 2Anthropic SDK official documentation
Anthropic · Accessed Official
- 3Google Gen AI SDK official documentation
Google Gen AI · Accessed Official
- 4AI SDK official documentation
AI · Accessed Official
- 5Gemini API libraries and legacy migration
Google · Accessed Official
- 6AI SDK tools and tool calling
Vercel AI SDK · Accessed Official