Recommendation

单一供应商且依赖原生能力时使用官方 SDK;需要 TypeScript 应用层抽象时评估 AI SDK。

先明确是否需要跨供应商、UI 流式体验和统一工具接口。12

适用范围: TypeScript and JavaScript application teams integrating generative-model APIs after defining the underlying provider and workload requirements

Main trade-off

抽象层减少切换成本,但会落后于供应商新能力或掩盖差异。1234

选择标准

按真实约束逐项判断,不要只比较功能列表。

  1. Provider commitment

    Decide whether one provider is an intentional dependency or credible provider choice is a hard requirement.14

  2. Native feature fidelity

    List the tools, events, streaming, realtime, multimodal, state, and provider-specific options the application cannot wait to receive through an adapter.12

  3. Runtime and UI needs

    Separate basic server API access from shared streaming, frontend state, provider registry, framework, and generative UI requirements.4

  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
Application surface
AI SDK adds shared TypeScript and UI primitives while provider SDKs primarily expose their provider APIs.12
Ownership
Every route leaves authorization, tool execution, validation, evaluation, observability, cost control, and recovery with the application.14

官方资源

官方文档与继续决策的正式路径。

来源

支撑页面关键主张的资料。

  1. 1
    OpenAI SDK official documentation

    OpenAI · Accessed Official

  2. 2
    Anthropic SDK official documentation

    Anthropic · Accessed Official

  3. 3
    Google Gen AI SDK official documentation

    Google Gen AI · Accessed Official

  4. 4
    AI SDK official documentation

    AI · Accessed Official

  5. 5
    Gemini API libraries and legacy migration

    Google · Accessed Official

  6. 6
    AI SDK tools and tool calling

    Vercel AI SDK · Accessed Official