The Wix AI SDK lets you access AI models from supported providers via the Vercel AI SDK. Follow these steps to set it up:
Install the Vercel ai and Wix @wix/ai packages:
Import one or more supported methods from the Vercel AI package:
Where <aiMethod> is the method you want to call. For example, this line imports generateText() from Vercel:
Import an AI provider from the Wix AI package. The import method depends on your hosting environment:
Call the AI method and specify the provider API and model:
Where:
<aiMethod> is the Vercel AI method you want to call.<providerModule> is the provider whose API you want to access.<api> is the API that has the functionality you need.<modelName> is the specific model you want to interact with.For example, this code snippet calls the generateText() method imported from Vercel, and configures it using the openai module imported from Wix:
This code uses generateText() to call OpenAI's Responses API to generate text: