Setup
The examples use AI SDK 7. Install it with the OpenAI provider, the React hooks, and Zod:Provider Configuration
Create a Venice provider using the OpenAI-compatible adapter:Using
.chat() ensures requests go to Venice’s /chat/completions endpoint. In recent AI SDK versions, the default openai('model') syntax uses the Responses API instead, which Venice serves at /responses with some limitations. See the Responses API guide before using it.Streaming Chat (Next.js App Router)
API Route
React Component
Generating Text (Non-Streaming)
Structured Output
Tool Calling
stopWhen: isStepCount(2) lets the model answer in a second step after the tool runs. Without it, the stream ends after the tool result.
Image Generation
Venice image generation can be called directly alongside the AI SDK:Multi-Model Chat (Model Selector)
Let users choose between Venice models:sendMessage sends the selected model in the request body with each message, so switching models applies to the next message.
Web Search Integration
Turn on Venice web search with a model feature suffix on the model ID. The suffix passesvenice_parameters through the model ID, so you don’t need to add fields to the request:
Embeddings
For embeddings, useembeddingModel() on the provider directly:
Environment Variables
Recommended Models
Vercel AI SDK Docs
Official Vercel AI SDK documentation
Venice Models
Browse all Venice models