API Reference

ai

TypeScript SDK for building LLM applications with streaming text, structured output, tool calls, and multi-provider abstraction.

Official Documentation ↗
CompatibilityThis documentation covers version v7.0.162. Check the official docs for the latest API surface.

Installation

npmnpm install ai

Methods

ai is typescript sdk for building llm applications with streaming text, structured output, tool calls, and multi-provider abstraction. This page documents the core methods, installation, and common usage patterns for the current stable release.

Installation

Install ai with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.

Core methods

The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v4.2 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.

Frequently asked questions

The faq section in the frontmatter answers the most common questions about ai, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://sdk.vercel.ai/docs · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:53:20.864Z.

FAQ

Which providers are supported?
OpenAI, Anthropic, Google, Mistral, Cohere, and others via @ai-sdk/* packages.
How does streaming work?
streamText returns an async iterable; consume result.textStream or pipe to a response.
Can I validate output?
Yes. generateObject takes a Zod schema and returns a typed, validated object.