> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Set up the Wix AI SDK ## Article: Set up the Wix AI SDK ## Article Link: https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/set-up-the-wix-ai-sdk.md ## Article Content: # Set up the Wix AI SDK The Wix AI SDK lets you access AI models from [supported providers](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md) via the [Vercel AI SDK](https://ai-sdk.dev/). Follow these steps to set it up: ## Step 1 | Install the packages Install the Vercel `ai`, Wix `@wix/ai` and `zod` packages: ```bash npm install @wix/ai npm install ai@>=6.0.26 npm install zod@>=4.1.8 ``` ## Step 2 | Import an AI method Import one or more [supported methods](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md) from the Vercel AI package: ```js import { } from "ai"; ``` Where `` is the method you want to call. For example, this line imports `generateText()` from Vercel: ```js import { generateText } from "ai"; ``` ## Step 3 | Set up a provider module Import an AI provider from the Wix AI package. The import method depends on your [hosting environment](https://dev.wix.com/docs/sdk/articles/get-started/about-the-wix-java-script-sdk.md#uses): ::::tabs :::Wix-hosted In a [Wix-hosted environment](https://dev.wix.com/docs/sdk/articles/get-started/about-the-wix-java-script-sdk.md#uses), directly import the [provider module](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md): ```js import { } from "@wix/ai"; ``` Where `` is the provider whose API and models you want to access. For example, this line imports `openai` from Wix: ```js import { openai } from "@wix/ai"; ``` You can directly import the following provider modules: | Provider | Module name | | -------- | ----------- | | OpenAI | `openai` | | Runware | `runware` | ::: :::Self-hosted In a [self-hosted environment](https://dev.wix.com/docs/sdk/articles/get-started/about-the-wix-java-script-sdk.md#uses): 1. Initialize a [Wix client](https://dev.wix.com/docs/sdk/core-modules/sdk/wix-client.md) with an [authorization strategy](https://dev.wix.com/docs/sdk/articles/set-up-a-client/about-the-wix-client.md#authorization-strategy-auth): ```js import { createClient, } from "@wix/sdk"; const wixClient = createClient({}); ``` 2. Import a Wix utility method and call it to create an authenticated [provider module](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md): ```js import { } from "@wix/ai"; const = ({ client: wixClient }); ``` Where: - `` creates a provider module authenticated by the Wix client. - `` is the provider whose API and models you want to access. For example, this code snippet sets up and authenticates the `openai` provider module: ```js import { generateText } from "ai"; import { createOpenAI } from "@wix/ai"; import { createClient, AppStrategy } from "@wix/sdk"; // Create a Wix client with a Wix app context: const wixClient = createClient({ auth: AppStrategy({ appId: "YOUR_APP_ID", appSecret: "YOUR_APP_SECRET", instanceId: "YOUR_INSTANCE_ID", }), }); // Create an openai module with the authenticated client const openai = createOpenAI({ client: wixClient }); ``` You can create the following provider modules: | Provider | Module name | Create by calling | | -------- | ----------- | ----------------- | | OpenAI | `openai` | `createOpenAI()` | | Runware | `runware` | `createRunware()` | ::: :::: ## Step 4 | Specify the provider API and model Call the AI method and specify the [provider API and model](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md): ```js const result = await ({ model: .(""), // Additional method parameters }); ``` Where: - `` is the Vercel AI method you want to call. - `` is the provider whose API you want to access. - `` is the API that has the functionality you need. - `` 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: ```js const { text } = await generateText({ model: openai("gpt-5.2"), prompt: "Write a vegetarian lasagna recipe for 4 people.", }); ``` ## Complete code example This code uses [`generateText()`](https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text) to call [OpenAI's Responses API](https://ai-sdk.dev/providers/ai-sdk-providers/openai#responses-models) to generate text: ::::tabs :::Wix-hosted ```js // Import AI functionality from the Vercel SDK import { generateText } from "ai"; // Import the provider module import { openai } from "@wix/ai"; // Generate text by specifying the model name const { text } = await generateText({ model: openai("gpt-5.2"), // or openai.responses('gpt-5.2') prompt: "Write a vegetarian lasagna recipe for 4 people.", }); ``` ::: :::Self-hosted ```js // Import AI functionality from the Vercel SDK import { generateText } from "ai"; // Import the method to create an authenticated provider module import { createOpenAI } from "@wix/ai"; // Import Wix client methods import { createClient, AppStrategy } from "@wix/sdk"; // Create a Wix client authenticated with an AppStrategy const wixClient = createClient({ auth: AppStrategy({ appId: "YOUR_APP_ID", appSecret: "YOUR_APP_SECRET", instanceId: "YOUR_INSTANCE_ID", }), }); // Create the openai provider module via the authenticated Wix client const openai = createOpenAI({ client: wixClient }); // Generate text by specifying the model name const { text } = await generateText({ model: openai("gpt-5.2"), // or openai.responses('gpt-5.2') prompt: "Write a vegetarian lasagna recipe for 4 people.", }); ``` ::: :::: ## See also - [About the Wix AI APIs](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md) - [About AI credits on Wix](https://support.wix.com/en/article/about-ai-credits) - [Vercel AI SDK Core](https://ai-sdk.dev/docs/ai-sdk-core/overview)