Skip to main content

AI SDK Core

Large Language Models (LLMs) are advanced programs that can understand, create, and engage with human language on a large scale. They are trained on vast amounts of written material to recognize patterns in language and predict what might come next in a given piece of text. AI SDK Core simplifies working with LLMs by offering a standardized way of integrating them into your app - so you can focus on building great AI applications for your users, not waste time on technical details.

Why AI SDK Core?

Working with different AI providers typically requires learning provider-specific APIs, handling various response formats, and managing different error patterns. AI SDK Core abstracts these differences away with a unified interface.

Core Functions

AI SDK Core provides functions for different LLM use cases:

Text Generation

  • generateText: Generate text and tool calls in a single request. Ideal for non-interactive use cases like automation, batch processing, and agents.
  • streamText: Stream text and tool calls as they’re generated. Perfect for interactive applications like chatbots and real-time interfaces.

Structured Data Generation

Both generateText and streamText support structured output via the output property, allowing you to generate typed, schema-validated data:

Tool Calling

Tools allow models to perform actions or retrieve information:

Key Features

Provider-Agnostic

Switch between AI providers without changing your code. The same functions work with OpenAI, Anthropic, Google, and many others.

Type Safety

Full TypeScript support with automatic type inference for tool inputs/outputs and structured data schemas.

Streaming Support

Built-in streaming capabilities for real-time user experiences.

Multi-Step Execution

Automatic handling of multi-turn tool calls and conversations.

Error Handling

Consistent error handling across all providers with detailed error types.

Framework Integration

Seamless integration with React, Vue, Svelte, and Next.js through AI SDK UI and AI SDK RSC.

Installation

Then install your preferred provider:

Next Steps

Generating Text

Learn how to generate and stream text with AI SDK Core

Structured Data

Generate type-safe structured data from language models

Tool Calling

Enable models to use tools and perform actions

Settings

Configure model parameters and behavior

API Reference

For detailed API documentation, see the AI SDK Core API Reference.