API reference
AI Tools API reference
modern AI developer tools and the Vercel AI SDK
- Identifiers
- 113
- With full guides
- 71
- Types
- 5
Topics covered
- Vercel AI SDK basics
- Streaming UI with useChat
- Structured output with Zod
- Tool calling
- Multi-step agents
- Provider routing
- Caching AI responses
- Generative UI
Class
| Name | What it does |
|---|---|
Experimental_Agent | Experimental_Agent is a reusable AI SDK class that combines a model, instructions, tools, and loop control. It can generate text, stream output, or produce an API response while managing agent steps. |
ChatOpenAI | |
PromptTemplate | |
LLMChain | |
ConversationChain | |
RetrievalQA | |
ChatPromptTemplate | |
RecursiveCharacterTextSplitter | |
RunnableSequence | |
RunnablePassthrough | |
AgentExecutor | |
StateGraph | |
VectorStoreIndex | VectorStoreIndex creates a searchable vector index from documents. It chunks documents, embeds the chunks with an embedding model, and stores the embeddings in a vector database. |
QueryEngine | |
SimpleDirectoryReader |
Function
| Name | What it does |
|---|---|
generateText | generateText produces text from a prompt with a language model and can call tools during execution. It is suited to non-interactive tasks such as automation, drafting, summarization, and tool-using agents. |
streamText | streamText streams text generated by a language model, making it suitable for chatbots and other real-time applications. It can also work with tools to support streamed UI generation. |
generateObject | generateObject creates structured, typed data from a prompt and schema with a language model. It supports several output strategies and validates schema-based results. |
streamObject | streamObject streams typed, structured data from a language model using a prompt and schema. It supports object, array, enum, and no-schema output strategies. |
embed | Generates an embedding for one value with an embedding model. The returned object includes the original value and its numeric embedding vector. |
tool | tool() is a TypeScript helper for defining AI SDK tools with inferred input and context types. It connects schemas to execution and lifecycle callbacks without adding runtime behavior. |
createOpenAI | createOpenAI creates a customized OpenAI provider for the AI SDK. Configure credentials, endpoint, headers, or transport, then use the provider to create OpenAI models. |
embedMany | Embeds multiple values with an embedding model. Large requests are automatically split into smaller chunks when the model imposes embedding-count or UTF-8 input-byte limits. |
useObject | useObject consumes a streamed JSON response and parses it into a structured object according to a supplied schema. It is intended for AI SDK UI applications that progressively render generated structured data. |
convertToCoreMessages | Converts useChat UI messages into CoreMessage objects suitable for AI Core functions such as streamText. The documentation warns that current SDK versions perform this conversion automatically. |
createAnthropic | createAnthropic creates a customized Anthropic provider for the Vercel AI SDK. Configure the provider, then call it with a Claude model identifier to obtain a language model. |
createGoogleGenerativeAI | Creates a customized Google Generative AI provider for the Vercel AI SDK. Use the returned provider to create Google language or embedding models with provider-specific settings. |
wrapLanguageModel | wrapLanguageModel enhances a LanguageModelV4 by applying one or more middleware layers. It returns a new model instance and can optionally override the model and provider identifiers. |
customProvider | Creates a custom AI SDK provider that maps application-specific IDs to models from another provider. It can also fall back to another provider for missing models or capabilities. |
createProviderRegistry | Creates a registry for multiple providers and models. Registered models are retrieved with provider-qualified IDs such as providerId:modelId. |
stepCountIs | Creates a stop condition that ends a tool-calling loop when it reaches a specified number of steps. Use it with stopWhen in generateText or streamText. |
smoothStream | smoothStream smooths text and reasoning output from streamText by buffering content into configurable chunks and releasing them with optional delays. It returns a TransformStream for streamText's experimental_transform option. |
streamUI | |
createStreamableUI | Creates a server-to-client stream for React UI. The client can render its value as a normal React node while the server updates, appends, finalizes, or fails the stream. |
createStreamableValue | Creates a server-to-client stream for any serializable value. Control it with update, appendValue, done, and error, then consume the resulting value with the corresponding RSC reading APIs. |
createReactAgent | |
experimental_generateImage | experimental_generateImage creates images from a text prompt through a selected image model. Optional arguments can request multiple outputs and a specific size. |
experimental_transcribe | experimental_transcribe generates a transcript from an audio file using a transcription model. It accepts audio data or a URL and returns the completed transcript as text. |
experimental_generateSpeech | Generates speech audio from text with a selected speech model. Configure voice, format, language, provider-specific options, retries, and cancellation as needed. |
createMistral | createMistral creates a configurable Mistral provider for the AI SDK. Configure the provider, then call it with a Mistral model identifier to obtain a model. |
createGroq | Creates a customized Groq provider for the Vercel AI SDK. Configure credentials and the API endpoint, then call the provider with a Groq model identifier. |
createCohere | createCohere creates a customized Cohere provider instance from optional settings such as an API key, base URL, headers, and fetch implementation. Use the provider to create models for Cohere's chat API. |
createDeepSeek | createDeepSeek creates a configurable DeepSeek provider for the AI SDK. Configure credentials, endpoint, headers, or request handling, then select a DeepSeek model from the returned provider. |
createXai | createXai creates a customized xAI provider from @ai-sdk/xai. Configure its URL, authentication, headers, or fetch implementation, then use the returned provider to select xAI models. |
createFireworks | createFireworks builds a customized Fireworks provider for the AI SDK. Configure credentials, endpoint routing, headers, or request handling, then use the returned provider to create Fireworks models. |
createTogetherAI | createTogetherAI creates a customized Together.ai provider for the AI SDK. Configure its optional API key or API URL, then use the returned provider with Together.ai model identifiers. |
createReplicate | createReplicate creates a customized Replicate provider instance from @ai-sdk/replicate. Configure its API token, request URL, headers, or fetch implementation before selecting Replicate models. |
createAmazonBedrock | Creates a customized Amazon Bedrock provider for the AI SDK. Configure AWS settings such as the region and credential provider, then use the returned provider to select Bedrock models. |
createAzure | createAzure creates a customized Azure OpenAI provider from settings such as an Azure resource name and API key. The provider can also use a complete Foundry OpenAI v1 base URL or Microsoft Entra ID token authentication. |
createVertex | createVertex creates a customized Google Vertex provider from optional settings such as a Google Cloud project and location. Use the returned provider to select Vertex models for AI SDK operations. |
jsonSchema | Creates an AI SDK-compatible JSON schema from a JSON Schema definition, with optional custom validation. Use it for structured-data generation and tool inputs when dynamic schemas or non-Zod validation are needed. |
zodSchema | zodSchema converts a Zod schema into an AI SDK-compatible schema. It is useful for structured data generation and tools, especially when conversion options such as references must be configured. |
cosineSimilarity | Calculates the cosine similarity between two numeric vectors. Its signed result ranges from -1 to 1, with values near 1 indicating greater similarity. |
simulateReadableStream | Creates a ReadableStream that emits supplied values in order with optional initial and inter-chunk delays. It is mainly useful for testing streaming behavior or reproducing time-delayed responses. |
extractReasoningMiddleware | Extracts delimited reasoning from generated model output and exposes it separately from the main text. It supports XML-style tags and custom literal delimiters. |
Hook
| Name | What it does |
|---|---|
useChat | useChat is a React hook for building conversational interfaces. It streams provider responses, maintains chat state, and updates the UI as messages arrive. |
useCompletion | useCompletion is a React hook for text-completion interfaces. It streams provider output, manages completion state, and exposes complete for starting generation. |
useAssistant |
Type Alias
| Name | What it does |
|---|---|
CoreMessage | CoreMessage is the union used to describe system, user, assistant, and tool messages for AI SDK Core functions. Its role determines the allowed content structure, including multimodal user content and tool results. |
UIMessage | UIMessage is the AI SDK’s complete, UI-facing representation of a message and its application state. It carries identity, role, optional metadata, and typed parts for rendering text, data, and tool interactions. |
LanguageModelV2 | |
ToolCallPart | ToolCallPart is the AI SDK content-part shape for a model-generated tool invocation. It identifies the call, names the target tool, and stores schema-shaped arguments. |
ToolResultPart | ToolResultPart represents one completed tool call within a tool message. It links the result to the call and tool, stores JSON-serializable output, and optionally carries provider-specific metadata. |
StreamData | |
ModelMessage | ModelMessage is the AI SDK Core type for conversation messages sent to models. It unifies system, user, assistant, and tool messages, including multimodal content and tool interactions. |
ToolSet | ToolSet is the AI SDK type for a named collection of tools available to model-generation functions. It enables typed tool calls and results across streamText and generateText. |
Const
| Name | What it does |
|---|---|
Pinecone | |
Weaviate | |
Qdrant | |
Chroma | |
Milvus | |
pgvector | The RAG workflow uses pgvector with Postgres to store embeddings alongside chunked source content. Vector distance then supports similarity-based retrieval for AI applications. |
FAISS | |
Hugging Face Transformers | Hugging Face Transformers is represented in the Vercel AI SDK by the Hugging Face provider. Use its provider instance to create language models for text generation and streaming. |
Ollama | Ollama is available to the AI SDK through community providers. Install one, import its provider, and create a model by passing an Ollama model name. |
OpenAI API | |
Anthropic API | Anthropic is the AI SDK provider for Anthropic Messages API models. Import anthropic from @ai-sdk/anthropic, select a model by ID, and pass it to AI SDK generation functions. |
Google Gemini API | The Google provider lets AI SDK applications call Google Gemini models through @ai-sdk/google. Use google(modelId) to create a model for AI SDK generation functions, with authentication supplied by the documented environment variable. |
Mistral | mistral is the default Mistral provider from @ai-sdk/mistral. Call it with a model ID to create a model for AI SDK text generation and streaming. |
Cohere | The Cohere provider integrates Cohere language and embedding models with the AI SDK through @ai-sdk/cohere. Use the default cohere instance for standard setup or createCohere for customization. |
Replicate | replicate is the default Replicate provider from @ai-sdk/replicate. Use replicate.image(modelId) to create an image model for AI SDK generation functions. |
Together AI | togetherai is the default Together.ai provider exported by @ai-sdk/togetherai. Call it with a Together.ai model ID to create a model for use with AI SDK generation APIs. |
Groq | groq is the default Groq provider instance exported by @ai-sdk/groq. Use it with a model identifier to create a language model for AI SDK operations. |
LiteLLM | |
Instructor | |
DSPy | |
Guidance | |
Outlines | |
vLLM | |
LangChain | The @ai-sdk/langchain adapter connects LangChain and LangGraph with the AI SDK. It converts their streams and messages for AI SDK UI components, including text, tools, multimodal content, and typed data events. |
LlamaIndex | The LlamaIndex adapter connects LlamaIndex ChatEngine or QueryEngine streams to AI SDK UI integrations. Use @ai-sdk/llamaindex to convert engine output into a client-consumable UI message stream. |
Haystack | |
Semantic Kernel | |
AutoGen | |
CrewAI | |
Mastra | |
Pydantic AI | |
LangSmith | LangSmith adds monitoring and evaluation to AI SDK applications. Initialize tracing with wrapAISDK, and use traceable for custom spans around model or tool work. |
Langfuse | |
Helicone | |
Weights & Biases | Weights & Biases observability for the AI SDK is provided through Weave. It uses OpenTelemetry to capture AI SDK traces, including prompts, responses, flow, and cost, for inspection in Weave. |
Phoenix | |
Braintrust | Braintrust integrates with the AI SDK through OpenTelemetry to log and monitor LLM interactions. Configure its exporter for Next.js or its span processor for standalone Node.js. |
Model Context Protocol | |
System Prompt | A system prompt provides initial instructions that guide and constrain a model’s behavior. In the current AI SDK, pass it through instructions, alongside prompt or messages. |
Few-shot Prompting | |
Structured Output | The AI SDK generates schema-conforming structured data through the output option on generateText and streamText. Choose an output specification such as Output.object() or Output.array() and supply a supported schema. |
Streaming Responses | Streaming exposes parts of an AI response as soon as they are generated, so a UI can begin rendering earlier than with a blocking response. It improves perceived responsiveness for conversational interfaces. |
Token Streaming | Token streaming uses streamText to deliver language-model text incrementally. It enables responsive chatbots and other real-time applications, and can also work with tools to generate UI components. |
Rate Limiting | Rate limiting protects an API by restricting each client's requests within a time window. The documented example uses Upstash Redis and Upstash Ratelimit to allow five requests every 30 seconds and reject excess traffic. |
Caching | Cache AI provider responses temporarily and replay them for repeated requests. The recommended method uses language model middleware, with simulateReadableStream for cached streaming output. |
Retries | maxRetries controls how many times the AI SDK retries failures while starting a model call. It defaults to 2 and can be set to 0 to disable retries. |
Provider Abstraction | Provider abstraction gives AI SDK Core a common interface for working with models from different providers. It lets applications use the same API while switching among provider integrations more easily. |
Search across every package and filter by type in your dashboard.
Start learning