AI SDK Core
AI SDK Core is a set of functions that allow you to interact with language models and other AI models. These functions are designed to be easy-to-use and flexible, allowing you to generate text, structured data, and embeddings from language models and other AI models.
AI SDK Core contains the following main functions:
generateText()
Generate text and call tools from a language model.
streamText()
Stream text and call tools from a language model.
Output
Structured output types for generateText and streamText.
embed()
Generate an embedding for a single value using an embedding model.
embedMany()
Generate embeddings for several values using an embedding model (batch embedding).
generateImage()
Generate images based on a given prompt using an image model.
experimental_generateVideo()
Generate videos based on a given prompt using a video model.
transcribe()
Generate a transcript from an audio file.
experimental_streamTranscribe()
Stream a transcript from live raw audio.
generateSpeech()
Generate speech audio from text.
uploadFile()
Upload a file to a provider and get a provider reference.
uploadSkill()
Upload a skill to a provider and get a provider reference.
It also contains the following helper functions:
tool()
Type inference helper function for tools.
experimental_getRealtimeToolDefinitions()
Convert AI SDK tools into realtime tool definitions.
Experimental_SandboxSession
Experimental execution environment interface passed to tool execution.
experimental_filterActiveTools()
Filters a tool set to only the currently active tools.
createMCPClient()
Creates a client for connecting to MCP servers.
validateJSONRPCMessage()
Validates unknown values as MCP JSON-RPC messages.
MCP Apps
Helpers for rendering interactive MCP tool UIs and filtering app-visible tools.
jsonSchema()
Creates AI SDK compatible JSON schema objects.
zodSchema()
Creates AI SDK compatible Zod schema objects.
createProviderRegistry()
Creates a registry for using models from multiple providers.
cosineSimilarity()
Calculates the cosine similarity between two vectors, e.g. embeddings.
simulateReadableStream()
Creates a ReadableStream that emits values with configurable delays.
wrapLanguageModel()
Wraps a language model with middleware.
wrapImageModel()
Wraps an image model with middleware.
extractReasoningMiddleware()
Extracts reasoning from the generated text and exposes it as a `reasoning` property on the result.
extractJsonMiddleware()
Extracts JSON from text content by stripping markdown code fences.
isStepCount()
Creates a stop condition that triggers after a specified number of steps.
hasToolCall()
Creates a stop condition that triggers when any specified tool is called.
isLoopFinished()
Creates a stop condition that lets the agent loop run until it naturally finishes.
simulateStreamingMiddleware()
Simulates streaming behavior with responses from non-streaming language models.
defaultSettingsMiddleware()
Applies default settings to a language model.
smoothStream()
Smooths text and reasoning streaming output.
generateId()
Helper function for generating unique IDs
createIdGenerator()
Creates an ID generator