Set up the Wix AI SDK

The Wix AI SDK lets you access AI models from supported providers via the Vercel AI SDK. Follow these steps to set it up:

Step 1 | Install the packages

Install the Vercel ai and Wix @wix/ai packages:

Copy

Step 2 | Import an AI method

Import one or more supported methods from the Vercel AI package:

Copy

Where <aiMethod> is the method you want to call. For example, this line imports generateText() from Vercel:

Copy

Step 3 | Set up a provider module

Import an AI provider from the Wix AI package. The import method depends on your hosting environment:

Step 4 | Specify the provider API and model

Call the AI method and specify the provider API and model:

Copy

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:

Copy

Complete code example

This code uses generateText() to call OpenAI's Responses API to generate text:

See also

Did this help?